diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..b5c6517 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,69 @@ +{ + "root": true, + "ignorePatterns": [ + "projects/**/*" + ], + "overrides": [ + { + "files": [ + "*.ts" + ], + "parserOptions": { + "project": [ + "tsconfig.json", + "e2e/tsconfig.json" + ], + "createDefaultProgram": true + }, + "extends": [ + "plugin:@angular-eslint/ng-cli-compat", + "plugin:@angular-eslint/ng-cli-compat--formatting-add-on", + "plugin:@angular-eslint/template/process-inline-templates" + ], + "rules": { + "@angular-eslint/component-selector": [ + "off", + { + "type": "element", + "prefix": "app", + "style": "kebab-case" + } + ], + "@angular-eslint/directive-selector": [ + "off", + { + "type": "attribute", + "prefix": "app", + "style": "camelCase" + } + ], + "@typescript-eslint/explicit-member-accessibility": [ + "off", + { + "accessibility": "explicit" + } + ], + "@typescript-eslint/no-inferrable-types": [ + "off", + { + "ignoreParameters": true + } + ], + "arrow-parens": [ + "off", + "always" + ], + "import/order": "off" + } + }, + { + "files": [ + "*.html" + ], + "extends": [ + "plugin:@angular-eslint/template/recommended" + ], + "rules": {} + } + ] +} diff --git a/angular.json b/angular.json index ec063a3..667492d 100644 --- a/angular.json +++ b/angular.json @@ -112,15 +112,11 @@ } }, "lint": { - "builder": "@angular-devkit/build-angular:tslint", + "builder": "@angular-eslint/builder:lint", "options": { - "tsConfig": [ - "tsconfig.app.json", - "tsconfig.spec.json", - "e2e/tsconfig.json" - ], - "exclude": [ - "**/node_modules/**" + "lintFilePatterns": [ + "src/**/*.ts", + "src/**/*.html" ] } }, diff --git a/package.json b/package.json index ca5b812..32cd5fe 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,17 @@ "protractor": "^7.0.0", "ts-node": "^9.0.0", "tslint": "^6.1.3", - "typescript": "~4.1.0" + "typescript": "~4.1.0", + "eslint": "^7.6.0", + "eslint-plugin-import": "2.22.1", + "eslint-plugin-jsdoc": "30.7.6", + "eslint-plugin-prefer-arrow": "1.2.2", + "@angular-eslint/builder": "1.2.0", + "@angular-eslint/eslint-plugin": "1.2.0", + "@angular-eslint/eslint-plugin-template": "1.2.0", + "@angular-eslint/schematics": "1.2.0", + "@angular-eslint/template-parser": "1.2.0", + "@typescript-eslint/eslint-plugin": "4.3.0", + "@typescript-eslint/parser": "4.3.0" } } diff --git a/src/app/services/component-state.service.ts b/src/app/services/component-state.service.ts index 74e270e..57878eb 100644 --- a/src/app/services/component-state.service.ts +++ b/src/app/services/component-state.service.ts @@ -39,7 +39,7 @@ export class ComponentStateService { } private dealWithPathChange(path) { - // tslint:disable-next-line:forin + // eslint-disable-next-line guard-for-in for (const visibleKey in this.visible) { this.visible[visibleKey] = true } diff --git a/src/app/utils/dataUtil.ts b/src/app/utils/dataUtil.ts index 185f0ea..98b5657 100644 --- a/src/app/utils/dataUtil.ts +++ b/src/app/utils/dataUtil.ts @@ -12,9 +12,9 @@ export function exist(pageNum: number, pageSize: number, pageList: PageList> = new Observable(o => { o.next(pageList[i]); diff --git a/src/app/utils/svgIconUtil.ts b/src/app/utils/svgIconUtil.ts index 3d17823..e7bc91b 100644 --- a/src/app/utils/svgIconUtil.ts +++ b/src/app/utils/svgIconUtil.ts @@ -3,9 +3,9 @@ export class SvgIconUtil { constructor() { } - // tslint:disable-next-line:max-line-length + // eslint-disable-next-line max-len static readonly nameIcon = ''; - // tslint:disable-next-line:max-line-length + // eslint-disable-next-line max-len static readonly locationIcon = ''; } diff --git a/tslint.json b/tslint.json deleted file mode 100644 index 6858576..0000000 --- a/tslint.json +++ /dev/null @@ -1,93 +0,0 @@ -{ - "extends": "tslint:recommended", - "rules": { - "nz-secondary-entry-imports": true, - "array-type": false, - "arrow-parens": false, - "deprecation": { - "severity": "warning" - }, - "component-class-suffix": true, - "contextual-lifecycle": true, - "directive-class-suffix": true, - "directive-selector": [ - false, - "attribute", - "app", - "camelCase" - ], - "component-selector": [ - false, - "element", - "app", - "kebab-case" - ], - "import-blacklist": [ - true, - "rxjs/Rx" - ], - "interface-name": false, - "max-classes-per-file": false, - "max-line-length": [ - true, - 140 - ], - "member-access": false, - "member-ordering": [ - true, - { - "order": [ - "static-field", - "instance-field", - "static-method", - "instance-method" - ] - } - ], - "no-consecutive-blank-lines": false, - "no-console": [ - true, - "debug", - "info", - "time", - "timeEnd", - "trace" - ], - "no-empty": false, - "no-inferrable-types": [ - false, - "ignore-params" - ], - "no-non-null-assertion": true, - "no-redundant-jsdoc": true, - "no-switch-case-fall-through": true, - "no-var-requires": false, - "object-literal-key-quotes": [ - true, - "as-needed" - ], - "object-literal-sort-keys": false, - "ordered-imports": false, - "quotemark": [ - true, - "single" - ], - "trailing-comma": false, - "no-conflicting-lifecycle": true, - "no-host-metadata-property": true, - "no-input-rename": true, - "no-inputs-metadata-property": true, - "no-output-native": true, - "no-output-on-prefix": true, - "no-output-rename": true, - "no-outputs-metadata-property": true, - "template-banana-in-box": true, - "template-no-negated-async": true, - "use-lifecycle-interface": true, - "use-pipe-transform-interface": true - }, - "rulesDirectory": [ - "codelyzer", - "node_modules/nz-tslint-rules" - ] -}