eslint-config-angular-strict 22.6.0 โ 22.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/index.js +27 -3
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -37,8 +37,10 @@ A production-ready, opinionated ESLint configuration that enforces best practice
|
|
|
37
37
|
- ๐ฆ [**Import-X**](https://github.com/un-ts/eslint-plugin-import-x) - Import/export validation and cycle detection
|
|
38
38
|
- ๐
[**Perfectionist**](https://github.com/azat-io/eslint-plugin-perfectionist) - Take Your Code to a Beauty Salon
|
|
39
39
|
- ๐จ [**Stylistic**](https://github.com/eslint-stylistic/eslint-stylistic) - Code formatting rules
|
|
40
|
+
- ๐งพ [**TOML**](https://github.com/ota-meshi/eslint-plugin-toml) - TOML files parsing and linting
|
|
40
41
|
- ๐ [**TypeScript ESLint**](https://github.com/typescript-eslint/typescript-eslint) - TypeScript linting
|
|
41
42
|
- ๐ฆ [**Unicorn**](https://github.com/sindresorhus/eslint-plugin-unicorn) - More than 100 powerful ESLint rules
|
|
43
|
+
- ๐ [**YAML**](https://github.com/ota-meshi/eslint-plugin-yml) - YAML files parsing and linting
|
|
42
44
|
|
|
43
45
|
## Installation
|
|
44
46
|
|
|
@@ -74,6 +76,22 @@ Add the following to your `package.json`:
|
|
|
74
76
|
}
|
|
75
77
|
```
|
|
76
78
|
|
|
79
|
+
### 4. Lint YAML and TOML files (optional)
|
|
80
|
+
|
|
81
|
+
YAML and TOML files are checked against the `standard` preset of their plugin and the Unicorn rules recommended for them, but `ng lint` only looks at the patterns declared in `angular.json`. Add them there:
|
|
82
|
+
|
|
83
|
+
```jsonc
|
|
84
|
+
{
|
|
85
|
+
// ...
|
|
86
|
+
"lint": {
|
|
87
|
+
"builder": "@angular-eslint/builder:lint",
|
|
88
|
+
"options": {
|
|
89
|
+
"lintFilePatterns": ["src/**/*.ts", "src/**/*.html", "**/*.toml", "**/*.yaml", "**/*.yml"],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
77
95
|
## TypeScript Configuration
|
|
78
96
|
|
|
79
97
|
Make sure your `tsconfig.json` is properly configured:
|
package/index.js
CHANGED
|
@@ -5,18 +5,26 @@ import angularTemplatePlugin from '@angular-eslint/eslint-plugin-template';
|
|
|
5
5
|
import importXPlugin from 'eslint-plugin-import-x';
|
|
6
6
|
import perfectionistPlugin from 'eslint-plugin-perfectionist';
|
|
7
7
|
import stylistic from '@stylistic/eslint-plugin';
|
|
8
|
+
import tomlPlugin from 'eslint-plugin-toml';
|
|
8
9
|
import tsEslintParser from '@typescript-eslint/parser';
|
|
9
10
|
import tsEslintPlugin from '@typescript-eslint/eslint-plugin';
|
|
10
11
|
import unicornPlugin from 'eslint-plugin-unicorn';
|
|
12
|
+
import ymlPlugin from 'eslint-plugin-yml';
|
|
11
13
|
|
|
12
14
|
import { noRestrictedSyntaxOverrides, noRestrictedSyntaxRule } from './rules/file-conventions.js';
|
|
13
15
|
|
|
14
16
|
// @angular-eslint v22 dropped the `configs` export โ manually enable all rules instead
|
|
15
17
|
const enableAllRules = (plugin, prefix) => Object.fromEntries(Object.keys(plugin.rules).map(k => [`${prefix}/${k}`, 'error']));
|
|
16
18
|
|
|
19
|
+
// The language plugins ship their presets as arrays whose rules carry no `files` โ merge them so they stay scoped to our own blocks
|
|
20
|
+
const presetRules = preset => Object.assign({}, ...preset.map(config => config.rules));
|
|
21
|
+
|
|
22
|
+
const dataFiles = ['**/*.toml', '**/*.yaml', '**/*.yml']; // Data files get their own language blocks below: the JavaScript presets must not reach them
|
|
23
|
+
|
|
17
24
|
export default [
|
|
25
|
+
{ ignores: ['dist/**', 'node_modules/**'] }, // Alone in its object, `ignores` is global: mixed with other keys it only applies to that block
|
|
26
|
+
|
|
18
27
|
{
|
|
19
|
-
ignores: ['dist/**', 'node_modules/**'],
|
|
20
28
|
plugins: {
|
|
21
29
|
'@angular-eslint/template': angularTemplatePlugin,
|
|
22
30
|
'@stylistic': stylistic,
|
|
@@ -27,10 +35,10 @@ export default [
|
|
|
27
35
|
},
|
|
28
36
|
|
|
29
37
|
...configs.base.all,
|
|
30
|
-
perfectionistPlugin.configs['recommended-natural'],
|
|
38
|
+
{ ...perfectionistPlugin.configs['recommended-natural'], ignores: dataFiles },
|
|
31
39
|
rules.base.importsStrict,
|
|
32
40
|
rules.typescript.typescriptEslintStrict,
|
|
33
|
-
{ ...unicornPlugin.configs.all, ignores: ['**/*.html'] }, // not built for Angular templates: nothing
|
|
41
|
+
{ ...unicornPlugin.configs.all, ignores: ['**/*.html', ...dataFiles] }, // Unicorn is not built for Angular templates: nothing to report, and several rules crash
|
|
34
42
|
|
|
35
43
|
// TypeScript files configuration
|
|
36
44
|
{
|
|
@@ -337,5 +345,21 @@ export default [
|
|
|
337
345
|
},
|
|
338
346
|
},
|
|
339
347
|
|
|
348
|
+
// TOML files configuration
|
|
349
|
+
{
|
|
350
|
+
files: ['**/*.toml'],
|
|
351
|
+
language: 'toml/toml',
|
|
352
|
+
plugins: { toml: tomlPlugin, unicorn: unicornPlugin },
|
|
353
|
+
rules: { ...presetRules(tomlPlugin.configs['flat/standard']), ...unicornPlugin.configs['recommended-toml'].rules },
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
// YAML files configuration
|
|
357
|
+
{
|
|
358
|
+
files: ['**/*.yaml', '**/*.yml'],
|
|
359
|
+
language: 'yml/yaml',
|
|
360
|
+
plugins: { unicorn: unicornPlugin, yml: ymlPlugin },
|
|
361
|
+
rules: { ...presetRules(ymlPlugin.configs['flat/standard']), ...unicornPlugin.configs['recommended-yaml'].rules },
|
|
362
|
+
},
|
|
363
|
+
|
|
340
364
|
...noRestrictedSyntaxOverrides,
|
|
341
365
|
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-angular-strict",
|
|
3
|
-
"version": "22.6.
|
|
3
|
+
"version": "22.6.2",
|
|
4
4
|
"description": "Modern ESLint configuration with strict rules for Angular development.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -46,7 +46,9 @@
|
|
|
46
46
|
"eslint-config-airbnb-extended": "3.3.0",
|
|
47
47
|
"eslint-plugin-import-x": "4.17.1",
|
|
48
48
|
"eslint-plugin-perfectionist": "5.12.1",
|
|
49
|
-
"eslint-plugin-
|
|
49
|
+
"eslint-plugin-toml": "1.5.0",
|
|
50
|
+
"eslint-plugin-unicorn": "77.0.0",
|
|
51
|
+
"eslint-plugin-yml": "3.9.0"
|
|
50
52
|
},
|
|
51
53
|
"devDependencies": {
|
|
52
54
|
"typescript": "6.0.3"
|