Skip to content

Commit

Permalink
Merge pull request #529 from kian2attari/bolt-tslint-to-eslint
Browse files Browse the repository at this point in the history
Bolt tslint to eslint
  • Loading branch information
stevengill authored Aug 5, 2020
2 parents be12cd9 + 0fbeb71 commit f8c25ff
Show file tree
Hide file tree
Showing 36 changed files with 937 additions and 685 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
63 changes: 63 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module.exports = {
env: {
es6: true,
node: true,
},
extends: [
'airbnb-typescript/base',
/* TODO: Uncomment rule below once jsdoc comments are added.
This matches the jsdoc rules in the TSLint config */
// "plugin:jsdoc/recommended",
'prettier',
'prettier/@typescript-eslint',
'./eslint-config-base', // the common settings in eslint-config-base
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.eslint.json',
},
plugins: ['@typescript-eslint'],
ignorePatterns: ['**/*.spec.ts', 'src/test-helpers.ts'],
rules: {
/* Below are some of the new 'airbnb-typescript' rules that the project currently does not follow.
They've been disabled here since they raise errors in a few files. The best course
of action is likely to adopt these rules and make the quick (and mostly automated) fixes
needed in the repo to conform to these. ESLint and the airbnb-typecript config is more strict
than the original TSLint configuration that this project had. */
'import/first': ['off'],
'import/prefer-default-export': ['off'],
'max-classes-per-file': ['off', 1],
'import/no-cycle': ['off'],
'@typescript-eslint/no-use-before-define': 'off',
'no-nested-ternary': 'off',
'consistent-return': 'off',
// 'import/order': ['off'],
// 'import/newline-after-import': ['off'],
// 'import/no-useless-path-segments': ['off'],
// '@typescript-eslint/lines-between-class-members': 'off',
// 'no-restricted-globals': 'off',
// 'no-lonely-if': 'off',
// 'no-undef-init': 'off',
// 'no-multi-assign': 'off',
// 'prefer-object-spread': 'off',
// 'no-restricted-syntax': 'off',
// 'prefer-destructuring': 'off',

/* Some currently-enabled additional rules. Uncomment to disable. The project currently conforms to them
so there it's best to just keep these commented or delete them entirely */
// '@typescript-eslint/ban-types': 'off',
// '@typescript-eslint/no-empty-interface': 'off',
// '@typescript-eslint/no-unsafe-assign': 'off',
// '@typescript-eslint/no-explicit-any': 'off',
// '@typescript-eslint/no-unsafe-member-access': 'off',
// '@typescript-eslint/no-unsafe-return': 'off',
// '@typescript-eslint/no-unnecessary-type-assertion': 'off',
// '@typescript-eslint/no-non-null-assertion': 'off',
// '@typescript-eslint/no-unsafe-assignment': 'off',
// '@typescript-eslint/no-unsafe-call': 'off',
// '@typescript-eslint/restrict-template-expressions': 'off',
// '@typescript-eslint/unbound-method': 'off',
// '@typescript-eslint/explicit-module-boundary-types': 'off',
// '@typescript-eslint/require-await': 'off',
},
};
26 changes: 26 additions & 0 deletions .eslintrc.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
extends: [
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'./eslint-config-base',
],
env: {
commonjs: true,
mocha: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.test.json',
},
plugins: ['@typescript-eslint'],
rules: {
/* The rules below currently raise errors. They are easy and mostly automated fixes so conforming to them
would be a good idea. Make sure to remove the rules below if you chose to adopt these rules. */
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'prefer-rest-params': 'off',
'brace-style': 'off',
},
};
13 changes: 13 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 120,
"overrides": [
{
"files": "*.ts",
"options": {
"parser": "typescript"
}
}
]
}
26 changes: 24 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
/*
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
https://github.com/typescript-eslint/tslint-to-eslint-config

It represents the closest reasonable ESLint configuration to this
project's original TSLint configuration.

We recommend eventually switching this configuration to extend from
the recommended rulesets in typescript-eslint.
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md

Happy linting! 💖
*/
{
"editor.rulers": [120],
"typescript.tsdk": "node_modules/typescript/lib"
"editor.rulers": [120],
"typescript.tsdk": "node_modules/typescript/lib",
"editor.formatOnSave": false,
"[javascript]": {
"editor.formatOnSave": true
},
"[typescript]": {
"editor.formatOnSave": true
},
"prettier.configPath": ".prettierrc.json",
"editor.tabSize": 2,
}
71 changes: 71 additions & 0 deletions eslint-config-base/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
module.exports = {
rules: {
// The rules below are ESLint equivalents for the old TSLint rules in tslint.json
// Matches the quotemark rule
'@typescript-eslint/quotes': [
'error',
'single',
{
'avoidEscape': true,
'allowTemplateLiterals': false,
},
],
// matches the variable-name rule
'@typescript-eslint/naming-convention': [
'error',
// custom rule to ignore cases that require quoting
{
'selector': 'variableLike',
'format': ['camelCase', 'UPPER_CASE'],
'leadingUnderscore': 'allow',
'filter': {
// you can expand this regex as you find more cases that require quoting that you want to allow
'regex': '[_ ]',
'match': false,
},
},
],
// matches ban-comma-operator rule
'no-sequences': 'error',
// matches the await-promise rule
'@typescript-eslint/await-thenable': 'error',
// matches interface-over-type-literal rule
'@typescript-eslint/consistent-type-definitions': 'error',
// matches member-access rule
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
'accessibility': 'explicit',
'overrides': {
'constructors': 'no-public',
},
},
],
// matches no-duplicate-switch-case
'no-duplicate-case': 'error',
// matches no-duplicate-variable
'no-redeclare': 'error',
// matches no-require-imports
'@typescript-eslint/no-require-imports': 'error',
// matches no-return-await
'no-return-await': 'error',
// matches no-submodule-imports (slightly different)
// "import/no-internal-modules": "error",
// matches no-this-assignment
'@typescript-eslint/no-this-alias': 'error',
// matches no-unused-expression
'@typescript-eslint/no-unused-expressions': 'error',
// matches no-var-requires
'@typescript-eslint/no-var-requires': 'error',
// sorta matches one-line (Prettier takes care of this)
'brace-style': ['error', '1tbs'],
// matches strict-boolean-expressions
'@typescript-eslint/strict-boolean-expressions': 'error',
// matches typedef
// REVIEW: This raised errors in a couple of the files. To view these errors, its value from 'off' to 'error'
'@typescript-eslint/explicit-function-return-type': 'off',
// matches typedef-whitespace
'@typescript-eslint/type-annotation-spacing': 'error',
// max-line-length is matched by Prettier
},
};
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"prepare": "npm run build",
"build": "tsc",
"build:clean": "shx rm -rf ./dist ./coverage ./.nyc_output",
"lint": "tslint --project .",
"test-lint": "tslint --project tsconfig.test.json \"src/**/*.spec.ts\" && tslint --project tsconfig.test.json \"src/test-helpers.ts\"",
"lint": "prettier 'src/**/*.ts' --check && eslint --ext .ts src",
"test-lint": "prettier 'src/**/*.spec.ts' --check && prettier 'src/test-helpers.ts' --check && eslint --no-eslintrc -c .eslintrc.test.js \"src/**/*.spec.ts\" --fix && eslint --no-eslintrc -c .eslintrc.test.js \"src/test-helpers.ts\"",
"mocha": "TS_NODE_PROJECT=tsconfig.test.json nyc mocha --config .mocharc.json \"src/**/*.spec.ts\"",
"test": "npm run lint && npm run test-lint && npm run mocha && npm run test:types",
"test:types": "tsd",
Expand Down Expand Up @@ -59,17 +59,24 @@
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.6",
"@types/sinon": "^7.0.11",
"@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.4.0",
"chai": "^4.2.0",
"codecov": "^3.2.0",
"eslint": "^7.3.1",
"eslint-config-airbnb-typescript": "^8.0.2",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsdoc": "^28.5.1",
"mocha": "^6.1.4",
"nyc": "^14.0.0",
"prettier": "^2.0.5",
"rewiremock": "^3.13.4",
"shx": "^0.3.2",
"sinon": "^7.3.1",
"source-map-support": "^0.5.12",
"ts-node": "^8.1.0",
"tsd": "^0.13.1",
"tslint": "^5.15.0",
"tslint-config-airbnb": "^5.11.1",
"typescript": "^3.7.2"
},
Expand Down
Loading

0 comments on commit f8c25ff

Please sign in to comment.