Repository: ember-cli/eslint-plugin-ember
Pull request #1981 (2023-11-04 22:56:32)

Add `template-no-let-reference` rule to `recommended-gjs` and `recommended-gts` configs 

NullVoxPopuli: 🎉 

Patch:
diff --git a/README.md b/README.md
index e64ca3c7..d014c68d 100644
--- a/README.md
+++ b/README.md
@@ -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).
 
@@ -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
 
diff --git a/docs/rules/template-no-let-reference.md b/docs/rules/template-no-let-reference.md
index 8880792f..7a6cda05 100644
--- a/docs/rules/template-no-let-reference.md
+++ b/docs/rules/template-no-let-reference.md
@@ -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 -->
 
diff --git a/lib/recommended-rules-gjs.js b/lib/recommended-rules-gjs.js
index 7c4139bf..d56fcfd7 100644
--- a/lib/recommended-rules-gjs.js
+++ b/lib/recommended-rules-gjs.js
@@ -4,4 +4,6 @@
  * In order to update its content based on rules'
  * definitions, execute "npm run update"
  */
-module.exports = {}
\ No newline at end of file
+module.exports = {
+  "ember/template-no-let-reference": "error"
+}
\ No newline at end of file
diff --git a/lib/recommended-rules-gts.js b/lib/recommended-rules-gts.js
index 7c4139bf..d56fcfd7 100644
--- a/lib/recommended-rules-gts.js
+++ b/lib/recommended-rules-gts.js
@@ -4,4 +4,6 @@
  * In order to update its content based on rules'
  * definitions, execute "npm run update"
  */
-module.exports = {}
\ No newline at end of file
+module.exports = {
+  "ember/template-no-let-reference": "error"
+}
\ No newline at end of file
diff --git a/lib/recommended-rules.js b/lib/recommended-rules.js
index f4af8b11..360f1062 100644
--- a/lib/recommended-rules.js
+++ b/lib/recommended-rules.js
@@ -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"
 }
\ No newline at end of file
diff --git a/lib/rules/template-indent.js b/lib/rules/template-indent.js
index e658b86c..fc1426a8 100644
--- a/lib/rules/template-indent.js
+++ b/lib/rules/template-indent.js
@@ -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',
     },
diff --git a/lib/rules/template-no-let-reference.js b/lib/rules/template-no-let-reference.js
index 4ba6d173..e8822f98 100644
--- a/lib/rules/template-no-let-reference.js
+++ b/lib/rules/template-no-let-reference.js
@@ -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,
diff --git a/scripts/update-rules.js b/scripts/update-rules.js
index dbf00f3f..e1a0ca90 100644
--- a/scripts/update-rules.js
+++ b/scripts/update-rules.js
@@ -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);


Test patch:
diff --git a/tests/__snapshots__/recommended.js.snap b/tests/__snapshots__/recommended.js.snap
index dc84b8f8..a425507f 100644
--- a/tests/__snapshots__/recommended.js.snap
+++ b/tests/__snapshots__/recommended.js.snap
@@ -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",
@@ -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",
 ]
diff --git a/tests/recommended.js b/tests/recommended.js
index 82a6fcf2..c04e9665 100644
--- a/tests/recommended.js
+++ b/tests/recommended.js
@@ -1,5 +1,4 @@
 'use strict';
-
 const rules = require('../lib').rules;
 
 describe('recommended rules', () => {
@@ -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();
+  });
 });