Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ rules in templates can be disabled with eslint directives with mustache or html

💼 [Configurations](https://github.com/ember-cli/eslint-plugin-ember#-configurations) enabled in.\
✅ Set in the `recommended` [configuration](https://github.com/ember-cli/eslint-plugin-ember#-configurations).\
![gjs logo](/docs/svgs/gjs.svg) Set in the `recommended-gjs` [configuration](https://github.com/ember-cli/eslint-plugin-ember#-configurations).\
![gts logo](/docs/svgs/gts.svg) Set in the `recommended-gts` [configuration](https://github.com/ember-cli/eslint-plugin-ember#-configurations).\
🔧 Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).\
💡 Manually fixable by [editor suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).

Expand Down Expand Up @@ -231,17 +233,17 @@ rules in templates can be disabled with eslint directives with mustache or html

### Ember Octane

| Name                                 | Description | 💼 | 🔧 | 💡 |
| :----------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------- | :- | :- | :- |
| [classic-decorator-hooks](docs/rules/classic-decorator-hooks.md) | enforce using correct hooks for both classic and non-classic classes | ✅ | | |
| [classic-decorator-no-classic-methods](docs/rules/classic-decorator-no-classic-methods.md) | disallow usage of classic APIs such as `get`/`set` in classes that aren't explicitly decorated with `@classic` | ✅ | | |
| [no-actions-hash](docs/rules/no-actions-hash.md) | disallow the actions hash in components, controllers, and routes | ✅ | | |
| [no-classic-classes](docs/rules/no-classic-classes.md) | disallow "classic" classes in favor of native JS classes | ✅ | | |
| [no-ember-super-in-es-classes](docs/rules/no-ember-super-in-es-classes.md) | disallow use of `this._super` in ES class methods | ✅ | 🔧 | |
| [no-empty-glimmer-component-classes](docs/rules/no-empty-glimmer-component-classes.md) | disallow empty backing classes for Glimmer components | ✅ | | |
| [no-tracked-properties-from-args](docs/rules/no-tracked-properties-from-args.md) | disallow creating @tracked properties from this.args | ✅ | | |
| [template-indent](docs/rules/template-indent.md) | enforce consistent indentation for gts/gjs templates | | 🔧 | |
| [template-no-let-reference](docs/rules/template-no-let-reference.md) | disallow referencing let variables in \<template\> | | | |
| Name                                 | Description | 💼 | 🔧 | 💡 |
| :----------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------- | :- | :- |
| [classic-decorator-hooks](docs/rules/classic-decorator-hooks.md) | enforce using correct hooks for both classic and non-classic classes | ✅ | | |
| [classic-decorator-no-classic-methods](docs/rules/classic-decorator-no-classic-methods.md) | disallow usage of classic APIs such as `get`/`set` in classes that aren't explicitly decorated with `@classic` | ✅ | | |
| [no-actions-hash](docs/rules/no-actions-hash.md) | disallow the actions hash in components, controllers, and routes | ✅ | | |
| [no-classic-classes](docs/rules/no-classic-classes.md) | disallow "classic" classes in favor of native JS classes | ✅ | | |
| [no-ember-super-in-es-classes](docs/rules/no-ember-super-in-es-classes.md) | disallow use of `this._super` in ES class methods | ✅ | 🔧 | |
| [no-empty-glimmer-component-classes](docs/rules/no-empty-glimmer-component-classes.md) | disallow empty backing classes for Glimmer components | ✅ | | |
| [no-tracked-properties-from-args](docs/rules/no-tracked-properties-from-args.md) | disallow creating @tracked properties from this.args | ✅ | | |
| [template-indent](docs/rules/template-indent.md) | enforce consistent indentation for gts/gjs templates | | 🔧 | |
| [template-no-let-reference](docs/rules/template-no-let-reference.md) | disallow referencing let variables in \<template\> | ![gjs logo](/docs/svgs/gjs.svg) ![gts logo](/docs/svgs/gts.svg) | | |

### jQuery

Expand Down
2 changes: 1 addition & 1 deletion docs/rules/template-no-let-reference.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ember/template-no-let-reference

💼 This rule is enabled in the ✅ `recommended` [config](https://github.com/ember-cli/eslint-plugin-ember#-configurations).
💼 This rule is enabled in the following [configs](https://github.com/ember-cli/eslint-plugin-ember#-configurations): ![gjs logo](/docs/svgs/gjs.svg) `recommended-gjs`, ![gts logo](/docs/svgs/gts.svg) `recommended-gts`.

<!-- end auto-generated rule header -->

Expand Down
4 changes: 3 additions & 1 deletion lib/recommended-rules-gjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
* In order to update its content based on rules'
* definitions, execute "npm run update"
*/
module.exports = {}
module.exports = {
"ember/template-no-let-reference": "error"
}
4 changes: 3 additions & 1 deletion lib/recommended-rules-gts.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
* In order to update its content based on rules'
* definitions, execute "npm run update"
*/
module.exports = {}
module.exports = {
"ember/template-no-let-reference": "error"
}
1 change: 0 additions & 1 deletion lib/recommended-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ module.exports = {
"ember/require-tagless-components": "error",
"ember/require-valid-css-selector-in-test-helpers": "error",
"ember/routes-segments-snake-case": "error",
"ember/template-no-let-reference": "error",
"ember/use-brace-expansion": "error",
"ember/use-ember-data-rfc-395-imports": "error"
}
3 changes: 2 additions & 1 deletion lib/rules/template-indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ module.exports = {
docs: {
description: 'enforce consistent indentation for gts/gjs templates',
// too opinionated to be recommended
recommended: false,
recommendedGjs: false,
recommendedGts: false,
category: 'Ember Octane',
url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-indent.md',
},
Expand Down
3 changes: 2 additions & 1 deletion lib/rules/template-no-let-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module.exports = {
docs: {
description: 'disallow referencing let variables in \\<template\\>',
category: 'Ember Octane',
recommended: true,
recommendedGjs: true,
recommendedGts: true,
url: 'https://github.com/ember-cli/eslint-plugin-ember/tree/master/docs/rules/template-no-let-reference.md',
},
fixable: null,
Expand Down
4 changes: 2 additions & 2 deletions scripts/update-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ module.exports = ${JSON.stringify(recommendedRules, null, 2)}`;
}

generate('../lib/recommended-rules.js', (entry) => entry[1].meta.docs.recommended);
generate('../lib/recommended-rules-gjs.js', (entry) => entry[1].meta.docs.category === 'gjs');
generate('../lib/recommended-rules-gts.js', (entry) => entry[1].meta.docs.category === 'gts');
generate('../lib/recommended-rules-gjs.js', (entry) => entry[1].meta.docs.recommendedGjs);
generate('../lib/recommended-rules-gts.js', (entry) => entry[1].meta.docs.recommendedGts);
13 changes: 12 additions & 1 deletion tests/__snapshots__/recommended.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`recommended rules gjs config has the right list 1`] = `
[
"template-no-let-reference",
]
`;

exports[`recommended rules gts config has the right list 1`] = `
[
"template-no-let-reference",
]
`;

exports[`recommended rules has the right list 1`] = `
[
"avoid-leaking-state-in-ember-objects",
Expand Down Expand Up @@ -70,7 +82,6 @@ exports[`recommended rules has the right list 1`] = `
"require-tagless-components",
"require-valid-css-selector-in-test-helpers",
"routes-segments-snake-case",
"template-no-let-reference",
"use-brace-expansion",
"use-ember-data-rfc-395-imports",
]
Expand Down
27 changes: 26 additions & 1 deletion tests/recommended.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';

const rules = require('../lib').rules;

describe('recommended rules', () => {
Expand All @@ -15,4 +14,30 @@ describe('recommended rules', () => {

expect(errors).toMatchSnapshot();
});

it('gjs config has the right list', () => {
const errors = [];

for (const name of Object.keys(rules)) {
// eslint-disable-next-line jest/no-if
if (rules[name].meta.docs.recommendedGjs) {
errors.push(name);
}
}

expect(errors).toMatchSnapshot();
});

it('gts config has the right list', () => {
const errors = [];

for (const name of Object.keys(rules)) {
// eslint-disable-next-line jest/no-if
if (rules[name].meta.docs.recommendedGts) {
errors.push(name);
}
}

expect(errors).toMatchSnapshot();
});
});