|
1 |
| -module.exports = { |
2 |
| - extends: [ |
3 |
| - 'plugin:@angular-eslint/recommended', |
4 |
| - 'plugin:@angular-eslint/template/process-inline-templates', |
5 |
| - '@ni/eslint-config-typescript' |
6 |
| - ], |
7 |
| - rules: { |
8 |
| - /* |
9 |
| - Overrides to Angular recommended rules: |
10 |
| - https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin/src/configs/recommended.json |
11 |
| - */ |
12 |
| - |
13 |
| - '@angular-eslint/no-host-metadata-property': 'error', |
14 |
| - |
15 |
| - /* |
16 |
| - '@angular-eslint/no-input-rename' rule notes: |
17 |
| - Disallow renaming directive inputs generally. Use an inline comment to disable the rule for exceptions where the |
18 |
| - context changes significantly, or disable the rule for files of directives that need to prefix their inputs to avoid conflicts. |
19 |
| - */ |
20 |
| - |
21 |
| - /* |
22 |
| - '@angular-eslint/no-output-rename' rule notes: |
23 |
| - Disallow renaming directive outputs generally. Use an inline comment to disable the rule for exceptions where the |
24 |
| - context changes significantly, or disable the rule for projects that use the dollar sign postfix for EventEmitters. |
25 |
| - */ |
26 |
| - |
27 |
| - /* |
28 |
| - Upgrade the recommended rule configuration from a warning to an error. |
29 |
| - */ |
30 |
| - '@angular-eslint/use-lifecycle-interface': 'error', |
31 |
| - |
32 |
| - // We intended to use the default from @typescript-eslint/recommended, but we adopted this override accidentally. |
33 |
| - // See https://github.com/ni/javascript-styleguide/issues/139 |
34 |
| - '@typescript-eslint/no-inferrable-types': [ |
35 |
| - 'error', |
36 |
| - { ignoreParameters: true } |
37 |
| - ], |
38 |
| - |
39 |
| - /* |
40 |
| - Overrides to Angular rules outside of the recommended configuration: |
41 |
| - */ |
42 |
| - |
43 |
| - /* |
44 |
| - Extract templates and styles into a separate files. In rare cases, allow for inline templates of a few |
45 |
| - elements with attributes and three minimal CSS declarations. |
46 |
| - */ |
47 |
| - '@angular-eslint/component-max-inline-declarations': ['error', { animations: 15, styles: 15, template: 15 }], |
48 |
| - |
49 |
| - /* [application-prefix] */ |
50 |
| - '@angular-eslint/component-selector': 'off', |
51 |
| - |
52 |
| - '@angular-eslint/contextual-decorator': 'error', |
53 |
| - |
54 |
| - /* |
55 |
| - Do not require a directive to select an element or attribute exclusively, because there are valid use cases |
56 |
| - for both. |
57 |
| - */ |
58 |
| - '@angular-eslint/directive-selector': 'off', |
59 |
| - |
60 |
| - '@angular-eslint/no-attribute-decorator': 'error', |
61 |
| - |
62 |
| - /* |
63 |
| - `forwardRef` is needed for certain Dependency Injection use cases and abuse is not widespread so its use is permitted. |
64 |
| - */ |
65 |
| - '@angular-eslint/no-forward-ref': 'off', |
66 |
| - |
67 |
| - /* |
68 |
| - We don't yet have a general naming conventions so enforcing a convention just for inputs would be inconsistent. |
69 |
| - */ |
70 |
| - '@angular-eslint/no-input-prefix': 'off', |
71 |
| - |
72 |
| - '@angular-eslint/no-lifecycle-call': 'error', |
73 |
| - |
74 |
| - '@angular-eslint/no-pipe-impure': 'error', |
75 |
| - |
76 |
| - '@angular-eslint/no-queries-metadata-property': 'error', |
77 |
| - |
78 |
| - /* [application-prefix] */ |
79 |
| - '@angular-eslint/pipe-prefix': 'error', |
80 |
| - |
81 |
| - /* |
82 |
| - This rule is for specific applications such as libraries that want to minimize global dependencies or parts |
83 |
| - of an application that have specific performance goals. |
84 |
| - */ |
85 |
| - '@angular-eslint/prefer-on-push-component-change-detection': 'off', |
86 |
| - |
87 |
| - /* |
88 |
| - While marking @Output properties as readonly does better capture the intention of how they should generally be used, |
89 |
| - it does not appear that there is wide-spread abuse of not marking @Output properties readonly. Marking them readonly |
90 |
| - would deviate from the style given in most Angular docs and examples so this rule is not enabled. |
91 |
| - */ |
92 |
| - '@angular-eslint/prefer-output-readonly': 'off', |
93 |
| - |
94 |
| - '@angular-eslint/relative-url-prefix': 'error', |
95 |
| - |
96 |
| - '@angular-eslint/runtime-localize': 'error', |
97 |
| - |
98 |
| - /* |
99 |
| - Generally not expected in practice to sort NgModule metadata arrays. Projects may enable if desired. |
100 |
| - */ |
101 |
| - '@angular-eslint/sort-ngmodule-metadata-arrays': 'off', |
102 |
| - |
103 |
| - '@angular-eslint/use-component-selector': 'error', |
104 |
| - |
105 |
| - '@angular-eslint/use-component-view-encapsulation': 'error', |
106 |
| - |
107 |
| - /* |
108 |
| - Provide root services with the application root injector in the Injectable decorator. However, NgModule |
109 |
| - providers are frequently preferred for non-root, module scoped services in applications where tree-shaking |
110 |
| - is usually irrelevant. Additionally, libraries commonly export services from modules in order to manage |
111 |
| - dependencies. Consider enabling this rule for libraries to ensure proper tree-shaking when appropriate. |
112 |
| - */ |
113 |
| - '@angular-eslint/use-injectable-provided-in': 'off' |
| 1 | +import typescript from '@ni/eslint-config-typescript'; |
| 2 | +import angular from 'angular-eslint'; |
| 3 | + |
| 4 | +export default [ |
| 5 | + ...angular.configs.tsRecommended, |
| 6 | + ...typescript, |
| 7 | + { |
| 8 | + processor: angular.processInlineTemplates, |
| 9 | + rules: { |
| 10 | + |
| 11 | + /* |
| 12 | + '@angular-eslint/no-input-rename' rule notes: |
| 13 | + Disallow renaming directive inputs generally. Use an inline comment to disable the rule for exceptions where the |
| 14 | + context changes significantly, or disable the rule for files of directives that need to prefix their inputs to avoid conflicts. |
| 15 | + */ |
| 16 | + |
| 17 | + /* |
| 18 | + '@angular-eslint/no-output-rename' rule notes: |
| 19 | + Disallow renaming directive outputs generally. Use an inline comment to disable the rule for exceptions where the |
| 20 | + context changes significantly, or disable the rule for projects that use the dollar sign postfix for EventEmitters. |
| 21 | + */ |
| 22 | + |
| 23 | + /* |
| 24 | + Upgrade the recommended rule configuration from a warning to an error. |
| 25 | + */ |
| 26 | + '@angular-eslint/use-lifecycle-interface': 'error', |
| 27 | + |
| 28 | + // We intended to use the default from @typescript-eslint/recommended, but we adopted this override accidentally. |
| 29 | + // See https://github.com/ni/javascript-styleguide/issues/139 |
| 30 | + '@typescript-eslint/no-inferrable-types': [ |
| 31 | + 'error', |
| 32 | + { ignoreParameters: true } |
| 33 | + ], |
| 34 | + |
| 35 | + /* |
| 36 | + Overrides to Angular rules outside of the recommended configuration: |
| 37 | + */ |
| 38 | + |
| 39 | + /* |
| 40 | + Extract templates and styles into a separate files. In rare cases, allow for inline templates of a few |
| 41 | + elements with attributes and three minimal CSS declarations. |
| 42 | + */ |
| 43 | + '@angular-eslint/component-max-inline-declarations': ['error', { animations: 15, styles: 15, template: 15 }], |
| 44 | + |
| 45 | + /* [application-prefix] */ |
| 46 | + '@angular-eslint/component-selector': 'off', |
| 47 | + |
| 48 | + '@angular-eslint/contextual-decorator': 'error', |
| 49 | + |
| 50 | + /* |
| 51 | + Do not require a directive to select an element or attribute exclusively, because there are valid use cases |
| 52 | + for both. |
| 53 | + */ |
| 54 | + '@angular-eslint/directive-selector': 'off', |
| 55 | + |
| 56 | + '@angular-eslint/no-attribute-decorator': 'error', |
| 57 | + |
| 58 | + /* |
| 59 | + `forwardRef` is needed for certain Dependency Injection use cases and abuse is not widespread so its use is permitted. |
| 60 | + */ |
| 61 | + '@angular-eslint/no-forward-ref': 'off', |
| 62 | + |
| 63 | + /* |
| 64 | + We don't yet have a general naming conventions so enforcing a convention just for inputs would be inconsistent. |
| 65 | + */ |
| 66 | + '@angular-eslint/no-input-prefix': 'off', |
| 67 | + |
| 68 | + '@angular-eslint/no-lifecycle-call': 'error', |
| 69 | + |
| 70 | + '@angular-eslint/no-pipe-impure': 'error', |
| 71 | + |
| 72 | + '@angular-eslint/no-queries-metadata-property': 'error', |
| 73 | + |
| 74 | + /* [application-prefix] */ |
| 75 | + '@angular-eslint/pipe-prefix': 'error', |
| 76 | + |
| 77 | + /* |
| 78 | + This rule is for specific applications such as libraries that want to minimize global dependencies or parts |
| 79 | + of an application that have specific performance goals. |
| 80 | + */ |
| 81 | + '@angular-eslint/prefer-on-push-component-change-detection': 'off', |
| 82 | + |
| 83 | + /* |
| 84 | + While marking @Output properties as readonly does better capture the intention of how they should generally be used, |
| 85 | + it does not appear that there is wide-spread abuse of not marking @Output properties readonly. Marking them readonly |
| 86 | + would deviate from the style given in most Angular docs and examples so this rule is not enabled. |
| 87 | + */ |
| 88 | + '@angular-eslint/prefer-output-readonly': 'off', |
| 89 | + |
| 90 | + '@angular-eslint/relative-url-prefix': 'error', |
| 91 | + |
| 92 | + '@angular-eslint/runtime-localize': 'error', |
| 93 | + |
| 94 | + /* |
| 95 | + Generally not expected in practice to sort NgModule metadata arrays. Projects may enable if desired. |
| 96 | + */ |
| 97 | + '@angular-eslint/sort-ngmodule-metadata-arrays': 'off', |
| 98 | + |
| 99 | + '@angular-eslint/use-component-selector': 'error', |
| 100 | + |
| 101 | + '@angular-eslint/use-component-view-encapsulation': 'error', |
| 102 | + |
| 103 | + /* |
| 104 | + Provide root services with the application root injector in the Injectable decorator. However, NgModule |
| 105 | + providers are frequently preferred for non-root, module scoped services in applications where tree-shaking |
| 106 | + is usually irrelevant. Additionally, libraries commonly export services from modules in order to manage |
| 107 | + dependencies. Consider enabling this rule for libraries to ensure proper tree-shaking when appropriate. |
| 108 | + */ |
| 109 | + '@angular-eslint/use-injectable-provided-in': 'off' |
| 110 | + } |
| 111 | + }, |
| 112 | + { |
| 113 | + files: ['**/*.spec.ts'], |
| 114 | + rules: { |
| 115 | + /* |
| 116 | + Tests often define helper components and it improves test readability if they are in the same |
| 117 | + file as the tests. |
| 118 | + */ |
| 119 | + '@angular-eslint/component-max-inline-declarations': 'off', |
| 120 | + |
| 121 | + /* |
| 122 | + Components defined in tests are typically only used within a single test file so don't need. |
| 123 | + a compontent selector. |
| 124 | + */ |
| 125 | + '@angular-eslint/use-component-selector': 'off', |
| 126 | + |
| 127 | + /* |
| 128 | + Tests often define additional classes as mocks or helper components and it improves test readability |
| 129 | + if those are in the same file as the tests. |
| 130 | + */ |
| 131 | + 'max-classes-per-file': 'off' |
| 132 | + } |
114 | 133 | },
|
115 |
| - overrides: [ |
116 |
| - { |
117 |
| - files: ['*.spec.ts'], |
118 |
| - rules: { |
119 |
| - /* |
120 |
| - Tests often define helper components and it improves test readability if they are in the same |
121 |
| - file as the tests. |
122 |
| - */ |
123 |
| - '@angular-eslint/component-max-inline-declarations': 'off', |
124 |
| - |
125 |
| - /* |
126 |
| - Components defined in tests are typically only used within a single test file so don't need. |
127 |
| - a compontent selector. |
128 |
| - */ |
129 |
| - '@angular-eslint/use-component-selector': 'off', |
130 |
| - |
131 |
| - /* |
132 |
| - Tests often define additional classes as mocks or helper components and it improves test readability |
133 |
| - if those are in the same file as the tests. |
134 |
| - */ |
135 |
| - 'max-classes-per-file': 'off' |
136 |
| - } |
137 |
| - }, |
138 |
| - ] |
139 |
| -}; |
| 134 | +]; |
0 commit comments