From dc4b8e00127eff53451cc163d3e5c75c8c5ecf4d Mon Sep 17 00:00:00 2001 From: Alexandre Morgaut <49318+AMorgaut@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:07:39 +0000 Subject: [PATCH 1/9] fix(eslint): flat config support --- eslint-plugin/lib/standalone.js | 38 +++++++++++++++++++++------------ eslint-plugin/package.json | 2 +- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/eslint-plugin/lib/standalone.js b/eslint-plugin/lib/standalone.js index 8d23003..4d119d5 100644 --- a/eslint-plugin/lib/standalone.js +++ b/eslint-plugin/lib/standalone.js @@ -22,21 +22,31 @@ */ "use strict"; -const rules = require("./rule-list"); +const rulesList = require("./rule-list"); -const ruleModules = rules.reduce((map, rule) => { - map[rule.ruleName] = rule.ruleModule; - return map; -}, {}); +const allRules = {} +const rules = {} // recommended rules -const ruleConfigs = rules.reduce((map, rule) => { - const recommended = rule.ruleModule.meta.docs.recommended; - map[`@ecocode/${rule.ruleName}`] = - recommended === false ? "off" : recommended; - return map; -}, {}); +for (let { ruleName, ruleModule } of rulesList) { + allRules[ruleName] = ruleModule; + const { recommended } = ruleModule.meta.docs; + rules[`@ecocode/${ruleName}`] = recommended === false ? "off" : recommended; +} -module.exports = { - rules: ruleModules, - configs: { recommended: { plugins: ["@ecocode"], rules: ruleConfigs } }, +const plugin = { + meta: { + name: "@ecocode/eslint-plugin", + version: "1.6.0" + }, + rules: allRules, + configs: { + recommended: { + plugins: ["@ecocode"], rules, + } + ['flat/recommended'] = { + plugins: { '@ecocode': ecocode }, rules, + } + }, }; + +module.exports = plugin; diff --git a/eslint-plugin/package.json b/eslint-plugin/package.json index d149025..9a39e9e 100644 --- a/eslint-plugin/package.json +++ b/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@ecocode/eslint-plugin", - "version": "1.5.0", + "version": "1.6.0", "description": "JavaScript linter of ecoCode project", "keywords": [ "eslint", From 56a9dabf65da1e6e3322c9ca9c39fedaf879bfd2 Mon Sep 17 00:00:00 2001 From: Alexandre Morgaut <49318+AMorgaut@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:45:42 +0200 Subject: [PATCH 2/9] fix: fix wrong plugin reference --- eslint-plugin/lib/standalone.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eslint-plugin/lib/standalone.js b/eslint-plugin/lib/standalone.js index 4d119d5..a428a92 100644 --- a/eslint-plugin/lib/standalone.js +++ b/eslint-plugin/lib/standalone.js @@ -44,7 +44,7 @@ const plugin = { plugins: ["@ecocode"], rules, } ['flat/recommended'] = { - plugins: { '@ecocode': ecocode }, rules, + plugins: { '@ecocode': plugin }, rules, } }, }; From 97b58c1913077a11cac6b89818c0dd40620a5b75 Mon Sep 17 00:00:00 2001 From: Alexandre Morgaut <49318+AMorgaut@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:59:14 +0200 Subject: [PATCH 3/9] fix: postpone plugin config initialisation to fix reference --- eslint-plugin/lib/standalone.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/eslint-plugin/lib/standalone.js b/eslint-plugin/lib/standalone.js index a428a92..fb5c68d 100644 --- a/eslint-plugin/lib/standalone.js +++ b/eslint-plugin/lib/standalone.js @@ -39,14 +39,15 @@ const plugin = { version: "1.6.0" }, rules: allRules, - configs: { - recommended: { - plugins: ["@ecocode"], rules, - } - ['flat/recommended'] = { - plugins: { '@ecocode': plugin }, rules, - } - }, }; +plugin.configs = { + recommended: { + plugins: ["@ecocode"], rules, + } + ['flat/recommended'] = { + plugins: { '@ecocode': plugin }, rules, + } +} + module.exports = plugin; From b24c6c19a6fc3faa427e2adfd3d42f605d5bd667 Mon Sep 17 00:00:00 2001 From: Alexandre Morgaut <49318+AMorgaut@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:42:03 +0200 Subject: [PATCH 4/9] chore: prettier fix --- eslint-plugin/lib/standalone.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/eslint-plugin/lib/standalone.js b/eslint-plugin/lib/standalone.js index fb5c68d..ddb2f71 100644 --- a/eslint-plugin/lib/standalone.js +++ b/eslint-plugin/lib/standalone.js @@ -25,28 +25,31 @@ const rulesList = require("./rule-list"); const allRules = {} -const rules = {} // recommended rules +const recommendedRules = {} // recommended rules for (let { ruleName, ruleModule } of rulesList) { allRules[ruleName] = ruleModule; const { recommended } = ruleModule.meta.docs; - rules[`@ecocode/${ruleName}`] = recommended === false ? "off" : recommended; + const ruleConfiguration = recommended === false ? "off" : recommended + recommendedRules[`@ecocode/${ruleName}`] = ruleConfiguration; } const plugin = { meta: { - name: "@ecocode/eslint-plugin", - version: "1.6.0" + name: "@ecocode/eslint-plugin", + version: "1.6.0", }, rules: allRules, }; -plugin.configs = { +plugin.configs = { recommended: { - plugins: ["@ecocode"], rules, - } + plugins: ["@ecocode"], + rules: recommendedRules, + }, ['flat/recommended'] = { - plugins: { '@ecocode': plugin }, rules, + plugins: { '@ecocode': plugin }, + rules: recommendedRules, } } From d17d6b5f3073f14075b656b2c07cb7dc757f61b3 Mon Sep 17 00:00:00 2001 From: Alexandre Morgaut <49318+AMorgaut@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:23:06 +0000 Subject: [PATCH 5/9] doc: update rules and eslint documentations --- eslint-plugin/README.md | 71 ++++++++++++++----- .../docs/rules/avoid-brightness-override.md | 2 +- .../docs/rules/avoid-css-animations.md | 2 +- .../rules/avoid-high-accuracy-geolocation.md | 2 +- .../docs/rules/limit-db-query-results.md | 2 +- .../rules/no-empty-image-src-attribute.md | 2 +- .../docs/rules/no-import-all-from-library.md | 2 +- .../rules/no-multiple-access-dom-element.md | 2 +- .../docs/rules/no-multiple-style-changes.md | 2 +- eslint-plugin/docs/rules/no-torch.md | 2 +- .../prefer-collections-with-pagination.md | 2 +- .../rules/prefer-shorthand-css-notations.md | 2 +- eslint-plugin/docs/rules/provide-print-css.md | 2 +- eslint-plugin/lib/standalone.js | 16 ++--- 14 files changed, 73 insertions(+), 38 deletions(-) diff --git a/eslint-plugin/README.md b/eslint-plugin/README.md index fde7e2c..5b28922 100644 --- a/eslint-plugin/README.md +++ b/eslint-plugin/README.md @@ -36,17 +36,52 @@ yarn add -D eslint @green-code-initiative/ecocode-eslint-plugin npm install -D eslint @green-code-initiative/ecocode-eslint-plugin ``` -### Enable whole plugin +### Enable plugin with recommended configuration -Add `@ecocode` recommended configuration to `extends` section of your `.eslintrc`: +#### With modern `eslint.config.js` -```jsonc +Add `@ecocode` **"flat/recommended"** configuration to your `eslint.config.js`: + +```js +import ecocode from '@ecocode/eslint-plugin' + +export default [ + /* other eslint configurations */ + ecocode.configs['flat/recommended'], +] +``` + +#### With the legacy `.eslintrc` + +Add `@ecocode` **"recommended"** configuration to `extends` section of your `.eslintrc`: + +```json { "extends": ["plugin:@ecocode/recommended"] } ``` -### Enable only some rules +### Enable specific rules + +#### With modern `eslint.config.js` + +Add the `ecocode` plugin configuration to your `eslint.config.js` and select the rules to activate: + +```js +import ecocode from '@ecocode/eslint-plugin' + +export default [ + /* other eslint configurations */ + { + plugins: { "@ecocode": ecocode }, + rules: { + "@ecocode/no-multiple-access-dom-element": "error" + } + } +] +``` + +#### With the legacy `.eslintrc` Add `@ecocode` to the `plugins` section of your `.eslintrc`, followed by rules configuration: @@ -67,20 +102,20 @@ Add `@ecocode` to the `plugins` section of your `.eslintrc`, followed by rules c ⚠️ Configurations set to warn in.\ ✅ Set in the `recommended` configuration. -| Name | Description | ⚠️ | -| :------------------------------------------------------------------------------------- | :--------------------------------------------------------- | :- | -| [avoid-brightness-override](docs/rules/avoid-brightness-override.md) | Should avoid to override brightness | ✅ | -| [avoid-css-animations](docs/rules/avoid-css-animations.md) | Avoid usage of CSS animations | ✅ | -| [avoid-high-accuracy-geolocation](docs/rules/avoid-high-accuracy-geolocation.md) | Avoid using high accuracy geolocation in web applications. | ✅ | -| [limit-db-query-results](docs/rules/limit-db-query-results.md) | Should limit the number of returns for a SQL query | ✅ | -| [no-empty-image-src-attribute](docs/rules/no-empty-image-src-attribute.md) | Disallow usage of image with empty source attribute | ✅ | -| [no-import-all-from-library](docs/rules/no-import-all-from-library.md) | Should not import all from library | ✅ | -| [no-multiple-access-dom-element](docs/rules/no-multiple-access-dom-element.md) | Disallow multiple access of same DOM element. | ✅ | -| [no-multiple-style-changes](docs/rules/no-multiple-style-changes.md) | Disallow multiple style changes at once. | ✅ | -| [no-torch](docs/rules/no-torch.md) | Should not programmatically enable torch mode | ✅ | -| [prefer-collections-with-pagination](docs/rules/prefer-collections-with-pagination.md) | Prefer API collections with pagination. | ✅ | -| [prefer-shorthand-css-notations](docs/rules/prefer-shorthand-css-notations.md) | Encourage usage of shorthand CSS notations | ✅ | -| [provide-print-css](docs/rules/provide-print-css.md) | Enforce providing a print stylesheet | ✅ | +| Name | Description | ⚠️ | +| :------------------------------------------------------------------------------------- | :--------------------------------------------------------- | :---------------------------- | +| [avoid-brightness-override](docs/rules/avoid-brightness-override.md) | Should avoid to override brightness | ✅ ![badge-flat/recommended][] | +| [avoid-css-animations](docs/rules/avoid-css-animations.md) | Avoid usage of CSS animations | ✅ ![badge-flat/recommended][] | +| [avoid-high-accuracy-geolocation](docs/rules/avoid-high-accuracy-geolocation.md) | Avoid using high accuracy geolocation in web applications. | ✅ ![badge-flat/recommended][] | +| [limit-db-query-results](docs/rules/limit-db-query-results.md) | Should limit the number of returns for a SQL query | ✅ ![badge-flat/recommended][] | +| [no-empty-image-src-attribute](docs/rules/no-empty-image-src-attribute.md) | Disallow usage of image with empty source attribute | ✅ ![badge-flat/recommended][] | +| [no-import-all-from-library](docs/rules/no-import-all-from-library.md) | Should not import all from library | ✅ ![badge-flat/recommended][] | +| [no-multiple-access-dom-element](docs/rules/no-multiple-access-dom-element.md) | Disallow multiple access of same DOM element. | ✅ ![badge-flat/recommended][] | +| [no-multiple-style-changes](docs/rules/no-multiple-style-changes.md) | Disallow multiple style changes at once. | ✅ ![badge-flat/recommended][] | +| [no-torch](docs/rules/no-torch.md) | Should not programmatically enable torch mode | ✅ ![badge-flat/recommended][] | +| [prefer-collections-with-pagination](docs/rules/prefer-collections-with-pagination.md) | Prefer API collections with pagination. | ✅ ![badge-flat/recommended][] | +| [prefer-shorthand-css-notations](docs/rules/prefer-shorthand-css-notations.md) | Encourage usage of shorthand CSS notations | ✅ ![badge-flat/recommended][] | +| [provide-print-css](docs/rules/provide-print-css.md) | Enforce providing a print stylesheet | ✅ ![badge-flat/recommended][] | diff --git a/eslint-plugin/docs/rules/avoid-brightness-override.md b/eslint-plugin/docs/rules/avoid-brightness-override.md index 34a3e3f..a28af56 100644 --- a/eslint-plugin/docs/rules/avoid-brightness-override.md +++ b/eslint-plugin/docs/rules/avoid-brightness-override.md @@ -1,6 +1,6 @@ # Should avoid to override brightness (`@ecocode/avoid-brightness-override`) -⚠️ This rule _warns_ in the ✅ `recommended` config. +⚠️ This rule _warns_ in the following configs: `flat/recommended`, ✅ `recommended`. diff --git a/eslint-plugin/docs/rules/avoid-css-animations.md b/eslint-plugin/docs/rules/avoid-css-animations.md index 2a77558..ab4080f 100644 --- a/eslint-plugin/docs/rules/avoid-css-animations.md +++ b/eslint-plugin/docs/rules/avoid-css-animations.md @@ -1,6 +1,6 @@ # Avoid usage of CSS animations (`@ecocode/avoid-css-animations`) -⚠️ This rule _warns_ in the ✅ `recommended` config. +⚠️ This rule _warns_ in the following configs: `flat/recommended`, ✅ `recommended`. diff --git a/eslint-plugin/docs/rules/avoid-high-accuracy-geolocation.md b/eslint-plugin/docs/rules/avoid-high-accuracy-geolocation.md index 49e4072..e9cae02 100644 --- a/eslint-plugin/docs/rules/avoid-high-accuracy-geolocation.md +++ b/eslint-plugin/docs/rules/avoid-high-accuracy-geolocation.md @@ -1,6 +1,6 @@ # Avoid using high accuracy geolocation in web applications (`@ecocode/avoid-high-accuracy-geolocation`) -⚠️ This rule _warns_ in the ✅ `recommended` config. +⚠️ This rule _warns_ in the following configs: `flat/recommended`, ✅ `recommended`. diff --git a/eslint-plugin/docs/rules/limit-db-query-results.md b/eslint-plugin/docs/rules/limit-db-query-results.md index e996235..b1030b6 100644 --- a/eslint-plugin/docs/rules/limit-db-query-results.md +++ b/eslint-plugin/docs/rules/limit-db-query-results.md @@ -1,6 +1,6 @@ # Should limit the number of returns for a SQL query (`@ecocode/limit-db-query-results`) -⚠️ This rule _warns_ in the ✅ `recommended` config. +⚠️ This rule _warns_ in the following configs: `flat/recommended`, ✅ `recommended`. diff --git a/eslint-plugin/docs/rules/no-empty-image-src-attribute.md b/eslint-plugin/docs/rules/no-empty-image-src-attribute.md index 8051a81..637eb73 100644 --- a/eslint-plugin/docs/rules/no-empty-image-src-attribute.md +++ b/eslint-plugin/docs/rules/no-empty-image-src-attribute.md @@ -1,6 +1,6 @@ # Disallow usage of image with empty source attribute (`@ecocode/no-empty-image-src-attribute`) -⚠️ This rule _warns_ in the ✅ `recommended` config. +⚠️ This rule _warns_ in the following configs: `flat/recommended`, ✅ `recommended`. diff --git a/eslint-plugin/docs/rules/no-import-all-from-library.md b/eslint-plugin/docs/rules/no-import-all-from-library.md index 9b3b541..f9d3056 100644 --- a/eslint-plugin/docs/rules/no-import-all-from-library.md +++ b/eslint-plugin/docs/rules/no-import-all-from-library.md @@ -1,6 +1,6 @@ # Should not import all from library (`@ecocode/no-import-all-from-library`) -⚠️ This rule _warns_ in the ✅ `recommended` config. +⚠️ This rule _warns_ in the following configs: `flat/recommended`, ✅ `recommended`. diff --git a/eslint-plugin/docs/rules/no-multiple-access-dom-element.md b/eslint-plugin/docs/rules/no-multiple-access-dom-element.md index b88d139..6b5e585 100644 --- a/eslint-plugin/docs/rules/no-multiple-access-dom-element.md +++ b/eslint-plugin/docs/rules/no-multiple-access-dom-element.md @@ -1,6 +1,6 @@ # Disallow multiple access of same DOM element (`@ecocode/no-multiple-access-dom-element`) -⚠️ This rule _warns_ in the ✅ `recommended` config. +⚠️ This rule _warns_ in the following configs: `flat/recommended`, ✅ `recommended`. diff --git a/eslint-plugin/docs/rules/no-multiple-style-changes.md b/eslint-plugin/docs/rules/no-multiple-style-changes.md index 1742cdd..2a9d7e2 100644 --- a/eslint-plugin/docs/rules/no-multiple-style-changes.md +++ b/eslint-plugin/docs/rules/no-multiple-style-changes.md @@ -1,6 +1,6 @@ # Disallow multiple style changes at once (`@ecocode/no-multiple-style-changes`) -⚠️ This rule _warns_ in the ✅ `recommended` config. +⚠️ This rule _warns_ in the following configs: `flat/recommended`, ✅ `recommended`. diff --git a/eslint-plugin/docs/rules/no-torch.md b/eslint-plugin/docs/rules/no-torch.md index ca068a4..009c437 100644 --- a/eslint-plugin/docs/rules/no-torch.md +++ b/eslint-plugin/docs/rules/no-torch.md @@ -1,6 +1,6 @@ # Should not programmatically enable torch mode (`@ecocode/no-torch`) -⚠️ This rule _warns_ in the ✅ `recommended` config. +⚠️ This rule _warns_ in the following configs: `flat/recommended`, ✅ `recommended`. ## Why is this an issue? diff --git a/eslint-plugin/docs/rules/prefer-collections-with-pagination.md b/eslint-plugin/docs/rules/prefer-collections-with-pagination.md index 2a457d8..52dd2b5 100644 --- a/eslint-plugin/docs/rules/prefer-collections-with-pagination.md +++ b/eslint-plugin/docs/rules/prefer-collections-with-pagination.md @@ -1,6 +1,6 @@ # Prefer API collections with pagination (`@ecocode/prefer-collections-with-pagination`) -⚠️ This rule _warns_ in the ✅ `recommended` config. +⚠️ This rule _warns_ in the following configs: `flat/recommended`, ✅ `recommended`. diff --git a/eslint-plugin/docs/rules/prefer-shorthand-css-notations.md b/eslint-plugin/docs/rules/prefer-shorthand-css-notations.md index e8f66e2..07437bd 100644 --- a/eslint-plugin/docs/rules/prefer-shorthand-css-notations.md +++ b/eslint-plugin/docs/rules/prefer-shorthand-css-notations.md @@ -1,6 +1,6 @@ # Encourage usage of shorthand CSS notations (`@ecocode/prefer-shorthand-css-notations`) -⚠️ This rule _warns_ in the ✅ `recommended` config. +⚠️ This rule _warns_ in the following configs: `flat/recommended`, ✅ `recommended`. diff --git a/eslint-plugin/docs/rules/provide-print-css.md b/eslint-plugin/docs/rules/provide-print-css.md index 42f13b3..c6dff54 100644 --- a/eslint-plugin/docs/rules/provide-print-css.md +++ b/eslint-plugin/docs/rules/provide-print-css.md @@ -1,6 +1,6 @@ # Enforce providing a print stylesheet (`@ecocode/provide-print-css`) -⚠️ This rule _warns_ in the ✅ `recommended` config. +⚠️ This rule _warns_ in the following configs: `flat/recommended`, ✅ `recommended`. diff --git a/eslint-plugin/lib/standalone.js b/eslint-plugin/lib/standalone.js index ddb2f71..a6b9fdb 100644 --- a/eslint-plugin/lib/standalone.js +++ b/eslint-plugin/lib/standalone.js @@ -24,13 +24,13 @@ const rulesList = require("./rule-list"); -const allRules = {} -const recommendedRules = {} // recommended rules +const allRules = {}; +const recommendedRules = {}; // recommended rules for (let { ruleName, ruleModule } of rulesList) { allRules[ruleName] = ruleModule; const { recommended } = ruleModule.meta.docs; - const ruleConfiguration = recommended === false ? "off" : recommended + const ruleConfiguration = recommended === false ? "off" : recommended; recommendedRules[`@ecocode/${ruleName}`] = ruleConfiguration; } @@ -46,11 +46,11 @@ plugin.configs = { recommended: { plugins: ["@ecocode"], rules: recommendedRules, - }, - ['flat/recommended'] = { - plugins: { '@ecocode': plugin }, + }, + ["flat/recommended"]: { + plugins: { "@ecocode": plugin }, rules: recommendedRules, - } -} + }, +}; module.exports = plugin; From d667571459eeaa7e99a7f6b66d2a5d7d3553953c Mon Sep 17 00:00:00 2001 From: Alexandre Morgaut Date: Wed, 16 Oct 2024 16:42:29 +0200 Subject: [PATCH 6/9] Update eslint-plugin/README.md Co-authored-by: Maxime Malgorn <9255967+utarwyn@users.noreply.github.com> --- eslint-plugin/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eslint-plugin/README.md b/eslint-plugin/README.md index 5b28922..80510ce 100644 --- a/eslint-plugin/README.md +++ b/eslint-plugin/README.md @@ -65,7 +65,7 @@ Add `@ecocode` **"recommended"** configuration to `extends` section of your `.es #### With modern `eslint.config.js` -Add the `ecocode` plugin configuration to your `eslint.config.js` and select the rules to activate: +Add the `ecocode` plugin configuration to your `eslint.config.js` and select the rules to activate: ```js import ecocode from '@ecocode/eslint-plugin' From 154179c79cdfa7f767d5737be7449cbb03490d5c Mon Sep 17 00:00:00 2001 From: Alexandre Morgaut Date: Fri, 18 Oct 2024 09:03:00 +0200 Subject: [PATCH 7/9] Update eslint-plugin/lib/standalone.js Co-authored-by: Maxime Malgorn <9255967+utarwyn@users.noreply.github.com> --- eslint-plugin/lib/standalone.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eslint-plugin/lib/standalone.js b/eslint-plugin/lib/standalone.js index a6b9fdb..f5c9778 100644 --- a/eslint-plugin/lib/standalone.js +++ b/eslint-plugin/lib/standalone.js @@ -25,7 +25,7 @@ const rulesList = require("./rule-list"); const allRules = {}; -const recommendedRules = {}; // recommended rules +const recommendedRules = {}; for (let { ruleName, ruleModule } of rulesList) { allRules[ruleName] = ruleModule; From 230c6e54fb939495fd99fced9df8456b51d0604e Mon Sep 17 00:00:00 2001 From: Alexandre Morgaut <49318+AMorgaut@users.noreply.github.com> Date: Fri, 18 Oct 2024 09:20:40 +0000 Subject: [PATCH 8/9] fix: revert package version change --- eslint-plugin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eslint-plugin/package.json b/eslint-plugin/package.json index 9a39e9e..d149025 100644 --- a/eslint-plugin/package.json +++ b/eslint-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@ecocode/eslint-plugin", - "version": "1.6.0", + "version": "1.5.0", "description": "JavaScript linter of ecoCode project", "keywords": [ "eslint", From aa8c858d58a5ce442c1419b4479d1a92c88c1831 Mon Sep 17 00:00:00 2001 From: Alexandre Morgaut <49318+AMorgaut@users.noreply.github.com> Date: Fri, 18 Oct 2024 20:12:05 +0000 Subject: [PATCH 9/9] doc: update config titles --- eslint-plugin/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/eslint-plugin/README.md b/eslint-plugin/README.md index 4069379..7ba84a4 100644 --- a/eslint-plugin/README.md +++ b/eslint-plugin/README.md @@ -38,7 +38,7 @@ npm install -D eslint @green-code-initiative/ecocode-eslint-plugin ### Enable plugin with recommended configuration -#### With modern `eslint.config.js` +#### ESLint Flat Configuration (`eslint.config.js`) Add `@ecocode` **"flat/recommended"** configuration to your `eslint.config.js`: @@ -51,9 +51,9 @@ export default [ ] ``` -#### With the legacy `.eslintrc` +#### ESLint deprecated legacy configuration (`.eslintrc`) -Add `@ecocode` **"recommended"** configuration to `extends` section of your `.eslintrc`: +For legacy ESLint versions using the deprecated `.eslintrc` file, add the `@ecocode` **"recommended"** configuration to the `extends` array : ```json { @@ -63,7 +63,7 @@ Add `@ecocode` **"recommended"** configuration to `extends` section of your `.es ### Enable specific rules -#### With modern `eslint.config.js` +#### ESLint Flat configuration (`eslint.config.js`) Add the `ecocode` plugin configuration to your `eslint.config.js` and select the rules to activate: @@ -81,9 +81,9 @@ export default [ ] ``` -#### With the legacy `.eslintrc` +#### ESLint deprecated legacy configuration (`.eslintrc`) -Add `@ecocode` to the `plugins` section of your `.eslintrc`, followed by rules configuration: +If your project uses a legacy ESLint version, it may use as well the now deprecated `.eslintrc` file. In such case, Add `@ecocode` to the `plugins` array, potentially followed by rules specific configurations: ```jsonc {