Skip to content

Commit

Permalink
chore: update eslint-config-eslint export
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed Jul 3, 2023
1 parent 1fc50a8 commit 777d28b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 18 deletions.
3 changes: 2 additions & 1 deletion eslint.config.js
Expand Up @@ -75,7 +75,8 @@ function createInternalFilesPatterns(pattern = null) {
}

module.exports = [
...baseConfig,
...baseConfig.base,
baseConfig.commonjs,
{
ignores: [
"build/**",
Expand Down
16 changes: 14 additions & 2 deletions packages/eslint-config-eslint/README.md
Expand Up @@ -25,8 +25,20 @@ npm install eslint-config-eslint --save-dev
In your `eslint.config.js` file, add:

```js
const eslintConfig = require("eslint-config-eslint");
module.exports = eslintConfig;
// ESM project
import eslintConfigEslint from "eslint-config-eslint";

export default [
...eslintConfigEslint.base,
{
files: ["**/*.js"],
...eslintConfigEslint.esm
},
{
files: ["**/*.cjs"],
...eslintConfigEslint.commonjs
}
];
```

### Where to ask for help?
Expand Down
45 changes: 30 additions & 15 deletions packages/eslint-config-eslint/index.js
@@ -1,6 +1,7 @@
"use strict";

const nodeRecommendedConfig = require("eslint-plugin-n/configs/recommended-script");
const nodeRecommendedScriptConfig = require("eslint-plugin-n/configs/recommended-script");
const nodeRecommendedModuleConfig = require("eslint-plugin-n/configs/recommended-module");
const js = require("@eslint/js");
const jsdoc = require("eslint-plugin-jsdoc");
const eslintComments = require("eslint-plugin-eslint-comments");
Expand All @@ -13,17 +14,28 @@ const unicorn = require("eslint-plugin-unicorn");
jsdoc.configs.recommended.plugins = { jsdoc };
eslintComments.configs.recommended.plugins = { "eslint-comments": eslintComments };

// extends eslint-plugin-n's recommended config
const nodeConfigs = [nodeRecommendedConfig, {
// extends eslint-plugin-n's config
const nodeSharedRules = {
"n/callback-return": ["error", ["cb", "callback", "next"]],
"n/handle-callback-err": ["error", "err"]
};
const nodeCommonJSConfig = {
...nodeRecommendedScriptConfig,
rules: {
"n/callback-return": ["error", ["cb", "callback", "next"]],
"n/handle-callback-err": ["error", "err"],
"n/no-deprecated-api": "error",
...nodeRecommendedScriptConfig.rules,
...nodeSharedRules,
"n/no-mixed-requires": "error",
"n/no-new-require": "error",
"n/no-path-concat": "error"
}
}];
};
const nodeESMConfig = {
...nodeRecommendedModuleConfig,
rules: {
...nodeRecommendedModuleConfig.rules,
...nodeSharedRules
}
};

// extends eslint recommended config
const jsConfigs = [js.configs.recommended, {
Expand Down Expand Up @@ -390,11 +402,14 @@ const eslintCommentsConfigs = [eslintComments.configs.recommended, {
}
}];

module.exports = [
{ linterOptions: { reportUnusedDisableDirectives: true } },
...jsConfigs,
...nodeConfigs,
...unicornConfigs,
...jsdocConfigs,
...eslintCommentsConfigs
];
module.exports = {
base: [
{ linterOptions: { reportUnusedDisableDirectives: true } },
...jsConfigs,
...unicornConfigs,
...jsdocConfigs,
...eslintCommentsConfigs
],
commonjs: nodeCommonJSConfig,
esm: nodeESMConfig
};

0 comments on commit 777d28b

Please sign in to comment.