eslint-config-angular-strict 22.3.12 โ 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 -11
- package/package.json +8 -6
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,
|
|
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
|
{
|
|
@@ -43,6 +54,7 @@ export default [
|
|
|
43
54
|
'@angular-eslint/component-class-suffix': ['error', { suffixes: ['App', 'Component', 'Drawer', 'Modal', 'Page'] }],
|
|
44
55
|
'@angular-eslint/component-selector': 'off',
|
|
45
56
|
'@angular-eslint/prefer-on-push-component-change-detection': 'off',
|
|
57
|
+
'@angular-eslint/prefer-standalone': ['error', { allowExplicitStandalone: false }], // standalone is the default, an explicit `true` is noise
|
|
46
58
|
'@angular-eslint/use-component-selector': 'off',
|
|
47
59
|
|
|
48
60
|
// ESLint rules
|
|
@@ -333,15 +345,28 @@ export default [
|
|
|
333
345
|
'@angular-eslint/template/no-call-expression': 'off',
|
|
334
346
|
'@angular-eslint/template/no-inline-styles': 'off',
|
|
335
347
|
'@angular-eslint/template/prefer-ngsrc': 'off',
|
|
348
|
+
},
|
|
349
|
+
},
|
|
336
350
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
'
|
|
344
|
-
'unicorn/
|
|
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...)
|
|
345
370
|
},
|
|
346
371
|
},
|
|
347
372
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-angular-strict",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.6.1",
|
|
4
4
|
"description": "Modern ESLint configuration with strict rules for Angular development.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"test": "node scripts/check-rule-names.js && cd tests && yarn install && eslint . --format=stylish"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@angular-eslint/builder": "22.
|
|
39
|
-
"@angular-eslint/eslint-plugin": "22.
|
|
40
|
-
"@angular-eslint/eslint-plugin-template": "22.
|
|
41
|
-
"@angular-eslint/template-parser": "22.
|
|
38
|
+
"@angular-eslint/builder": "22.6.0",
|
|
39
|
+
"@angular-eslint/eslint-plugin": "22.6.0",
|
|
40
|
+
"@angular-eslint/eslint-plugin-template": "22.6.0",
|
|
41
|
+
"@angular-eslint/template-parser": "22.6.0",
|
|
42
42
|
"@stylistic/eslint-plugin": "5.10.0",
|
|
43
43
|
"@typescript-eslint/eslint-plugin": "8.71.1",
|
|
44
44
|
"@typescript-eslint/parser": "8.71.1",
|
|
@@ -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"
|