Skip to content

Commit

Permalink
fix: convert README template usage to flat (#194)
Browse files Browse the repository at this point in the history
* fix: convert README template usage to flat

* update tests/plugin/index.js

* remove comment about omitting prefix

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>

* add import to usage instructions

---------

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
  • Loading branch information
MikeMcC399 and mdjermanovic authored Oct 19, 2024
1 parent e0bbfd4 commit 779340a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
41 changes: 26 additions & 15 deletions plugin/templates/_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,36 @@ 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:

```json
{
"plugins": [
"<%= pluginId %>"
]
}
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
import <%= pluginId %> from "eslint-plugin-<%= pluginId %>";

export default [
{
plugins: {
<%= pluginId %>
}
}
];
```

<% if (hasRules) { %>
Then configure the rules you want to use under the rules section.

```json
{
"rules": {
"<%= pluginId %>/rule-name": 2
Then configure the rules you want to use under the `rules` key.

```js
import <%= pluginId %> from "eslint-plugin-<%= pluginId %>";

export default [
{
plugins: {
<%= pluginId %>
},
rules: {
"<%= pluginId %>/rule-name": "warn"
}
}
}
];
```

<% } %>
Expand Down
6 changes: 3 additions & 3 deletions tests/plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -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\"");
});
});

Expand Down

0 comments on commit 779340a

Please sign in to comment.