Skip to content

Commit

Permalink
replace tslint with eslint
Browse files Browse the repository at this point in the history
Convert most tslint rules to eslint, changed most inline comments in the
sources as well. Some tslint rules still work, hence why you will be
able to see `// tslint` comments.

Unfortunately, there is an outstanding issue regarding eslint
performance on large typescript monorepos, so we should fallback to
linting all packages individually until this is fixed.

Signed-off-by: Paul Maréchal <paul.marechal@ericsson.com>
  • Loading branch information
paul-marechal committed Jan 17, 2020
1 parent 4bfe7e5 commit 05ad6de
Show file tree
Hide file tree
Showing 462 changed files with 2,298 additions and 1,249 deletions.
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
root: true,
extends: [
'./configs/base.eslintrc.json',
'./configs/warnings.eslintrc.json',
'./configs/errors.eslintrc.json'
],
parserOptions: {
tsconfigRootDir: __dirname,
project: [
'tsconfig.json',
'dev-packages/*/tsconfig.json',
'packages/*/tsconfig.json',
'examples/*/tsconfig.json'
]
}
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ gh-pages
.vscode/ipch
dev-packages/electron/compile_commands.json
*.tsbuildinfo
.eslintcache
54 changes: 23 additions & 31 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
// If one would like to add/remove/modify user preferences without modifying the content of the
// workspace settings file, then one would need to modify the `settings.json` under here:
// - Windows: %APPDATA%\Code\User\settings.json
// - Linux: $HOME/.config/Code/User/settings.json
// - Mac: $HOME/Library/Application Support/Code/User/settings.json
{
"tslint.enable": true,
"typescript.tsdk": "node_modules/typescript/lib",
"editor.formatOnSave": true,
"search.exclude": {
"**/node_modules": true,
"**/lib": true,
"**/coverage": true
"editor.insertSpaces": true,
"files.insertFinalNewline": true,
"clang-format.language.typescript.enable": false,
"editor.rulers": [
180
], // ESLint `max-len` rule.
"[typescript]": {
"editor.tabSize": 4,
"editor.defaultFormatter": "vscode.typescript-language-features",
},
"[javascript]": {
"editor.tabSize": 4,
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[json]": {
"editor.tabSize": 2,
"editor.defaultFormatter": "vscode.json-language-features",
},
"[jsonc]": {
"editor.tabSize": 2,
"editor.defaultFormatter": "vscode.json-language-features",
},
"lcov.path": [
"packages/core/coverage/lcov.info",
Expand All @@ -34,25 +46,5 @@
"pattern": "**/*.spec.ts",
"command": "yarn test:theia"
}
],
"editor.insertSpaces": true,
"[typescript]": {
"editor.tabSize": 4,
"editor.defaultFormatter": "vscode.typescript-language-features",
},
"[javascript]": {
"editor.tabSize": 4,
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[json]": {
"editor.tabSize": 2,
"editor.defaultFormatter": "vscode.json-language-features",
},
"[jsonc]": {
"editor.tabSize": 2,
"editor.defaultFormatter": "vscode.json-language-features",
},
"typescript.tsdk": "node_modules/typescript/lib",
"files.insertFinalNewline": true,
"clang-format.language.typescript.enable": false
]
}
25 changes: 25 additions & 0 deletions configs/base.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 6,
"ecmaFeatures": {
"jsx": true
}
},
"plugins": [
"@typescript-eslint",
"@typescript-eslint/tslint",
"import",
"no-null"
],
"env": {
"browser": true,
"mocha": true,
"node": true
},
"ignorePatterns": [
"node_modules",
"*.d.ts"
]
}
6 changes: 6 additions & 0 deletions configs/build.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": [
"./base.eslintrc.json",
"./errors.eslintrc.json"
]
}
8 changes: 0 additions & 8 deletions configs/build.tslint.json

This file was deleted.

123 changes: 123 additions & 0 deletions configs/errors.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"rules": {
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/indent": "off", // temp
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/quotes": [
"error",
"single",
{
"avoidEscape": true
}
],
"@typescript-eslint/semi": [
"error",
"always"
],
"@typescript-eslint/type-annotation-spacing": "error",
"arrow-body-style": [
"error",
"as-needed"
],
"arrow-parens": [
"error",
"as-needed"
],
"camelcase": "off",
"comma-dangle": "off",
"curly": "error",
"eol-last": "error",
"eqeqeq": [
"error",
"smart"
],
"guard-for-in": "error",
"id-blacklist": "off",
"id-match": "off",
"import/no-deprecated": "error",
"import/no-extraneous-dependencies": "off",
"max-len": [
"error",
{
"code": 180
}
],
"no-magic-numbers": "off",
"no-multiple-empty-lines": "error",
"no-new-wrappers": "error",
"no-null/no-null": "error",
"no-shadow": [
"error",
{
"hoist": "all"
}
],
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-underscore-dangle": "off",
"no-unused-expressions": "error",
"no-var": "error",
"no-void": "off", // @theia/plugin-ext uses this?
"one-var": [
"error",
"never"
],
"prefer-const": [
"error",
{
"destructuring": "all"
}
],
"radix": "off",
"space-before-function-paren": [
"error",
{
"anonymous": "always",
"named": "never",
"asyncArrow": "always"
}
],
"spaced-comment": [
"error",
"always",
{
"exceptions": ["*", "+", "-", "/"]
}
],
"@typescript-eslint/tslint/config": [
"error", {
"rules": {
"file-header": [
true,
"SPDX-License-Identifier: EPL-2\\.0 OR GPL-2\\.0 WITH Classpath-exception-2\\.0"
],
"jsdoc-format": [
true,
"check-multiline-start"
],
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"typedef": [
true,
"call-signature",
"property-declaration"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
]
}
}
]
}
}
Loading

0 comments on commit 05ad6de

Please sign in to comment.