Skip to content

Commit 4f57331

Browse files
Move template rules from recommended to strict configs (opt-in, non-breaking)
Co-authored-by: NullVoxPopuli <[email protected]>
1 parent 2940d49 commit 4f57331

43 files changed

Lines changed: 221 additions & 188 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,28 @@ module.exports = {
110110
};
111111
```
112112

113+
### Strict Template Linting (Optional)
114+
115+
For enhanced template linting in `gjs`/`gts` files, use the `strict-gjs` or `strict-gts` configs. These include additional template rules ported from `ember-template-lint`:
116+
117+
```javascript
118+
// eslint.config.js
119+
const ember = require('eslint-plugin-ember');
120+
121+
module.exports = [
122+
...ember.configs.recommended,
123+
{
124+
files: ['**/*.gts'],
125+
extends: ['plugin:ember/strict-gts'],
126+
},
127+
{
128+
files: ['**/*.gjs'],
129+
extends: ['plugin:ember/strict-gjs'],
130+
},
131+
];
132+
```
133+
134+
113135
### rules applied to fcct templates
114136

115137
- semi rule, same as [prettier plugin](https://github.com/gitKrystan/prettier-plugin-ember-template-tag/issues/1)
@@ -160,6 +182,8 @@ rules in templates can be disabled with eslint directives with mustache or html
160182
|| `recommended` |
161183
| ![gjs logo](/docs/svgs/gjs.svg) | `recommended-gjs` |
162184
| ![gts logo](/docs/svgs/gts.svg) | `recommended-gts` |
185+
| ![gjs logo](/docs/svgs/gjs.svg) | `strict-gjs` |
186+
| ![gts logo](/docs/svgs/gts.svg) | `strict-gts` |
163187

164188
<!-- end auto-generated configs list -->
165189

@@ -171,6 +195,8 @@ rules in templates can be disabled with eslint directives with mustache or html
171195
✅ Set in the `recommended` [configuration](https://github.com/ember-cli/eslint-plugin-ember#-configurations).\
172196
![gjs logo](/docs/svgs/gjs.svg) Set in the `recommended-gjs` [configuration](https://github.com/ember-cli/eslint-plugin-ember#-configurations).\
173197
![gts logo](/docs/svgs/gts.svg) Set in the `recommended-gts` [configuration](https://github.com/ember-cli/eslint-plugin-ember#-configurations).\
198+
![gjs logo](/docs/svgs/gjs.svg)🔒 Set in the `strict-gjs` [configuration](https://github.com/ember-cli/eslint-plugin-ember#-configurations).\
199+
![gts logo](/docs/svgs/gts.svg)🔒 Set in the `strict-gts` [configuration](https://github.com/ember-cli/eslint-plugin-ember#-configurations).\
174200
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
175201
💡 Manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
176202

lib/config-legacy/strict-gjs.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const base = require('./base');
2+
const gjsRules = require('../strict-rules-gjs');
3+
4+
module.exports = {
5+
...base,
6+
rules: gjsRules,
7+
};

lib/config-legacy/strict-gts.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const base = require('./base');
2+
const gtsRules = require('../strict-rules-gts');
3+
4+
module.exports = {
5+
...base,
6+
rules: gtsRules,
7+
};

lib/config/strict-gjs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const base = require('./base');
2+
const gjsRules = require('../strict-rules-gjs');
3+
4+
module.exports = [...base, { rules: gjsRules }];

lib/config/strict-gts.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const base = require('./base');
2+
const gtsRules = require('../strict-rules-gts');
3+
4+
// see https://github.com/typescript-eslint/typescript-eslint/issues/8607
5+
// https://github.com/typescript-eslint/typescript-eslint/blob/v7.4.0/packages/eslint-plugin/src/configs/eslint-recommended-raw.ts
6+
const tsRecommended = {
7+
'constructor-super': 'off', // ts(2335) & ts(2377)
8+
'getter-return': 'off', // ts(2378)
9+
'no-const-assign': 'off', // ts(2588)
10+
'no-dupe-args': 'off', // ts(2300)
11+
'no-dupe-class-members': 'off', // ts(2393) & ts(2300)
12+
'no-dupe-keys': 'off', // ts(1117)
13+
'no-func-assign': 'off', // ts(2630)
14+
'no-import-assign': 'off', // ts(2632) & ts(2540)
15+
'no-new-symbol': 'off', // ts(7009)
16+
'no-obj-calls': 'off', // ts(2349)
17+
'no-redeclare': 'off', // ts(2451)
18+
'no-setter-return': 'off', // ts(2408)
19+
'no-this-before-super': 'off', // ts(2376) & ts(17009)
20+
'no-undef': 'off', // ts(2304) & ts(2552)
21+
'no-unreachable': 'off', // ts(7027)
22+
'no-unsafe-negation': 'off', // ts(2365) & ts(2322) & ts(2358)
23+
'no-var': 'error', // ts transpiles let/const to var, so no need for vars any more
24+
'prefer-const': 'error', // ts provides better types with const
25+
'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
26+
'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
27+
};
28+
29+
module.exports = [...base, { rules: { ...gtsRules, ...tsRecommended } }];

lib/recommended-rules-gjs.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,5 @@
55
* definitions, execute "npm run update"
66
*/
77
module.exports = {
8-
"ember/template-deprecated-inline-view-helper": "error",
9-
"ember/template-deprecated-render-helper": "error",
10-
"ember/template-link-rel-noopener": "error",
11-
"ember/template-no-abstract-roles": "error",
12-
"ember/template-no-accesskey-attribute": "error",
13-
"ember/template-no-action": "error",
14-
"ember/template-no-args-paths": "error",
15-
"ember/template-no-aria-hidden-body": "error",
16-
"ember/template-no-attrs-in-components": "error",
17-
"ember/template-no-autofocus-attribute": "error",
18-
"ember/template-no-debugger": "error",
19-
"ember/template-no-duplicate-attributes": "error",
20-
"ember/template-no-duplicate-id": "error",
21-
"ember/template-no-empty-headings": "error",
22-
"ember/template-no-heading-inside-button": "error",
23-
"ember/template-no-input-block": "error",
24-
"ember/template-no-input-tagname": "error",
25-
"ember/template-no-let-reference": "error",
26-
"ember/template-no-log": "error",
27-
"ember/template-no-obsolete-elements": "error",
28-
"ember/template-no-partial": "error",
29-
"ember/template-no-positive-tabindex": "error",
30-
"ember/template-no-this-in-template-only-components": "error",
31-
"ember/template-no-triple-curlies": "error",
32-
"ember/template-no-unbound": "error",
33-
"ember/template-no-unnecessary-concat": "error",
34-
"ember/template-no-valueless-arguments": "error",
35-
"ember/template-no-with": "error",
36-
"ember/template-require-button-type": "error",
37-
"ember/template-require-iframe-title": "error",
38-
"ember/template-require-valid-alt-text": "error",
39-
"ember/template-splat-attributes-only": "error"
8+
"ember/template-no-let-reference": "error"
409
}

lib/recommended-rules-gts.js

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,5 @@
55
* definitions, execute "npm run update"
66
*/
77
module.exports = {
8-
"ember/template-deprecated-inline-view-helper": "error",
9-
"ember/template-deprecated-render-helper": "error",
10-
"ember/template-link-rel-noopener": "error",
11-
"ember/template-no-abstract-roles": "error",
12-
"ember/template-no-accesskey-attribute": "error",
13-
"ember/template-no-action": "error",
14-
"ember/template-no-args-paths": "error",
15-
"ember/template-no-aria-hidden-body": "error",
16-
"ember/template-no-attrs-in-components": "error",
17-
"ember/template-no-autofocus-attribute": "error",
18-
"ember/template-no-debugger": "error",
19-
"ember/template-no-duplicate-attributes": "error",
20-
"ember/template-no-duplicate-id": "error",
21-
"ember/template-no-empty-headings": "error",
22-
"ember/template-no-heading-inside-button": "error",
23-
"ember/template-no-input-block": "error",
24-
"ember/template-no-input-tagname": "error",
25-
"ember/template-no-let-reference": "error",
26-
"ember/template-no-log": "error",
27-
"ember/template-no-obsolete-elements": "error",
28-
"ember/template-no-partial": "error",
29-
"ember/template-no-positive-tabindex": "error",
30-
"ember/template-no-this-in-template-only-components": "error",
31-
"ember/template-no-triple-curlies": "error",
32-
"ember/template-no-unbound": "error",
33-
"ember/template-no-unnecessary-concat": "error",
34-
"ember/template-no-valueless-arguments": "error",
35-
"ember/template-no-with": "error",
36-
"ember/template-require-button-type": "error",
37-
"ember/template-require-iframe-title": "error",
38-
"ember/template-require-valid-alt-text": "error",
39-
"ember/template-splat-attributes-only": "error"
8+
"ember/template-no-let-reference": "error"
409
}

lib/rules/template-deprecated-inline-view-helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ module.exports = {
55
docs: {
66
description: 'disallow inline {{view}} helper',
77
category: 'Deprecations',
8-
recommendedGjs: true,
9-
recommendedGts: true,
8+
strictGjs: true,
9+
strictGts: true,
1010
url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-deprecated-inline-view-helper.md',
1111
},
1212
fixable: null,

lib/rules/template-deprecated-render-helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ module.exports = {
55
docs: {
66
description: 'disallow {{render}} helper',
77
category: 'Deprecations',
8-
recommendedGjs: true,
9-
recommendedGts: true,
8+
strictGjs: true,
9+
strictGts: true,
1010
url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-deprecated-render-helper.md',
1111
},
1212
fixable: null,

lib/rules/template-link-rel-noopener.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ module.exports = {
55
docs: {
66
description: 'require rel="noopener noreferrer" on links with target="_blank"',
77
category: 'Security',
8-
recommendedGjs: true,
9-
recommendedGts: true,
8+
strictGjs: true,
9+
strictGts: true,
1010
url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-link-rel-noopener.md',
1111
},
1212
fixable: 'code',

0 commit comments

Comments
 (0)