Skip to content

Commit

Permalink
chore: use eslint-plugin-eslint-plugin (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic authored Nov 22, 2024
1 parent 2f02c74 commit 6f662aa
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 14 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ export default [
<!-- Rule Table Start -->
| **Rule Name** | **Description** | **Recommended** |
| :- | :- | :-: |
| [`fenced-code-language`](./docs/rules/fenced-code-language.md) | Require languages for fenced code blocks. | yes |
| [`heading-increment`](./docs/rules/heading-increment.md) | Enforce heading levels increment by one. | yes |
| [`no-duplicate-headings`](./docs/rules/no-duplicate-headings.md) | Disallow duplicate headings in the same document. | no |
| [`no-empty-links`](./docs/rules/no-empty-links.md) | Disallow empty links. | yes |
| [`no-html`](./docs/rules/no-html.md) | Disallow HTML tags. | no |
| [`no-invalid-label-refs`](./docs/rules/no-invalid-label-refs.md) | Disallow invalid label references. | yes |
| [`no-missing-label-refs`](./docs/rules/no-missing-label-refs.md) | Disallow missing label references. | yes |
| [`fenced-code-language`](./docs/rules/fenced-code-language.md) | Require languages for fenced code blocks | yes |
| [`heading-increment`](./docs/rules/heading-increment.md) | Enforce heading levels increment by one | yes |
| [`no-duplicate-headings`](./docs/rules/no-duplicate-headings.md) | Disallow duplicate headings in the same document | no |
| [`no-empty-links`](./docs/rules/no-empty-links.md) | Disallow empty links | yes |
| [`no-html`](./docs/rules/no-html.md) | Disallow HTML tags | no |
| [`no-invalid-label-refs`](./docs/rules/no-invalid-label-refs.md) | Disallow invalid label references | yes |
| [`no-missing-label-refs`](./docs/rules/no-missing-label-refs.md) | Disallow missing label references | yes |
<!-- Rule Table End -->

**Note:** This plugin does not provide formatting rules. We recommend using a source code formatter such as [Prettier](https://prettier.io) for that purpose.
Expand Down
54 changes: 54 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
//-----------------------------------------------------------------------------
// Imports
//-----------------------------------------------------------------------------

import globals from "globals";
import eslintConfigESLint from "eslint-config-eslint";
import eslintPlugin from "eslint-plugin-eslint-plugin";
import markdown from "./src/index.js";

//-----------------------------------------------------------------------------
// Helpers
//-----------------------------------------------------------------------------

const eslintPluginRulesRecommendedConfig =
eslintPlugin.configs["flat/rules-recommended"];
const eslintPluginTestsRecommendedConfig =
eslintPlugin.configs["flat/tests-recommended"];

//-----------------------------------------------------------------------------
// Configuration
//-----------------------------------------------------------------------------

export default [
...eslintConfigESLint,
{
Expand Down Expand Up @@ -73,4 +91,40 @@ export default [
"jsdoc/require-jsdoc": "off",
},
},
{
files: ["src/rules/*.js"],
...eslintPluginRulesRecommendedConfig,
rules: {
...eslintPluginRulesRecommendedConfig.rules,
"eslint-plugin/require-meta-schema": "off", // `schema` defaults to []
"eslint-plugin/prefer-placeholders": "error",
"eslint-plugin/prefer-replace-text": "error",
"eslint-plugin/report-message-format": ["error", "[^a-z].*\\.$"],
"eslint-plugin/require-meta-docs-description": [
"error",
{ pattern: "^(Enforce|Require|Disallow) .+[^. ]$" },
],
},
},
{
files: ["tests/rules/*.test.js"],
...eslintPluginTestsRecommendedConfig,
rules: {
...eslintPluginTestsRecommendedConfig.rules,
"eslint-plugin/test-case-property-ordering": [
"error",
[
"name",
"filename",
"code",
"output",
"language",
"options",
"languageOptions",
"errors",
],
],
"eslint-plugin/test-case-shorthand-strings": "error",
},
},
];
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"dedent": "^1.5.3",
"eslint": "^9.15.0",
"eslint-config-eslint": "^11.0.0",
"eslint-plugin-eslint-plugin": "^6.3.2",
"globals": "^15.1.0",
"got": "^14.4.2",
"lint-staged": "^15.2.9",
Expand Down
2 changes: 1 addition & 1 deletion src/rules/fenced-code-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {

docs: {
recommended: true,
description: "Require languages for fenced code blocks.",
description: "Require languages for fenced code blocks",
},

messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/heading-increment.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {

docs: {
recommended: true,
description: "Enforce heading levels increment by one.",
description: "Enforce heading levels increment by one",
},

messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-duplicate-headings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default {
type: "problem",

docs: {
description: "Disallow duplicate headings in the same document.",
description: "Disallow duplicate headings in the same document",
},

messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-empty-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default {

docs: {
recommended: true,
description: "Disallow empty links.",
description: "Disallow empty links",
},

messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default {
type: "problem",

docs: {
description: "Disallow HTML tags.",
description: "Disallow HTML tags",
},

messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-invalid-label-refs.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default {

docs: {
recommended: true,
description: "Disallow invalid label references.",
description: "Disallow invalid label references",
},

messages: {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-missing-label-refs.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default {

docs: {
recommended: true,
description: "Disallow missing label references.",
description: "Disallow missing label references",
},

messages: {
Expand Down

0 comments on commit 6f662aa

Please sign in to comment.