@pob/eslint-config 56.1.0 → 57.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,98 +3,26 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [51.0.2](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-09-01)
7
- ## [51.1.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-10-03)
8
-
9
- ### Bug Fixes
10
-
11
- * fix react/function-component-definition rule and enable func-names ([e656eba](https://github.com/christophehurpeau/eslint-config-pob/commit/e656ebaba4639a0eb547ef11dc9d3fbf32aec60e))
12
- ## [51.1.1](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-10-18)
13
-
14
- ### Bug Fixes
15
-
16
- * fix no-restricted-exports rule ([a1dd956](https://github.com/christophehurpeau/eslint-config-pob/commit/a1dd956448099f77f3adadca1ce031044a3a4492))
17
- ## [51.1.2](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-10-19)
18
- ## [51.2.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-12-10)
19
- ## [51.2.2](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-12-14)
20
- ## [52.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-12-28)
21
-
22
- ### ⚠ BREAKING CHANGES
23
-
24
- * change import/extensions to ignorePackages
6
+ ## [57.1.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v57.0.0...v57.1.0) (2024-08-11)
25
7
 
26
8
  ### Features
27
9
 
28
- * change import/extensions to ignorePackages ([1833642](https://github.com/christophehurpeau/eslint-config-pob/commit/183364280552d484acd37bbf3b9816d88c1f6bfe))
29
- ## [52.0.1](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-12-28)
30
-
31
- ### Reverts
32
-
33
- * Revert "feat!: change import/extensions to ignorePackages" ([22d14bc](https://github.com/christophehurpeau/eslint-config-pob/commit/22d14bc6d6f94cae03a547cf53d939f6c1c756a7))
34
- ## [53.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2023-12-28)
35
-
36
- ### ⚠ BREAKING CHANGES
37
-
38
- * feat: change import/extensions to ignorePackages
39
-
40
- ### Reverts
41
-
42
- * feat: change import/extensions to ignorePackages ([0a15b9e](https://github.com/christophehurpeau/eslint-config-pob/commit/0a15b9e80b990a8f6277a1bd19481a9fe72f3f22))
43
- ## [54.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-02-17)
44
-
45
- ### ⚠ BREAKING CHANGES
46
-
47
- * replace eslint-plugin-node by eslint-plugin-n
48
-
49
- ### Features
10
+ * add names ([8b169fe](https://github.com/christophehurpeau/eslint-config-pob/commit/8b169fe50a73477a449ab0cdb40acf9d9d9bf538))
50
11
 
51
- * replace eslint-plugin-node by eslint-plugin-n ([7d9764c](https://github.com/christophehurpeau/eslint-config-pob/commit/7d9764cf80fffcd4381056624eb06887a3d86e3f))
52
- ## [54.0.1](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-02-24)
53
- ## [55.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-04-20)
12
+ ## [57.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.1.0...v57.0.0) (2024-08-11)
54
13
 
55
14
  ### ⚠ BREAKING CHANGES
56
15
 
57
- * remove eslint-config-airbnb-base
58
-
59
- ### Features
60
-
61
- * remove eslint-config-airbnb-base ([295a348](https://github.com/christophehurpeau/eslint-config-pob/commit/295a34808018f395e22d935772ac9e614bc6bd47))
62
- ## [55.0.1](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-04-21)
63
-
64
- ### Bug Fixes
65
-
66
- * properly configure module vs commonjs ([8ae7ffd](https://github.com/christophehurpeau/eslint-config-pob/commit/8ae7ffdb3b37f1ec898b4ce8694420253ff3260d))
67
- ## [55.1.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-04-21)
68
-
69
- ### Features
70
-
71
- * remove max-lines ([38d7fda](https://github.com/christophehurpeau/eslint-config-pob/commit/38d7fdaa36f40a6f7434fea242bf6a72bef4bcca))
72
- ## [55.2.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-04-21)
16
+ * use flat config
73
17
 
74
18
  ### Features
75
19
 
76
- * enable max-params ([93f60a1](https://github.com/christophehurpeau/eslint-config-pob/commit/93f60a12ffa4a94a8adf0f74866c8f2c81c37c2e))
77
- ## [55.2.1](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-04-21)
20
+ * add baseModule ([c1e7cef](https://github.com/christophehurpeau/eslint-config-pob/commit/c1e7cef19d835b3ab0333b4588d1810e09874d53))
21
+ * use flat config ([b0bda47](https://github.com/christophehurpeau/eslint-config-pob/commit/b0bda47976ec40a30679988c603d425f9b75346f))
78
22
 
79
- ### Bug Fixes
80
-
81
- * remove generator-star-spacing ([a9bf679](https://github.com/christophehurpeau/eslint-config-pob/commit/a9bf679717e27b3e3cb86c25af17d89cae205f59))
82
- ## [55.3.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-05-05)
83
-
84
- ### Features
85
-
86
- * change curly to warn and add test ([83e0e27](https://github.com/christophehurpeau/eslint-config-pob/commit/83e0e27dbb8f6403cc18862fff606ae517fe2dbb))
87
- * change quote rule to warn and add test ([a4a5ba2](https://github.com/christophehurpeau/eslint-config-pob/commit/a4a5ba20269fc0c78c3672867c56a87de1f791dd))
88
- * remove optional peer dependencies ([ddddeb2](https://github.com/christophehurpeau/eslint-config-pob/commit/ddddeb27d606f16dbf6c38b2f61c3a7bfe20510d))
89
- ## [56.0.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-05-05)
90
-
91
- ### ⚠ BREAKING CHANGES
92
-
93
- * use standard quotes
23
+ Version bump for dependency: @pob/eslint-plugin
94
24
 
95
- ### Features
96
25
 
97
- * use standard quotes ([0083d81](https://github.com/christophehurpeau/eslint-config-pob/commit/0083d816bbe4e320eabe3c23a8d4edaa561df8a3))
98
26
  ## [56.1.0](https://github.com/christophehurpeau/eslint-config-pob/compare/v56.0.0...v56.1.0) (2024-07-27)
99
27
 
100
28
  ### Features
@@ -606,7 +534,7 @@ Note: no notable changes
606
534
 
607
535
  ### BREAKING CHANGES
608
536
 
609
- * **deps:** requires eslint-plugin-unicorn 34 and enable new rules
537
+ * **deps:** requires eslint-plugin-unicorn 34 and enable new rules
610
538
  * requires new min supported node versions
611
539
 
612
540
 
package/lib/_base.js CHANGED
@@ -1,18 +1,40 @@
1
- "use strict";
1
+ import js from "@eslint/js";
2
+ import pobPlugin from "@pob/eslint-plugin";
3
+ import unicornPluginConfigs from "./plugins/unicorn.js";
4
+ import bestPracticesConfig from "./rules/best-practices.js";
5
+ import codeQualityConfig from "./rules/code-quality.js";
6
+ import devOnlyConfig from "./rules/dev-only.js";
7
+ import errorsConfig from "./rules/errors.js";
8
+ import styleConfig from "./rules/style.js";
2
9
 
3
- module.exports = {
4
- extends: [
5
- "eslint:recommended",
6
- "plugin:@pob/base",
7
- ...[
8
- "./plugins/unicorn",
9
- "./rules/best-practices",
10
- "./rules/code-quality",
11
- "./rules/errors",
12
- "./rules/style",
13
- "./plugins/import/import-base",
14
- "./plugins/import/import-commonjs",
15
- ].map(require.resolve),
16
- ],
17
- plugins: ["@pob/eslint-plugin"],
18
- };
10
+ export default [
11
+ {
12
+ linterOptions: {
13
+ // todo noInlineConfig: true,
14
+ reportUnusedDisableDirectives: "error",
15
+ },
16
+ plugins: {
17
+ "@pob": pobPlugin,
18
+ },
19
+ },
20
+ {
21
+ ignores: [".yarn", "**/dist/", "**/build/", "**/coverage/"],
22
+ },
23
+ js.configs.recommended,
24
+ pobPlugin.configs.base,
25
+ ...unicornPluginConfigs,
26
+ bestPracticesConfig,
27
+ codeQualityConfig,
28
+ errorsConfig,
29
+ styleConfig,
30
+ devOnlyConfig,
31
+
32
+ // TODO
33
+ // {
34
+ // files: ["*.json"],
35
+ // languageOptions: {
36
+ // parser: jsoncParser,
37
+ // },
38
+ // rules: {},
39
+ // },
40
+ ];
@@ -1,10 +1,15 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- parserOptions: {
1
+ export default {
2
+ name: "@pob/eslint-config/base/commonjs",
3
+ languageOptions: {
5
4
  sourceType: "script",
6
5
  },
7
6
  rules: {
8
7
  strict: ["error", "safe"],
8
+
9
+ // https://eslint.org/docs/rules/global-require
10
+ "global-require": "error",
11
+
12
+ // disallow use of new operator with the require function
13
+ "no-new-require": "error",
9
14
  },
10
15
  };
@@ -1,10 +1,29 @@
1
- "use strict";
2
-
3
- module.exports = {
4
- parserOptions: {
1
+ export default {
2
+ name: "@pob/eslint-config/base/module",
3
+ languageOptions: {
5
4
  sourceType: "module",
6
5
  },
7
6
  rules: {
8
7
  strict: "off",
8
+
9
+ // replaced by import/no-duplicates
10
+ "no-duplicate-imports": "off",
11
+
12
+ // https://eslint.org/docs/rules/no-restricted-exports
13
+ "no-restricted-exports": [
14
+ "error",
15
+ {
16
+ restrictDefaultExports: {
17
+ direct: false, // permits `export default` declarations
18
+ named: true, // restricts `export { foo as default };` declarations
19
+ defaultFrom: false, // permits `export { default } from 'foo';` declarations
20
+ namedFrom: false, // permits `export { foo as default } from 'foo';` declarations
21
+ namespaceFrom: true, // restricts `export * as default from 'foo';` declarations
22
+ },
23
+ restrictedNamedExports: [
24
+ "then", // this will cause tons of confusion when your module is dynamically `import()`ed, and will break in most node ESM versions
25
+ ],
26
+ },
27
+ ],
9
28
  },
10
29
  };
package/lib/index.js CHANGED
@@ -1,20 +1,74 @@
1
- "use strict";
1
+ import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { FlatCompat } from "@eslint/eslintrc";
4
+ import baseConfigs from "./_base.js";
5
+ import baseCommonjsConfig from "./base/commonjs.js";
6
+ import baseModuleConfig from "./base/module.js";
7
+ import nodePluginCommonjsConfigs from "./node/commonjs.js";
8
+ import nodePluginModuleConfigs from "./node/module.js";
9
+ import importPluginBaseConfigs from "./plugins/import/import-base.js";
10
+ import importPluginCommonjsConfig from "./plugins/import/import-commonjs.js";
11
+ import importPluginModuleConfig from "./plugins/import/import-module.js";
2
12
 
3
- module.exports = {
4
- extends: ["./_base", "./base/commonjs"].map(require.resolve),
13
+ export default (url) => {
14
+ const __filename = fileURLToPath(url);
15
+ const __dirname = path.dirname(__filename);
5
16
 
6
- overrides: [
17
+ const compat = new FlatCompat({
18
+ baseDirectory: __dirname,
19
+ });
20
+
21
+ const nodeCommonjs = [
22
+ ...baseConfigs,
23
+ baseCommonjsConfig,
24
+ ...importPluginBaseConfigs(compat),
25
+ importPluginCommonjsConfig,
26
+ ...nodePluginCommonjsConfigs,
27
+
28
+ {
29
+ files: ["**/*.mjs"],
30
+ ...baseModuleConfig,
31
+ },
32
+ {
33
+ files: ["**/*.mjs"],
34
+ ...importPluginModuleConfig,
35
+ },
36
+ ...nodePluginModuleConfigs.map((config) => ({
37
+ ...config,
38
+ files: ["**/*.mjs"],
39
+ })),
40
+ ];
41
+
42
+ const baseModule = [
43
+ ...baseConfigs,
44
+ baseModuleConfig,
45
+ ...importPluginBaseConfigs(compat),
46
+ importPluginModuleConfig,
7
47
  {
8
- files: ["*.mjs"],
9
- extends: ["./base/module", "./plugins/import/import-module"].map(
10
- require.resolve,
11
- ),
48
+ files: ["**/*.cjs"],
49
+ ...baseCommonjsConfig,
12
50
  },
13
51
  {
14
- files: ["*.cjs"],
15
- extends: ["./base/commonjs", "./plugins/import/import-commonjs"].map(
16
- require.resolve,
17
- ),
52
+ files: ["**/*.cjs"],
53
+ ...importPluginCommonjsConfig,
54
+ },
55
+ ];
56
+
57
+ const nodeModule = [
58
+ ...baseModule,
59
+ ...nodePluginModuleConfigs,
60
+ ...nodePluginCommonjsConfigs.map((config) => ({
61
+ ...config,
62
+ files: ["**/*.cjs"],
63
+ })),
64
+ ];
65
+
66
+ return {
67
+ compat,
68
+ configs: {
69
+ baseModule,
70
+ nodeModule,
71
+ nodeCommonjs,
18
72
  },
19
- ],
73
+ };
20
74
  };
package/lib/node/_base.js CHANGED
@@ -1,6 +1,4 @@
1
- "use strict";
2
-
3
- exports.overrideRules = {
1
+ export const overrideRules = {
4
2
  // Disable rules already checked by import plugin
5
3
  "n/no-unpublished-require": "off",
6
4
  "n/no-extraneous-require": "off",
@@ -25,19 +23,13 @@ exports.overrideRules = {
25
23
  "no-sync": "off",
26
24
 
27
25
  // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/import/extensions.md
28
- "import/extensions": [
29
- "error",
30
- "ignorePackages",
31
- {
32
- mjs: "always",
33
- cjs: "always",
34
- js: "never",
35
- },
36
- ],
37
- };
38
-
39
- exports.env = {
40
- browser: false,
41
- node: true,
42
- es6: true,
26
+ // "import/extensions": [
27
+ // "error",
28
+ // "ignorePackages",
29
+ // {
30
+ // mjs: "always",
31
+ // cjs: "always",
32
+ // js: "never",
33
+ // },
34
+ // ],
43
35
  };
@@ -1,24 +1,15 @@
1
- "use strict";
2
-
3
- const { env, overrideRules } = require("./_base");
4
-
5
- module.exports = {
6
- plugins: ["n"],
7
- extends: ["plugin:n/recommended-script"],
8
- env,
9
-
10
- parserOptions: {
11
- // https://node.green/#ES2020
12
- // most 2020 features are supported in node 14
13
- // top level await is introduced in 2022
14
- // current ecmaVersion in eslint-plugin-node is 2019
15
- ecmaVersion: 2022,
16
- },
17
-
18
- rules: {
19
- ...overrideRules,
20
- "unicorn/prefer-module": "off",
21
- "n/no-new-require": "error",
22
- "n/no-path-concat": "error",
1
+ import nodePlugin from "eslint-plugin-n";
2
+ import { overrideRules } from "./_base.js";
3
+
4
+ export default [
5
+ nodePlugin.configs["flat/recommended-script"],
6
+ {
7
+ name: "@pob/eslint-config/node/commonjs",
8
+ rules: {
9
+ ...overrideRules,
10
+ // "unicorn/prefer-module": "off",
11
+ "n/no-new-require": "error",
12
+ "n/no-path-concat": "error",
13
+ },
23
14
  },
24
- };
15
+ ];
@@ -1,33 +1,25 @@
1
- "use strict";
1
+ import nodePlugin from "eslint-plugin-n";
2
+ import { overrideRules } from "./_base.js";
2
3
 
3
- const { env, overrideRules } = require("./_base");
4
+ export default [
5
+ nodePlugin.configs["flat/recommended-module"],
6
+ {
7
+ name: "@pob/eslint-config/node/module",
8
+ rules: {
9
+ ...overrideRules,
10
+ "unicorn/prefer-module": "error",
11
+ "unicorn/import-index": "off",
4
12
 
5
- module.exports = {
6
- plugins: ["n"],
7
- extends: ["plugin:n/recommended-module"],
8
- parserOptions: {
9
- sourceType: "module",
10
- // https://node.green/#ES2020
11
- // most 2020 features are supported in node 14
12
- // top level await is introduced in 2022
13
- // current ecmaVersion in eslint-plugin-node is 2019
14
- ecmaVersion: 2022,
13
+ // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/import/extensions.md
14
+ "import/extensions": [
15
+ "error",
16
+ "ignorePackages",
17
+ {
18
+ mjs: "always",
19
+ cjs: "always",
20
+ js: "always",
21
+ },
22
+ ],
23
+ },
15
24
  },
16
- env,
17
- rules: {
18
- ...overrideRules,
19
- "unicorn/prefer-module": "error",
20
- "unicorn/import-index": "off",
21
-
22
- // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/import/extensions.md
23
- "import/extensions": [
24
- "error",
25
- "ignorePackages",
26
- {
27
- mjs: "always",
28
- cjs: "always",
29
- js: "always",
30
- },
31
- ],
32
- },
33
- };
25
+ ];