Skip to content

Commit

Permalink
chore: move the configs to separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add committed Apr 21, 2023
1 parent c446dd1 commit 41e83ec
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 20 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Here's an example ESLint configuration that:
* Enables the `recommended` configuration
* Enables an optional/non-recommended rule

### <a name='eslintrc'></a>eslintrc
```json
{
"parserOptions": {
Expand All @@ -52,6 +53,20 @@ Here's an example ESLint configuration that:
}
```

### <a name='flat'></a>`eslint.config.js`
```js
const eslintPluginRecommended = require("eslint-plugin-eslint-plugin/configs/recommended");
module.exports = [
eslintPluginRecommended,
{
languageOptions: {sourceType: "commonjs"},
rules: {
"eslint-plugin/require-meta-docs-description": "error"

Check failure on line 64 in README.md

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma

Check failure on line 64 in README.md

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
}

Check failure on line 65 in README.md

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma

Check failure on line 65 in README.md

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
}

Check failure on line 66 in README.md

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma

Check failure on line 66 in README.md

View workflow job for this annotation

GitHub Actions / lint

Missing trailing comma
];
```

## <a name='Rules'></a>Rules

<!-- begin auto-generated rules list -->
Expand Down
13 changes: 13 additions & 0 deletions configs/all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @fileoverview the `all` config for `eslint.config.js`
* @author 唯然<weiran.zsd@outlook.com>
*/

'use strict';

const { configs, rules } = require('../lib/index.js');

module.exports = {
plugins: { 'eslint-plugin': { rules } },
rules: configs.all.rules,
};
18 changes: 0 additions & 18 deletions configs/index.js

This file was deleted.

13 changes: 13 additions & 0 deletions configs/recommended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @fileoverview the `recommended` config for `eslint.config.js`
* @author 唯然<weiran.zsd@outlook.com>
*/

'use strict';

const { configs, rules } = require('../lib/index.js');

module.exports = {
plugins: { 'eslint-plugin': { rules } },
rules: configs.recommended.rules,
};
13 changes: 13 additions & 0 deletions configs/rules-recommended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @fileoverview the `rules-recommended` config for `eslint.config.js`
* @author 唯然<weiran.zsd@outlook.com>
*/

'use strict';

const { configs, rules } = require('../lib/index.js');

module.exports = {
plugins: { 'eslint-plugin': { rules } },
rules: configs['rules-recommended'].rules,
};
13 changes: 13 additions & 0 deletions configs/rules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @fileoverview the `rules` config for `eslint.config.js`
* @author 唯然<weiran.zsd@outlook.com>
*/

'use strict';

const { configs, rules } = require('../lib/index.js');

module.exports = {
plugins: { 'eslint-plugin': { rules } },
rules: configs.rules.rules,
};
13 changes: 13 additions & 0 deletions configs/tests-recommended.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @fileoverview the `tests-recommended` config for `eslint.config.js`
* @author 唯然<weiran.zsd@outlook.com>
*/

'use strict';

const { configs, rules } = require('../lib/index.js');

module.exports = {
plugins: { 'eslint-plugin': { rules } },
rules: configs['tests-recommended'].rules,
};
13 changes: 13 additions & 0 deletions configs/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @fileoverview the `tests` config for `eslint.config.js`
* @author 唯然<weiran.zsd@outlook.com>
*/

'use strict';

const { configs, rules } = require('../lib/index.js');

module.exports = {
plugins: { 'eslint-plugin': { rules } },
rules: configs.tests.rules,
};
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const js = require('@eslint/js');
const { FlatCompat } = require('@eslint/eslintrc');
const globals = require('globals');
const markdown = require('eslint-plugin-markdown');
const eslintPluginConfig = require('eslint-plugin-eslint-plugin/configs').all;
const eslintPluginConfig = require('eslint-plugin-eslint-plugin/configs/all');

const compat = new FlatCompat({
baseDirectory: __dirname,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "./lib/index.js",
"exports": {
".": "./lib/index.js",
"./configs": "./configs/index.js",
"./configs/*": "./configs/*.js",
"./package.json": "./package.json"
},
"license": "MIT",
Expand Down

0 comments on commit 41e83ec

Please sign in to comment.