eslint-config-reverentgeek 6.2.0 → 6.3.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/README.md CHANGED
@@ -17,68 +17,44 @@ This package is [ReverentGeek's](https://reverentgeek.com/about/) preferred conf
17
17
  ```js
18
18
  "use strict";
19
19
 
20
- /* eslint-disable-next-line n/no-unpublished-require */
21
- const rgConfig = require( "eslint-config-reverentgeek" );
20
+ const defineConfig = require( "eslint/config" ).defineConfig; // eslint-disable-line n/no-unpublished-require
21
+ const rg = require( "eslint-config-reverentgeek" ); // eslint-disable-line n/no-extraneous-require
22
22
 
23
- module.exports = [
24
- rgConfig.configs.common,
23
+ module.exports = defineConfig( [
25
24
  {
25
+ extends: [ rg.configs.node ],
26
26
  rules: {
27
27
  }
28
28
  }
29
- ];
29
+ ] );
30
30
  ```
31
31
 
32
+ The _node_ config adds specific support for Node.js and CommonJS modules.
33
+
32
34
  ## Alternative Configs
33
35
 
34
36
  The _node-esm_ config adds specific support for Node.js and ES modules (`import`/`export`).
35
37
 
36
38
  ```js
37
- /* eslint-disable-next-line n/no-unpublished-import */
38
- import rg from "eslint-config-reverentgeek";
39
+ import { defineConfig } from "eslint/config"; // eslint-disable-line n/no-unpublished-import
40
+ import rg from "eslint-config-reverentgeek"; // eslint-disable-line n/no-extraneous-import
39
41
 
40
- export default [
41
- rg.configs["node-esm"],
42
- {
43
- rules: {
44
- }
42
+ export default defineConfig( {
43
+ extends: [ rg.configs["node-esm"] ],
44
+ rules: {
45
45
  }
46
- ];
46
+ } );
47
47
  ```
48
48
 
49
49
  The _blog_ config changes the code style to two-spaced indentions, which is better for copying code samples to blog posts.
50
50
 
51
51
  ```js
52
- "use strict";
53
-
54
- /* eslint-disable-next-line n/no-unpublished-require */
55
- const rgConfig = require( "eslint-config-reverentgeek" );
56
-
57
- module.exports = [
58
- rgConfig.configs.browser,
59
- rgConfig.configs.blog,
60
- {
61
- rules: {
62
- }
63
- }
64
- ];
65
- ```
66
-
67
- The _node_ config adds specific support for Node.js and CommonJS modules.
68
-
69
- ```js
70
- "use strict";
71
-
72
- /* eslint-disable-next-line n/no-unpublished-require */
73
- const rgConfig = require( "eslint-config-reverentgeek" );
52
+ import { defineConfig } from "eslint/config";
53
+ import rg from "eslint-config-reverentgeek";
74
54
 
75
- module.exports = [
76
- rgConfig.configs.node,
77
- {
78
- rules: {
79
- }
80
- }
81
- ];
55
+ export default defineConfig( {
56
+ extends: [ rg.configs.browser, rg.configs.blog ]
57
+ } );
82
58
  ```
83
59
 
84
60
  The _react_ config adds specific support for React, browser, and ES modules (`import`/`export`).
@@ -88,39 +64,29 @@ npm install --save-dev eslint-plugin-react
88
64
  ```
89
65
 
90
66
  ```js
91
- /* eslint-disable-next-line n/no-unpublished-import */
67
+ import { defineConfig } from "eslint/config";
92
68
  import rg from "eslint-config-reverentgeek";
93
- /* eslint-disable-next-line n/no-unpublished-import */
94
69
  import react from "eslint-plugin-react";
95
70
 
96
- export default [
97
- rg.configs.browser,
98
- rg.configs.react,
99
- {
100
- plugins: {
101
- react,
102
- },
103
- rules: {
104
- }
71
+ export default defineConfig( {
72
+ extends: [ rg.configs.browser, rg.configs.react ],
73
+ plugins: {
74
+ react
75
+ },
76
+ rules: {
105
77
  }
106
- ];
78
+ } );
107
79
  ```
108
80
 
109
81
  The _browser_ config sets the `browser` environment and adds ES module support.
110
82
 
111
83
  ```js
112
- "use strict";
113
-
114
- /* eslint-disable-next-line n/no-unpublished-require */
115
- const rgConfig = require( "eslint-config-reverentgeek" );
84
+ import { defineConfig } from "eslint/config";
85
+ import rg from "eslint-config-reverentgeek";
116
86
 
117
- module.exports = [
118
- rgConfig.configs.browser,
119
- {
120
- rules: {
121
- }
122
- }
123
- ];
87
+ export default defineConfig( {
88
+ extends: [ rg.configs.browser ]
89
+ } );
124
90
  ```
125
91
 
126
92
  ## Legacy .eslintrc.js support (eslint < v9.0)
package/eslint.config.js CHANGED
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ const defineConfig = require( "eslint/config" ).defineConfig; // eslint-disable-line n/no-unpublished-require
3
+
2
4
  const node = require( "./src/node" );
3
5
 
4
6
  const config = {
@@ -19,5 +21,5 @@ const testConfig = {
19
21
  }
20
22
  };
21
23
 
22
- module.exports = [ node, config, testConfig ];
24
+ module.exports = defineConfig( [ node, config, testConfig ] );
23
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-reverentgeek",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "ESLint rules that ReverentGeek likes :)",
5
5
  "main": "src/index.js",
6
6
  "repository": {
package/src/blog.js CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";
2
2
 
3
+ const defineConfig = require( "eslint/config" ).defineConfig; // eslint-disable-line n/no-unpublished-require
3
4
  const styles = require( "@stylistic/eslint-plugin" );
4
5
 
5
- module.exports = {
6
- name: "reverentgeek-blog",
6
+ module.exports = defineConfig( {
7
+ name: "blog",
7
8
  plugins: {
8
9
  "@stylistic": styles
9
10
  },
@@ -11,5 +12,5 @@ module.exports = {
11
12
  "no-console": [ "off" ],
12
13
  "@stylistic/indent": [ "error", 2 ]
13
14
  }
14
- };
15
+ } );
15
16
 
package/src/browser.js CHANGED
@@ -1,18 +1,14 @@
1
1
  "use strict";
2
+ const defineConfig = require( "eslint/config" ).defineConfig; // eslint-disable-line n/no-unpublished-require
2
3
  const globals = require( "globals" );
3
4
  const common = require( "./common" );
4
- const { merge } = require( "./utils" );
5
5
 
6
- const config = {
7
- name: "reverentgeek-browser",
6
+ module.exports = defineConfig( {
7
+ name: "browser",
8
+ extends: [ common ],
8
9
  languageOptions: {
9
10
  ecmaVersion: "latest",
10
11
  sourceType: "module",
11
12
  globals: globals.browser
12
- },
13
- rules: {
14
13
  }
15
- };
16
-
17
- module.exports = merge( common, config );
18
-
14
+ } );
package/src/common.js CHANGED
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
 
3
+ const defineConfig = require( "eslint/config" ).defineConfig; // eslint-disable-line n/no-unpublished-require
4
+
3
5
  const eslint = require( "@eslint/js" );
4
6
  const styles = require( "@stylistic/eslint-plugin" );
5
- const { merge } = require( "./utils" );
6
7
 
7
- const config = {
8
- name: "reverentgeek-common",
8
+ module.exports = defineConfig( {
9
+ name: "common",
10
+ extends: [ eslint.configs.recommended, styles.configs.recommended ],
9
11
  rules: {
10
12
  "no-console": [ "off" ],
11
13
  "no-var": [ "error" ],
@@ -26,6 +28,5 @@ const config = {
26
28
  "@stylistic/space-in-parens": [ "error", "always" ],
27
29
  "@stylistic/template-curly-spacing": [ "error", "always" ]
28
30
  }
29
- };
31
+ } );
30
32
 
31
- module.exports = merge( eslint.configs.recommended, styles.configs.recommended, config );
package/src/esm.js CHANGED
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
+ const defineConfig = require( "eslint/config" ).defineConfig; // eslint-disable-line n/no-unpublished-require
2
3
 
3
- module.exports = {
4
- name: "reverentgeek-esm",
4
+ module.exports = defineConfig( {
5
+ name: "esm",
5
6
  languageOptions: {
6
7
  ecmaVersion: "latest",
7
8
  sourceType: "module"
8
9
  }
9
- };
10
+ } );
10
11
 
package/src/node-esm.js CHANGED
@@ -1,19 +1,17 @@
1
1
  "use strict";
2
+ const defineConfig = require( "eslint/config" ).defineConfig; // eslint-disable-line n/no-unpublished-require
2
3
  const common = require( "./common" );
3
4
  const nodePlugin = require( "eslint-plugin-n" );
4
5
  const nodeRecommended = nodePlugin.configs["flat/recommended-module"];
5
- const { merge } = require( "./utils" );
6
6
 
7
- const config = {
8
- name: "reverentgeek-node-esm",
7
+ module.exports = defineConfig( {
8
+ name: "node-esm",
9
+ extends: [ common, nodeRecommended ],
9
10
  languageOptions: {
10
11
  sourceType: "module"
11
12
  },
12
13
  rules: {
13
14
  "n/exports-style": [ "error" ]
14
15
  }
15
- };
16
- const merged = merge( common, nodeRecommended, config );
17
-
18
- module.exports = merged;
16
+ } );
19
17
 
package/src/node.js CHANGED
@@ -1,12 +1,14 @@
1
1
 
2
2
  "use strict";
3
+
4
+ const defineConfig = require( "eslint/config" ).defineConfig; // eslint-disable-line n/no-unpublished-require
3
5
  const common = require( "./common" );
4
6
  const nodePlugin = require( "eslint-plugin-n" );
5
7
  const nodeRecommended = nodePlugin.configs["flat/recommended-script"];
6
- const { merge } = require( "./utils" );
7
8
 
8
- const config = {
9
- name: "reverentgeek-node-commonjs",
9
+ module.exports = defineConfig( {
10
+ name: "node-commonjs",
11
+ extends: [ common, nodeRecommended ],
10
12
  languageOptions: {
11
13
  sourceType: "commonjs"
12
14
  },
@@ -14,9 +16,4 @@ const config = {
14
16
  strict: [ "error", "global" ],
15
17
  "n/exports-style": [ "error" ]
16
18
  }
17
- };
18
-
19
- const merged = merge( common, nodeRecommended, config );
20
-
21
- module.exports = merged;
22
-
19
+ } );
package/src/react.js CHANGED
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
+ const defineConfig = require( "eslint/config" ).defineConfig; // eslint-disable-line n/no-unpublished-require
2
3
 
3
- module.exports = {
4
- name: "reverentgeek-react",
4
+ module.exports = defineConfig( {
5
+ name: "react",
5
6
  languageOptions: {
6
7
  parserOptions: {
7
8
  ecmaFeatures: {
@@ -9,5 +10,4 @@ module.exports = {
9
10
  }
10
11
  }
11
12
  }
12
- };
13
-
13
+ } );
package/test/blog.test.js CHANGED
@@ -16,4 +16,4 @@ describe( "blog config", () => {
16
16
  } );
17
17
 
18
18
  testHasPlugins( blogConfig, [ "@stylistic" ] );
19
- } );
19
+ } );
@@ -17,4 +17,4 @@ describe( "browser config", () => {
17
17
  assert.ok( Object.prototype.hasOwnProperty.call( browserConfig.languageOptions.globals, "document" ), "Should have document global" );
18
18
  assert.ok( Object.prototype.hasOwnProperty.call( browserConfig.languageOptions.globals, "console" ), "Should have console global" );
19
19
  } );
20
- } );
20
+ } );
@@ -11,4 +11,4 @@ describe( "common config", () => {
11
11
  testHasRules( commonConfig, [ "@stylistic/indent", "@stylistic/quotes", "@stylistic/semi", "@stylistic/brace-style" ] );
12
12
 
13
13
  testHasPlugins( commonConfig, [ "@stylistic" ] );
14
- } );
14
+ } );
package/test/esm.test.js CHANGED
@@ -15,4 +15,4 @@ describe( "esm config", () => {
15
15
  assert.ok( esmConfig.languageOptions, "Should have languageOptions" );
16
16
  assert.strictEqual( esmConfig.languageOptions.ecmaVersion, "latest", "Should use latest ecmaVersion" );
17
17
  } );
18
- } );
18
+ } );
@@ -4,7 +4,7 @@ const { test, describe } = require( "node:test" );
4
4
  const assert = require( "node:assert" );
5
5
  const pkg = require( "../package.json" );
6
6
  const configModule = require( "../src/index.js" );
7
- const { expectedNames } = require( "./test-helpers.js" );
7
+ const { expectedNames, getConfig } = require( "./test-helpers.js" );
8
8
 
9
9
  describe( "eslint-config-reverentgeek", () => {
10
10
  test( "should export meta information", () => {
@@ -54,7 +54,7 @@ describe( "eslint-config-reverentgeek", () => {
54
54
 
55
55
  test( "all configs should have correct names", () => {
56
56
  for ( const [ configName, expectedName ] of Object.entries( expectedNames ) ) {
57
- const config = configModule.configs[configName];
57
+ const config = getConfig( configName );
58
58
  assert.ok( config.name, `${ configName } config should have a name property` );
59
59
  assert.strictEqual( typeof config.name, "string", `${ configName } config name should be a string` );
60
60
  assert.strictEqual( config.name, expectedName, `${ configName } config should have correct name` );
@@ -71,4 +71,4 @@ describe( "eslint-config-reverentgeek", () => {
71
71
  }
72
72
  } );
73
73
  } );
74
- } );
74
+ } );
@@ -9,4 +9,4 @@ describe( "node-esm config", () => {
9
9
  testBasicConfigStructure( "node-esm", nodeEsmConfig );
10
10
 
11
11
  testLanguageOptions( nodeEsmConfig, "module" );
12
- } );
12
+ } );
package/test/node.test.js CHANGED
@@ -13,4 +13,4 @@ describe( "node config", () => {
13
13
  testHasRules( nodeConfig, [ "strict", "n/exports-style" ] );
14
14
 
15
15
  testHasPlugins( nodeConfig, [ "n" ] );
16
- } );
16
+ } );
@@ -15,4 +15,4 @@ describe( "react config", () => {
15
15
  assert.ok( reactConfig.languageOptions.parserOptions.ecmaFeatures, "Should have ecmaFeatures" );
16
16
  assert.ok( reactConfig.languageOptions.parserOptions.ecmaFeatures.jsx, "Should support JSX" );
17
17
  } );
18
- } );
18
+ } );
@@ -6,13 +6,13 @@ const configModule = require( "../src/index.js" );
6
6
 
7
7
  // Expected names for all configs
8
8
  const expectedNames = {
9
- common: "reverentgeek-common",
10
- blog: "reverentgeek-blog",
11
- browser: "reverentgeek-browser",
12
- node: "reverentgeek-node-commonjs",
13
- "node-esm": "reverentgeek-node-esm",
14
- esm: "reverentgeek-esm",
15
- react: "reverentgeek-react"
9
+ common: "common",
10
+ blog: "blog",
11
+ browser: "browser",
12
+ node: "node-commonjs",
13
+ "node-esm": "node-esm",
14
+ esm: "esm",
15
+ react: "react"
16
16
  };
17
17
 
18
18
  /**
@@ -89,9 +89,50 @@ function testLanguageOptions( config, expectedSourceType, hasGlobals = false ) {
89
89
 
90
90
  /**
91
91
  * Get a config from the main module
92
+ * Since configs are now arrays due to defineConfig, we need to handle them properly
92
93
  */
93
94
  function getConfig( configName ) {
94
- return configModule.configs[configName];
95
+ const configArray = configModule.configs[configName];
96
+
97
+ // If it's an array (which it should be with defineConfig), we need to get the effective config
98
+ if ( Array.isArray( configArray ) ) {
99
+ // For testing purposes, we'll merge all configs in the array to get the effective configuration
100
+ // This simulates what ESLint would do when processing the config
101
+ const merged = {
102
+ name: null,
103
+ plugins: {},
104
+ rules: {},
105
+ languageOptions: {}
106
+ };
107
+
108
+ configArray.forEach( ( config ) => {
109
+ if ( config.name ) {
110
+ merged.name = config.name;
111
+ }
112
+ if ( config.plugins ) {
113
+ Object.assign( merged.plugins, config.plugins );
114
+ }
115
+ if ( config.rules ) {
116
+ Object.assign( merged.rules, config.rules );
117
+ }
118
+ if ( config.languageOptions ) {
119
+ Object.assign( merged.languageOptions, config.languageOptions );
120
+ }
121
+ } );
122
+
123
+ // Clean up empty objects
124
+ if ( Object.keys( merged.plugins ).length === 0 ) {
125
+ delete merged.plugins;
126
+ }
127
+ if ( Object.keys( merged.languageOptions ).length === 0 ) {
128
+ delete merged.languageOptions;
129
+ }
130
+
131
+ return merged;
132
+ }
133
+
134
+ // Fallback for non-array configs (shouldn't happen with defineConfig)
135
+ return configArray;
95
136
  }
96
137
 
97
138
  module.exports = {
@@ -102,4 +143,4 @@ module.exports = {
102
143
  testHasPlugins,
103
144
  testLanguageOptions,
104
145
  getConfig
105
- };
146
+ };