From 202737a4a74727e03b404828c57dd64272ca80b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87etin?= <69278826+cetincakiroglu@users.noreply.github.com> Date: Mon, 30 Jan 2023 13:38:04 +0300 Subject: [PATCH] Fixed #12577 - Migrate to eslint --- .eslintrc.json | 51 ++++++++++++++++ .npmignore | 2 +- angular.json | 26 ++++----- package.json | 18 +++--- src/tslint.json | 17 ------ tsconfig.json | 3 +- tslint.json | 152 ------------------------------------------------ 7 files changed, 78 insertions(+), 191 deletions(-) create mode 100644 .eslintrc.json delete mode 100755 src/tslint.json delete mode 100755 tslint.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000000..3fb5b57f9d9 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,51 @@ +{ + "root": true, + "ignorePatterns": ["projects/**/*"], + "overrides": [ + { + "files": ["*.ts"], + "parserOptions": { + "project": ["tsconfig.json", "e2e/tsconfig.json"], + "createDefaultProgram": true + }, + "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:@angular-eslint/recommended", "plugin:@angular-eslint/template/process-inline-templates", "prettier"], + "rules": { + "@angular-eslint/component-selector": [ + "error", + { + "type": "element", + "prefix": "p", + "style": "kebab-case" + } + ], + "@angular-eslint/directive-selector": [ + "error", + { + "type": "attribute", + "prefix": "p", + "style": "camelCase" + } + ], + "arrow-body-style": ["error", "as-needed"], + "curly": "error", + "@typescript-eslint/member-ordering": [ + "error", + { + "default": ["public-static-field", "static-field", "instance-field", "public-instance-method", "public-static-field"] + } + ], + "no-console": [ + "error", + { + "allow": ["debug", "info", "time", "timeEnd", "trace"] + } + ] + } + }, + { + "files": ["*.html"], + "extends": ["plugin:@angular-eslint/template/recommended"], + "rules": {} + } + ] +} \ No newline at end of file diff --git a/.npmignore b/.npmignore index 2f77800591b..1012902a769 100644 --- a/.npmignore +++ b/.npmignore @@ -52,7 +52,7 @@ CHANGELOG.md .angular-cli.json angular.json tsconfig*.json -tslint.json +.eslintrc.json gulpfile.js .github package-lock.json diff --git a/angular.json b/angular.json index 07e69ea4212..9bb7d95aa1a 100755 --- a/angular.json +++ b/angular.json @@ -7,11 +7,11 @@ "root": "src", "projectType": "library", "architect": { - "build": { + "build": { "builder": "@angular-devkit/build-angular:ng-packagr", "options": { - "project": "src/app/components/ng-package.json", - "tsConfig": "src/app/components/tsconfig.lib.prod.json" + "project": "src/app/components/ng-package.json", + "tsConfig": "src/app/components/tsconfig.lib.prod.json" } } } @@ -62,7 +62,7 @@ "file-saver", "jspdf", "quill" - ] + ] }, "configurations": { "production": { @@ -143,14 +143,11 @@ } }, "lint": { - "builder": "@angular-devkit/build-angular:tslint", + "builder": "@angular-eslint/builder:lint", "options": { - "tsConfig": [ - "tsconfig.app.json", - "tsconfig.spec.json" - ], - "exclude": [ - "**/node_modules/**" + "lintFilePatterns": [ + "src/**/*.ts", + "src/**/*.html" ] } } @@ -159,6 +156,9 @@ }, "defaultProject": "primeng", "cli": { - "analytics": false + "analytics": false, + "schematicCollections": [ + "@angular-eslint/schematics" + ] } -} + } \ No newline at end of file diff --git a/package.json b/package.json index b2cd13c652f..c30db26d56d 100755 --- a/package.json +++ b/package.json @@ -36,11 +36,11 @@ "@angular/router": "^15.1.0", "@types/jasmine": "~3.10.0", "@types/node": "^12.11.1", - "@fullcalendar/core": "6.0.0-beta.1", - "@fullcalendar/daygrid": "6.0.0-beta.1", - "@fullcalendar/interaction": "6.0.0-beta.1", - "@fullcalendar/timegrid": "6.0.0-beta.1", - "@fullcalendar/web-component": "6.0.0-beta.1", + "@fullcalendar/angular": "^6.0.3", + "@fullcalendar/core": "^6.0.3", + "@fullcalendar/daygrid": "^6.0.3", + "@fullcalendar/interaction": "^6.0.3", + "@fullcalendar/timegrid": "^6.0.3", "chart.js": "3.3.2", "codelyzer": "^6.0.0", "del": "^2.2.0", @@ -69,9 +69,13 @@ "rxjs": "~7.5.0", "ts-node": "~8.3.0", "tslib": "^2.3.0", - "tslint": "~6.1.0", "typescript": "~4.8.4", "xlsx": "^0.15.1", - "zone.js": "~0.11.4" + "zone.js": "~0.11.4", + "eslint": "^8.28.0", + "eslint-config-prettier": "^8.5.0", + "eslint-plugin-import": "latest", + "eslint-plugin-jsdoc": "latest", + "eslint-plugin-prefer-arrow": "latest" } } \ No newline at end of file diff --git a/src/tslint.json b/src/tslint.json deleted file mode 100755 index 52e2c1a5a74..00000000000 --- a/src/tslint.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": "../tslint.json", - "rules": { - "directive-selector": [ - true, - "attribute", - "app", - "camelCase" - ], - "component-selector": [ - true, - "element", - "app", - "kebab-case" - ] - } -} diff --git a/tsconfig.json b/tsconfig.json index e9dfc123da3..1234570003a 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "paths": { "primeng/*": ["src/app/components/*/public_api"] }, - "useDefineForClassFields": false + "useDefineForClassFields": false, + "noFallthroughCasesInSwitch": true } } diff --git a/tslint.json b/tslint.json deleted file mode 100755 index 277c8eba024..00000000000 --- a/tslint.json +++ /dev/null @@ -1,152 +0,0 @@ -{ - "extends": "tslint:recommended", - "rulesDirectory": [ - "codelyzer" - ], - "rules": { - "align": { - "options": [ - "parameters", - "statements" - ] - }, - "array-type": false, - "arrow-return-shorthand": true, - "curly": true, - "deprecation": { - "severity": "warning" - }, - "eofline": true, - "import-blacklist": [ - true, - "rxjs/Rx" - ], - "import-spacing": true, - "indent": { - "options": [ - "spaces" - ] - }, - "max-classes-per-file": false, - "max-line-length": [ - true, - 140 - ], - "member-ordering": [ - true, - { - "order": [ - "static-field", - "instance-field", - "static-method", - "instance-method" - ] - } - ], - "no-console": [ - true, - "debug", - "info", - "time", - "timeEnd", - "trace" - ], - "no-empty": false, - "no-inferrable-types": [ - true, - "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" - ], - "quotemark": [ - true, - "single" - ], - "semicolon": { - "options": [ - "always" - ] - }, - "space-before-function-paren": { - "options": { - "anonymous": "never", - "asyncArrow": "always", - "constructor": "never", - "method": "never", - "named": "never" - } - }, - "typedef": [ - true, - "call-signature" - ], - "typedef-whitespace": { - "options": [ - { - "call-signature": "nospace", - "index-signature": "nospace", - "parameter": "nospace", - "property-declaration": "nospace", - "variable-declaration": "nospace" - }, - { - "call-signature": "onespace", - "index-signature": "onespace", - "parameter": "onespace", - "property-declaration": "onespace", - "variable-declaration": "onespace" - } - ] - }, - "variable-name": { - "options": [ - "ban-keywords", - "check-format", - "allow-pascal-case" - ] - }, - "whitespace": { - "options": [ - "check-branch", - "check-decl", - "check-operator", - "check-separator", - "check-type", - "check-typecast" - ] - }, - "component-class-suffix": true, - "contextual-lifecycle": true, - "directive-class-suffix": true, - "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, - "directive-selector": [ - true, - "attribute", - "app", - "camelCase" - ], - "component-selector": [ - true, - "element", - "app", - "kebab-case" - ] - } -}