From bf17edd969fc19386ff5111738b14f832cc29e2e Mon Sep 17 00:00:00 2001 From: AlexBob <5199840@qq.com> Date: Tue, 25 Jun 2024 14:28:04 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(eslint-config):=20=E5=88=9D?= =?UTF-8?q?=E5=A7=8B=E5=8C=96=E5=B9=B6=E6=9B=B4=E6=96=B0ESLint=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加了ESLint的配置文件eslint.config.js,针对TypeScript和HTML文件进行了规则定义。 - 更新了angular.json中的相关配置,指定了新的ESLint配置文件路径。 - 引入了typescript-eslint库,以支持TypeScript的ESLint检查。 - 配置中强调了代码风格的一致性,如属性选择器的命名规则等。 - 此外,还整理和格式化了.prettierrc.json文件,进一步规范了代码样式。 通过这次配置的更新,项目将具备更严格的代码检查和更统一的代码风格。 --- ui/.prettierrc.json | 11 +++++++++++ ui/angular.json | 6 +++--- ui/eslint.config.js | 8 ++++++++ ui/projects/web/eslint.config.js | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 ui/.prettierrc.json create mode 100644 ui/eslint.config.js create mode 100644 ui/projects/web/eslint.config.js diff --git a/ui/.prettierrc.json b/ui/.prettierrc.json new file mode 100644 index 00000000..dd2d87ba --- /dev/null +++ b/ui/.prettierrc.json @@ -0,0 +1,11 @@ +{ + "tabWidth": 2, + "useTabs": false, + "singleQuote": true, + "semi": true, + "bracketSpacing": true, + "arrowParens": "avoid", + "trailingComma": "es5", + "bracketSameLine": true, + "printWidth": 80 +} diff --git a/ui/angular.json b/ui/angular.json index 76f2fe22..f91f7501 100644 --- a/ui/angular.json +++ b/ui/angular.json @@ -161,10 +161,10 @@ "builder": "@angular-eslint/builder:lint", "options": { "lintFilePatterns": [ - "projects/app/**/*.ts", - "projects/app/**/*.html" + "projects/web/**/*.ts", + "projects/web/**/*.html" ], - "eslintConfig": "projects/app/eslint.config.js" + "eslintConfig": "projects/web/eslint.config.js" } } } diff --git a/ui/eslint.config.js b/ui/eslint.config.js new file mode 100644 index 00000000..28266920 --- /dev/null +++ b/ui/eslint.config.js @@ -0,0 +1,8 @@ +export default [ + { + rules: { + semi: 'error', + 'prefer-const': 'error', + }, + }, +]; diff --git a/ui/projects/web/eslint.config.js b/ui/projects/web/eslint.config.js new file mode 100644 index 00000000..f87d3695 --- /dev/null +++ b/ui/projects/web/eslint.config.js @@ -0,0 +1,32 @@ +// @ts-check +const tseslint = require('typescript-eslint'); +const rootConfig = require('../../eslint.config.js'); + +module.exports = tseslint.config( + ...rootConfig, + { + files: ['**/*.ts'], + rules: { + '@angular-eslint/directive-selector': [ + 'error', + { + type: 'attribute', + prefix: 'app', + style: 'camelCase', + }, + ], + '@angular-eslint/component-selector': [ + 'error', + { + type: 'element', + prefix: 'app', + style: 'kebab-case', + }, + ], + }, + }, + { + files: ['**/*.html'], + rules: {}, + } +);