Skip to content

Commit

Permalink
migrate from TSLint to ESLint + Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
tinovyatkin committed Aug 18, 2019
1 parent 12a4d36 commit fa9c859
Show file tree
Hide file tree
Showing 7 changed files with 838 additions and 143 deletions.
122 changes: 71 additions & 51 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,53 +1,73 @@
{
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier",
"prettier/@typescript-eslint"
],
"rules": {
// "linebreak-style": ["error", "windows"],
"@typescript-eslint/require-await": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-explicit-any": "off"
},
"overrides": [
{
"files": [
"**/__tests__/**",
"**/__integration_tests__/**",
"**/*.test.ts"
],
"env": {
"jest": true
},
"rules": {
// relaxed settings for tests - any test is better than no test!
"no-useless-catch": "warn",
"@typescript-eslint/prefer-includes": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/prefer-regexp-exec": "warn",
"@typescript-eslint/no-inferrable-types": "warn",
"require-atomic-updates": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-use-before-define": "off"
}
}
]
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json",
"sourceType": "module"
},
"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
// "plugin:prettier/recommended", // need to be uncommented on full run
"prettier/@typescript-eslint"
],
"rules": {
// Following line need to be uncommented before full run in separated PR
// "linebreak-style": ["error", "windows"],
"@typescript-eslint/require-await": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-explicit-any": "off",
// ---------- tslint.json rules -------------
// not enforced by abode presets
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/unified-signatures": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
// were switched off in TSLint config
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"overrides": {
"constructors": "off"
}
}
],
"@typescript-eslint/array-type": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/member-ordering": "off",
// existing errors lowered to warn - NEED TO REFACTOR later
"no-prototype-builtins": "warn",
"@typescript-eslint/no-inferrable-types": "warn"
},
"overrides": [
{
"files": ["**/__tests__/**", "**/__integration_tests__/**", "**/*.test.ts"],
"env": {
"jest": true
},
"rules": {
// relaxed settings for tests - any test is better than no test!
"no-useless-catch": "warn",
"no-useless-escape": "warn",
"@typescript-eslint/prefer-includes": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/prefer-regexp-exec": "warn",
"@typescript-eslint/no-inferrable-types": "warn",
"@typescript-eslint/array-type": "warn",
"require-atomic-updates": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-use-before-define": "off"
}
}
]
}
27 changes: 27 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"printWidth": 100,
"endOfLine": "crlf",
"trailingComma": "es5",
"singleQuote": true,
"semi": true,
"useTabs": true,
"tabWidth": 1,
"arrowParens": "always",
"overrides": [
{
"files": ["*.yml", "*.sh", "*.json"],
"options": {
"singleQuote": false,
"useTabs": false,
"endOfLine": "lf",
"tabWidth": 2
}
},
{
"files": ["package.json", "package-lock.json"],
"options": {
"parser": "json-stringify"
}
}
]
}
5 changes: 4 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
// for the documentation about the extensions.json format
"recommendations": [
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// Editor config to enforce our TAB and CRLF
"EditorConfig.editorconfig",
// We use Jest for test and this extension allows easy debugging
"Orta.vscode-jest"
"Orta.vscode-jest",
// We use ESLint for code linting
"dbaeumer.vscode-eslint"
]
}
48 changes: 27 additions & 21 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
{
"files.eol": "\r\n",
"editor.insertSpaces": false,
// prevent Jest extension to run automatically on our integration tests
"jest.autoEnable": false,
"jest.runAllTestsFirst": false,
"jest.debugCodeLens.showWhenTestStateIn": ["pass", "fail", "unknown"],
"[json]": {
"files.eol": "\n",
"editor.insertSpaces": true,
"editor.tabSize": 2
},
"[yaml]": {
"files.eol": "\n",
"editor.insertSpaces": true,
"editor.tabSize": 2
},
"[shellscript]": {
"files.eol": "\n",
"editor.insertSpaces": true,
"editor.tabSize": 2
}
"files.eol": "\r\n",
"editor.insertSpaces": false,
"[json]": {
"files.eol": "\n",
"editor.insertSpaces": true,
"editor.tabSize": 2
},
"[yaml]": {
"files.eol": "\n",
"editor.insertSpaces": true,
"editor.tabSize": 2
},
"[shellscript]": {
"files.eol": "\n",
"editor.insertSpaces": true,
"editor.tabSize": 2
},
// prevent Jest extension to run automatically on our integration tests
"jest.autoEnable": false,
"jest.runAllTestsFirst": false,
"jest.debugCodeLens.showWhenTestStateIn": ["pass", "fail", "unknown"],
// ESlint Options
"eslint.autoFixOnSave": true,
"eslint.run": "onType",
"eslint.validate": ["javascript", "typescript"],
// we run prettier from ESLint, so, disable it from separated extension
"prettier.disableLanguages": ["typescript"]
}
Loading

0 comments on commit fa9c859

Please sign in to comment.