Skip to content

Commit

Permalink
feat(compliance-web): Migrate project from tslint to eslint (#387)
Browse files Browse the repository at this point in the history
* feat(compliance-web): Migrate project from tslint to eslint

- Add .eslintrc.js
- remove tsling.config.json
- Disable failing rules (to keep PR small and to be fixed later)
- Add recommended plugins for vscode
- Remove some excluded files from tsconfig.json because eslint throws an error if the files are not included (we can change this to exclude them from scanning altogether if we want, but it seems good to scan them if possible)

Note: Security rules will be fixed in an upcoming PR.

* Chore: Re-add test files to the exclude list in tsconfig.json

The previous change caused yarn build to fail because it was picking up the contents of src/test-resources/generator/, which it's not supposed to do; that directory is a tool for generating new test resources, has its own separate package.json, and is intended to be built separately

The addition of tsconfig.eslint.json allows test files to be included in the eslint scan, but remain excluded for the build.
  • Loading branch information
RobGallo authored Sep 2, 2020
1 parent 28b16ce commit 59a1500
Show file tree
Hide file tree
Showing 6 changed files with 473 additions and 90 deletions.
52 changes: 52 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
module.exports = {
env: {
es2017: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:security/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module', // Allows for the use of imports
project: './tsconfig.eslint.json',
ecmaFeatures: {},
ecmaVersion: 8,
},
plugins: ['@typescript-eslint', 'security'],
settings: {},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-unnecessary-type-assertion': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'security/detect-object-injection': 'off',
'security/detect-non-literal-fs-filename': 'off',
'no-var': 'off',
'prefer-const': 'off',
},
overrides: [
{
files: ['src/tests/**/*'],
rules: {
// Disable those errors and warnings which are not a threat to test code because the code is not run in production environments
},
},
],
};
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
{
"recommendations": [
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"psioniq.psi-header"
]
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"@types/lodash": "^4.14.136",
"@types/node": "^14.0.1",
"@types/yargs": "^15.0.0",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"eslint": "^7.8.1",
"eslint-plugin-security": "^1.4.0",
"jest": "^26.0.1",
"jest-circus": "^26.0.0",
"jest-junit": "^11.0.1",
Expand All @@ -32,8 +36,6 @@
"rimraf": "^3.0.0",
"semantic-release": "^17.0.1",
"ts-jest": "^26.0.0",
"tslint": "^6.0.0",
"tslint-microsoft-contrib": "^6.2.0",
"typemoq": "^2.1.0",
"typescript": "^4.0.2"
},
Expand All @@ -47,7 +49,7 @@
"build": "tsc -p .",
"clean": "rimraf dist/* test-results/*",
"test": "jest",
"lint": "tslint -p .",
"lint": "eslint src/**/*.{js,ts,tsx}",
"format": "prettier --config prettier.config.js --write \"**/*\"",
"format-check": "prettier --config prettier.config.js --check \"**/*\"",
"copyrightheaders": "license-check-and-add check -f copyright-header.config.json",
Expand Down
4 changes: 4 additions & 0 deletions tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules"]
}
23 changes: 0 additions & 23 deletions tslint.json

This file was deleted.

Loading

0 comments on commit 59a1500

Please sign in to comment.