I'm trying to achieve this:
Using VS Code as my Editor for JavaScript and TypeScript, having formatting rules from eslint-config-google
applied automatically when saving a JavaScript/TypeScript document.
My devDependencies
are these:
"devDependencies": {
"@types/node": "^10.12.18",
"@typescript-eslint/eslint-plugin": "^1.9.0",
"@typescript-eslint/parser": "^1.9.0",
"eslint": "5.16.0",
"eslint-config-google": "0.13.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-prettier": "^3.1.0",
"prettier": "^1.18.2",
"typescript": "^3.4.3"
}
My .eslintrc
:
{
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "prettier"],
"extends": ["eslint:recommended", "google", "prettier"],
"parserOptions": {
"ecmaVersion": 2016,
"sourceType": "module"
},
"env": {
"es6": true,
"node": true,
"mocha": true
},
"rules": {
"prettier/prettier": ["error"]
}
}
My .prettierc
:
{
"printWidth": 100,
"singleQuote": true
}
I have installed prettier
and eslint
extensions in VS Code and enabled format on Save.
Considering this code:
'use strict';
describe('some test', () => {
it('should return a string value', (done) => {
return done();
});
});
Neither ESLint nor Prettier are complaining, but when saving the document,
Prettier removes the parentheses around done
also eslint-config-google
defines them as required.
Also, when removing the parentheses around done
, no error is shown, also they're required.
Looks like eslint-config-google
and Prettier are not in sync which is likely my fault.
Whats wrong here?