eslint-config-angular-strict 22.6.0 โ 22.6.1
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 +36 -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 for syntax errors and every Unicorn rule that supports 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,29 @@ 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
|
+
// Unicorn has no `all` preset per language โ enable every maintained rule that declares support for it
|
|
20
|
+
const enableUnicornRules = (language) => {
|
|
21
|
+
const isSupported = rule => !rule.meta.deprecated && (rule.meta.languages || []).some(supported => supported === '*' || supported === language);
|
|
22
|
+
return Object.fromEntries(Object.entries(unicornPlugin.rules).filter(([, rule]) => isSupported(rule)).map(([name]) => [`unicorn/${name}`, 'error']));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const dataFiles = ['**/*.toml', '**/*.yaml', '**/*.yml']; // Data files get their own language blocks below: the JavaScript presets must not reach them
|
|
26
|
+
|
|
17
27
|
export default [
|
|
28
|
+
{ ignores: ['dist/**', 'node_modules/**'] }, // Alone in its object, `ignores` is global: mixed with other keys it only applies to that block
|
|
29
|
+
|
|
18
30
|
{
|
|
19
|
-
ignores: ['dist/**', 'node_modules/**'],
|
|
20
31
|
plugins: {
|
|
21
32
|
'@angular-eslint/template': angularTemplatePlugin,
|
|
22
33
|
'@stylistic': stylistic,
|
|
@@ -27,10 +38,10 @@ export default [
|
|
|
27
38
|
},
|
|
28
39
|
|
|
29
40
|
...configs.base.all,
|
|
30
|
-
perfectionistPlugin.configs['recommended-natural'],
|
|
41
|
+
{ ...perfectionistPlugin.configs['recommended-natural'], ignores: dataFiles },
|
|
31
42
|
rules.base.importsStrict,
|
|
32
43
|
rules.typescript.typescriptEslintStrict,
|
|
33
|
-
{ ...unicornPlugin.configs.all, ignores: ['**/*.html'] }, // not built for Angular templates: nothing
|
|
44
|
+
{ ...unicornPlugin.configs.all, ignores: ['**/*.html', ...dataFiles] }, // Unicorn is not built for Angular templates: nothing to report, and several rules crash
|
|
34
45
|
|
|
35
46
|
// TypeScript files configuration
|
|
36
47
|
{
|
|
@@ -337,5 +348,27 @@ export default [
|
|
|
337
348
|
},
|
|
338
349
|
},
|
|
339
350
|
|
|
351
|
+
// TOML files configuration
|
|
352
|
+
{
|
|
353
|
+
files: ['**/*.toml'],
|
|
354
|
+
language: 'toml/toml',
|
|
355
|
+
plugins: { toml: tomlPlugin, unicorn: unicornPlugin },
|
|
356
|
+
rules: {
|
|
357
|
+
...enableUnicornRules('toml/toml'),
|
|
358
|
+
'unicorn/key-name-casing': 'off', // keys are dictated by the tool that reads the file (Ruff, Yarn...)
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
|
|
362
|
+
// YAML files configuration
|
|
363
|
+
{
|
|
364
|
+
files: ['**/*.yaml', '**/*.yml'],
|
|
365
|
+
language: 'yml/yaml',
|
|
366
|
+
plugins: { unicorn: unicornPlugin, yml: ymlPlugin },
|
|
367
|
+
rules: {
|
|
368
|
+
...enableUnicornRules('yml/yaml'),
|
|
369
|
+
'unicorn/key-name-casing': 'off', // keys are dictated by the tool that reads the file (Dependabot, GitHub Actions...)
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
|
|
340
373
|
...noRestrictedSyntaxOverrides,
|
|
341
374
|
];
|
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.1",
|
|
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"
|