Skip to content

Commit

Permalink
✨ feat(eslint-config): 初始化并更新ESLint配置
Browse files Browse the repository at this point in the history
- 添加了ESLint的配置文件eslint.config.js,针对TypeScript和HTML文件进行了规则定义。
- 更新了angular.json中的相关配置,指定了新的ESLint配置文件路径。
- 引入了typescript-eslint库,以支持TypeScript的ESLint检查。
- 配置中强调了代码风格的一致性,如属性选择器的命名规则等。
- 此外,还整理和格式化了.prettierrc.json文件,进一步规范了代码样式。

通过这次配置的更新,项目将具备更严格的代码检查和更统一的代码风格。
  • Loading branch information
vnobo committed Jun 25, 2024
1 parent 1ada4df commit bf17edd
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
11 changes: 11 additions & 0 deletions ui/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"semi": true,
"bracketSpacing": true,
"arrowParens": "avoid",
"trailingComma": "es5",
"bracketSameLine": true,
"printWidth": 80
}
6 changes: 3 additions & 3 deletions ui/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions ui/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default [
{
rules: {
semi: 'error',
'prefer-const': 'error',
},
},
];
32 changes: 32 additions & 0 deletions ui/projects/web/eslint.config.js
Original file line number Diff line number Diff line change
@@ -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: {},
}
);

0 comments on commit bf17edd

Please sign in to comment.