From 20d36642d25678c76331efe012e8ad56ef4ec67d Mon Sep 17 00:00:00 2001 From: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Date: Sat, 19 Oct 2024 09:05:42 +0200 Subject: [PATCH 1/4] fix: convert README template usage to flat --- plugin/templates/_README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugin/templates/_README.md b/plugin/templates/_README.md index aad75f2..d351f71 100644 --- a/plugin/templates/_README.md +++ b/plugin/templates/_README.md @@ -18,23 +18,23 @@ npm install eslint-plugin-<%= pluginId %> --save-dev ## Usage -Add `<%= pluginId %>` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix: +Add `<%= pluginId %>` to the `plugins` key of your [configuration file](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file). You can omit the `eslint-plugin-` prefix: -```json +```js { - "plugins": [ + plugins: { "<%= pluginId %>" - ] + } } ``` <% if (hasRules) { %> -Then configure the rules you want to use under the rules section. +Then configure the rules you want to use under the `rules` key. -```json +```js { - "rules": { - "<%= pluginId %>/rule-name": 2 + rules: { + "<%= pluginId %>/rule-name": "warn" } } ``` From 2dfd66eb32b56a018d19bdce1a258f8b6126af0f Mon Sep 17 00:00:00 2001 From: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Date: Sat, 19 Oct 2024 09:34:46 +0200 Subject: [PATCH 2/4] update tests/plugin/index.js --- tests/plugin/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/plugin/index.js b/tests/plugin/index.js index 34ce856..caa6530 100644 --- a/tests/plugin/index.js +++ b/tests/plugin/index.js @@ -57,9 +57,9 @@ describe("ESLint Plugin Generator", () => { assert.fileContent("README.md", "# eslint-plugin-foo-bar"); assert.fileContent("README.md", "Next, install `eslint-plugin-foo-bar`:"); assert.fileContent("README.md", "npm install eslint-plugin-foo-bar --save-dev"); - assert.fileContent("README.md", "Add `foo-bar` to the plugins section"); + assert.fileContent("README.md", "Add `foo-bar` to the `plugins` key"); - assert.noFileContent("README.md", "Then configure the rules you want to use under the rules section."); + assert.noFileContent("README.md", "Then configure the rules you want to use under the `rules` key."); }); it("has correct lib/index.js", () => { @@ -102,7 +102,7 @@ describe("ESLint Plugin Generator", () => { }); it("has correct README.md", () => { - assert.fileContent("README.md", "\"foo-bar/rule-name\": 2"); + assert.fileContent("README.md", "\"foo-bar/rule-name\": \"warn\""); }); }); From b2f801c53b971fba50b6ec96180eba552c5396e7 Mon Sep 17 00:00:00 2001 From: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Date: Sat, 19 Oct 2024 12:24:55 +0200 Subject: [PATCH 3/4] remove comment about omitting prefix Co-authored-by: Milos Djermanovic --- plugin/templates/_README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/templates/_README.md b/plugin/templates/_README.md index d351f71..dbc4142 100644 --- a/plugin/templates/_README.md +++ b/plugin/templates/_README.md @@ -18,7 +18,7 @@ npm install eslint-plugin-<%= pluginId %> --save-dev ## Usage -Add `<%= pluginId %>` to the `plugins` key of your [configuration file](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file). You can omit the `eslint-plugin-` prefix: +Add `<%= pluginId %>` to the `plugins` key of your [configuration file](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file): ```js { From 471f2d33d7f786f4667f36bdc4a0479013ba67b3 Mon Sep 17 00:00:00 2001 From: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Date: Sat, 19 Oct 2024 12:37:16 +0200 Subject: [PATCH 4/4] add import to usage instructions --- plugin/templates/_README.md | 29 ++++++++++++++++++++--------- tests/plugin/index.js | 2 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/plugin/templates/_README.md b/plugin/templates/_README.md index dbc4142..0653974 100644 --- a/plugin/templates/_README.md +++ b/plugin/templates/_README.md @@ -18,25 +18,36 @@ npm install eslint-plugin-<%= pluginId %> --save-dev ## Usage -Add `<%= pluginId %>` to the `plugins` key of your [configuration file](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file): +In your [configuration file](https://eslint.org/docs/latest/use/configure/configuration-files#configuration-file), import the plugin `eslint-plugin-<%= pluginId %>` and add `<%= pluginId %>` to the `plugins` key: ```js -{ - plugins: { - "<%= pluginId %>" +import <%= pluginId %> from "eslint-plugin-<%= pluginId %>"; + +export default [ + { + plugins: { + <%= pluginId %> + } } -} +]; ``` <% if (hasRules) { %> Then configure the rules you want to use under the `rules` key. ```js -{ - rules: { - "<%= pluginId %>/rule-name": "warn" +import <%= pluginId %> from "eslint-plugin-<%= pluginId %>"; + +export default [ + { + plugins: { + <%= pluginId %> + }, + rules: { + "<%= pluginId %>/rule-name": "warn" + } } -} +]; ``` <% } %> diff --git a/tests/plugin/index.js b/tests/plugin/index.js index caa6530..223e713 100644 --- a/tests/plugin/index.js +++ b/tests/plugin/index.js @@ -57,7 +57,7 @@ describe("ESLint Plugin Generator", () => { assert.fileContent("README.md", "# eslint-plugin-foo-bar"); assert.fileContent("README.md", "Next, install `eslint-plugin-foo-bar`:"); assert.fileContent("README.md", "npm install eslint-plugin-foo-bar --save-dev"); - assert.fileContent("README.md", "Add `foo-bar` to the `plugins` key"); + assert.fileContent("README.md", "add `foo-bar` to the `plugins` key"); assert.noFileContent("README.md", "Then configure the rules you want to use under the `rules` key."); });