eslint-config-reverentgeek 6.2.0 → 6.3.1
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 +31 -65
- package/eslint.config.js +3 -1
- package/package.json +3 -3
- package/src/blog.js +4 -3
- package/src/browser.js +5 -9
- package/src/common.js +6 -5
- package/src/esm.js +4 -3
- package/src/node-esm.js +5 -7
- package/src/node.js +6 -9
- package/src/react.js +4 -4
- package/test/blog.test.js +1 -1
- package/test/browser.test.js +1 -1
- package/test/common.test.js +1 -1
- package/test/esm.test.js +1 -1
- package/test/index.test.js +3 -3
- package/test/node-esm.test.js +1 -1
- package/test/node.test.js +1 -1
- package/test/react.test.js +1 -1
- package/test/test-helpers.js +50 -9
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
|
-
|
|
21
|
-
const
|
|
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
|
-
|
|
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-unpublished-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
|
-
|
|
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
|
-
|
|
76
|
-
|
|
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
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
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
|
-
|
|
118
|
-
|
|
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.
|
|
3
|
+
"version": "6.3.1",
|
|
4
4
|
"description": "ESLint rules that ReverentGeek likes :)",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"author": "David Neal <david@reverentgeek.com> (https://reverentgeek.com)",
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@stylistic/eslint-plugin": "^5.
|
|
22
|
+
"@stylistic/eslint-plugin": "^5.5.0",
|
|
23
23
|
"eslint-plugin-n": "^17.23.1",
|
|
24
24
|
"globals": "^16.4.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"eslint": "^9.
|
|
27
|
+
"eslint": "^9.38.0"
|
|
28
28
|
},
|
|
29
29
|
"engines": {
|
|
30
30
|
"node": ">=18.0.0"
|
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: "
|
|
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
|
-
|
|
7
|
-
name: "
|
|
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
|
-
|
|
8
|
-
name: "
|
|
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: "
|
|
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
|
-
|
|
8
|
-
name: "
|
|
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
|
-
|
|
9
|
-
name: "
|
|
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: "
|
|
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
package/test/browser.test.js
CHANGED
|
@@ -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
|
+
} );
|
package/test/common.test.js
CHANGED
package/test/esm.test.js
CHANGED
package/test/index.test.js
CHANGED
|
@@ -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 =
|
|
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
|
+
} );
|
package/test/node-esm.test.js
CHANGED
package/test/node.test.js
CHANGED
package/test/react.test.js
CHANGED
package/test/test-helpers.js
CHANGED
|
@@ -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: "
|
|
10
|
-
blog: "
|
|
11
|
-
browser: "
|
|
12
|
-
node: "
|
|
13
|
-
"node-esm": "
|
|
14
|
-
esm: "
|
|
15
|
-
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
|
-
|
|
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
|
+
};
|