eslint-config-reverentgeek 5.5.3 → 6.0.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 CHANGED
@@ -1,3 +1,4 @@
1
+ <!-- markdownlint-disable MD010 -->
1
2
  # eslint-config-reverentgeek
2
3
 
3
4
  This package is [ReverentGeek's](https://twitter.com/reverentgeek) preferred configuration settings for [eslint](https://eslint.org/).
@@ -6,9 +7,9 @@ This package is [ReverentGeek's](https://twitter.com/reverentgeek) preferred con
6
7
 
7
8
  1. Install dependencies.
8
9
 
9
- ```sh
10
- npm install --save-dev eslint eslint-config-reverentgeek
11
- ```
10
+ ```sh
11
+ npm install --save-dev eslint eslint-config-reverentgeek
12
+ ```
12
13
 
13
14
  2. Create an `eslint.config.js` file.
14
15
  3. Add the following to the config file.
@@ -18,7 +19,7 @@ npm install --save-dev eslint eslint-config-reverentgeek
18
19
 
19
20
  const rgConfig = require( "eslint-config-reverentgeek" );
20
21
  module.exports = [
21
- ...rgConfig.configs.common,
22
+ rgConfig.configs.common,
22
23
  {
23
24
  rules: {
24
25
  }
@@ -28,52 +29,48 @@ module.exports = [
28
29
 
29
30
  ## Alternative Configs
30
31
 
31
- The _blog_ config changes the code style to two-spaced indentions, which is better for copying code samples to blog posts.
32
+ The _node-esm_ config adds specific support for Node.js and ES modules (`import`/`export`).
32
33
 
33
34
  ```js
34
- "use strict";
35
+ import rg from "eslint-config-reverentgeek";
35
36
 
36
- const rgConfig = require( "eslint-config-reverentgeek" );
37
- module.exports = [
38
- ...rgConfig.configs.browser,
39
- ...rgConfig.configs.blog,
37
+ export default [
38
+ rg.configs["node-esm"],
40
39
  {
41
40
  rules: {
41
+ "n/no-unpublished-import": [ "error", { allowModules: [ "eslint-config-reverentgeek" ] } ]
42
42
  }
43
43
  }
44
44
  ];
45
45
  ```
46
46
 
47
- The _node_ config adds specific support for Node.js and CommonJS modules.
47
+ The _blog_ config changes the code style to two-spaced indentions, which is better for copying code samples to blog posts.
48
48
 
49
49
  ```js
50
50
  "use strict";
51
51
 
52
52
  const rgConfig = require( "eslint-config-reverentgeek" );
53
53
  module.exports = [
54
- ...rgConfig.configs.node,
54
+ rgConfig.configs.browser,
55
+ rgConfig.configs.blog,
55
56
  {
56
57
  rules: {
57
- "n/no-unpublished-require": [ "error", {
58
- allowModules: [ "eslint-config-reverentgeek" ]
59
- } ]
60
58
  }
61
59
  }
62
60
  ];
63
61
  ```
64
62
 
65
- The _node-esm_ config adds specific support for Node.js and ES modules (`import`/`export`).
63
+ The _node_ config adds specific support for Node.js and CommonJS modules.
66
64
 
67
65
  ```js
68
- import rg from "eslint-config-reverentgeek";
66
+ "use strict";
69
67
 
70
- export default [
71
- ...rg.configs[ "node-esm" ],
68
+ const rgConfig = require( "eslint-config-reverentgeek" );
69
+ module.exports = [
70
+ rgConfig.configs.node,
72
71
  {
73
72
  rules: {
74
- "n/no-unpublished-import": [ "error", {
75
- allowModules: [ "eslint-config-reverentgeek" ]
76
- } ]
73
+ "n/no-unpublished-require": [ "error", { allowModules: [ "eslint-config-reverentgeek" ] } ]
77
74
  }
78
75
  }
79
76
  ];
@@ -90,16 +87,14 @@ import rg from "eslint-config-reverentgeek";
90
87
  import react from "eslint-plugin-react";
91
88
 
92
89
  export default [
93
- ...rg.configs.browser,
94
- ...rg.configs.react,
90
+ rg.configs.browser,
91
+ rg.configs.react,
95
92
  {
96
93
  plugins: {
97
94
  react,
98
95
  },
99
96
  rules: {
100
- "n/no-unpublished-import": [ "error", {
101
- allowModules: [ "eslint-config-reverentgeek" ]
102
- } ]
97
+ "n/no-unpublished-import": [ "error", { allowModules: [ "eslint-config-reverentgeek" ] } ]
103
98
  }
104
99
  }
105
100
  ];
@@ -112,7 +107,7 @@ The _browser_ config sets the `browser` environment and adds ES module support.
112
107
 
113
108
  const rgConfig = require( "eslint-config-reverentgeek" );
114
109
  module.exports = [
115
- ...rgConfig.configs.browser,
110
+ rgConfig.configs.browser,
116
111
  {
117
112
  rules: {
118
113
  }
@@ -124,16 +119,16 @@ module.exports = [
124
119
 
125
120
  1. Install dependencies.
126
121
 
127
- ```sh
128
- npm install --save-dev eslint@8 eslint-config-reverentgeek@4
129
- ```
122
+ ```sh
123
+ npm install --save-dev eslint@8 eslint-config-reverentgeek@4
124
+ ```
130
125
 
131
126
  2. Create an `.eslintrc.js` file.
132
127
  3. Add the following to the config file.
133
128
 
134
129
  ```js
135
130
  module.exports = {
136
- extends: [ "reverentgeek" ]
131
+ extends: [ "reverentgeek" ]
137
132
  };
138
133
  ```
139
134
 
@@ -143,7 +138,7 @@ The _blog_ rule set changes to code style to two-spaced indentions, which is bet
143
138
 
144
139
  ```js
145
140
  module.exports = {
146
- extends: [ "reverentgeek/blog" ]
141
+ extends: [ "reverentgeek/blog" ]
147
142
  };
148
143
  ```
149
144
 
@@ -153,7 +148,7 @@ The _node_ rule set adds specific support for Node.js and CommonJS modules.
153
148
  "use strict";
154
149
 
155
150
  module.exports = {
156
- extends: [ "reverentgeek/node" ]
151
+ extends: [ "reverentgeek/node" ]
157
152
  };
158
153
  ```
159
154
 
@@ -163,7 +158,7 @@ The _node/module_ rule set adds specific support for Node.js and ES modules (`im
163
158
  "use strict";
164
159
 
165
160
  module.exports = {
166
- extends: [ "reverentgeek/node/module" ]
161
+ extends: [ "reverentgeek/node/module" ]
167
162
  };
168
163
  ```
169
164
 
@@ -171,6 +166,6 @@ The _browser_ rule set the `browser` environment and adds ES module support.
171
166
 
172
167
  ```js
173
168
  module.exports = {
174
- extends: [ "reverentgeek/browser" ]
169
+ extends: [ "reverentgeek/browser" ]
175
170
  };
176
171
  ```
package/blog.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const styles = require( "@stylistic/eslint-plugin" );
3
3
 
4
- module.exports = [ {
4
+ module.exports = {
5
5
  plugins: {
6
6
  "@stylistic": styles
7
7
  },
@@ -9,4 +9,5 @@ module.exports = [ {
9
9
  "no-console": [ "off" ],
10
10
  "@stylistic/indent": [ "error", 2 ]
11
11
  }
12
- } ];
12
+ };
13
+
package/browser.js CHANGED
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
2
  const globals = require( "globals" );
3
3
  const common = require( "./common" );
4
+ const { merge } = require( "./utils" );
4
5
 
5
- module.exports = [
6
- ...common,
7
- {
8
- languageOptions: {
9
- ecmaVersion: "latest",
10
- sourceType: "module",
11
- globals: globals.browser
12
- },
13
- rules: {
14
- }
6
+ const config = {
7
+ languageOptions: {
8
+ ecmaVersion: "latest",
9
+ sourceType: "module",
10
+ globals: globals.browser
11
+ },
12
+ rules: {
15
13
  }
16
- ];
14
+ };
15
+
16
+ module.exports = merge( common, config );
17
+
package/common.js CHANGED
@@ -2,29 +2,31 @@
2
2
 
3
3
  const eslint = require( "@eslint/js" );
4
4
  const styles = require( "@stylistic/eslint-plugin" );
5
+ const { merge } = require( "./utils" );
5
6
 
6
- module.exports = [
7
- eslint.configs.recommended,
8
- {
9
- plugins: {
10
- "@stylistic": styles
11
- },
12
- rules: {
13
- "no-console": [ "off" ],
14
- "no-var": [ "error" ],
15
- "@stylistic/array-bracket-spacing": [ "error", "always", { singleValue: true } ],
16
- "@stylistic/comma-spacing": [ "error", { before: false, after: true } ],
17
- "@stylistic/eol-last": [ "error", "always" ],
18
- "@stylistic/indent": [ "error", "tab" ],
19
- "@stylistic/linebreak-style": [ "error", "unix" ],
20
- "@stylistic/no-multiple-empty-lines": [ "error", { max: 1 } ],
21
- "@stylistic/no-trailing-spaces": [ "error", { skipBlankLines: false, ignoreComments: false } ],
22
- "@stylistic/object-curly-spacing": [ "error", "always" ],
23
- "@stylistic/quote-props": [ "error", "as-needed" ],
24
- "@stylistic/quotes": [ "error", "double" ],
25
- "@stylistic/semi": [ "error", "always" ],
26
- "@stylistic/space-in-parens": [ "error", "always" ],
27
- "@stylistic/template-curly-spacing": [ "error", "always" ]
28
- }
7
+ const config = {
8
+ name: "reverentgeek-common",
9
+ rules: {
10
+ "no-console": [ "off" ],
11
+ "no-var": [ "error" ],
12
+ "@stylistic/array-bracket-spacing": [ "error", "always", { singleValue: true } ],
13
+ "@stylistic/comma-dangle": [ "error", "never" ],
14
+ "@stylistic/comma-spacing": [ "error", { before: false, after: true } ],
15
+ "@stylistic/eol-last": [ "error", "always" ],
16
+ "@stylistic/indent": [ "error", "tab" ],
17
+ "@stylistic/linebreak-style": [ "error", "unix" ],
18
+ "@stylistic/no-multiple-empty-lines": [ "error", { max: 1 } ],
19
+ "@stylistic/no-tabs": [ "error", { allowIndentationTabs: true } ],
20
+ "@stylistic/no-trailing-spaces": [ "error", { skipBlankLines: false, ignoreComments: false } ],
21
+ "@stylistic/object-curly-spacing": [ "error", "always" ],
22
+ "@stylistic/quote-props": [ "error", "as-needed" ],
23
+ "@stylistic/quotes": [ "error", "double" ],
24
+ "@stylistic/semi": [ "error", "always" ],
25
+ "@stylistic/space-in-parens": [ "error", "always" ],
26
+ "@stylistic/template-curly-spacing": [ "error", "always" ]
29
27
  }
30
- ];
28
+ };
29
+
30
+ const merged = merge( eslint.configs.recommended, styles.configs.recommended, config );
31
+
32
+ module.exports = merged;
package/eslint.config.js CHANGED
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  const node = require( "./node" );
3
3
 
4
- module.exports = [
5
- ...node,
6
- {
7
- rules: {
8
- "n/no-unpublished-require": [ "error", {
9
- allowModules: [ "globals", "eslint-plugin-n", "@stylistic/eslint-plugin" ]
10
- } ],
11
- "n/no-extraneous-require": [ "error", {
12
- allowModules: [ "@eslint/js" ]
13
- } ]
14
- }
4
+ const config = {
5
+ rules: {
6
+ "n/no-unpublished-require": [ "error", {
7
+ allowModules: [ "globals", "eslint-plugin-n", "@stylistic/eslint-plugin" ]
8
+ } ],
9
+ "n/no-extraneous-require": [ "error", {
10
+ allowModules: [ "@eslint/js" ]
11
+ } ]
15
12
  }
16
- ];
13
+ };
14
+
15
+ module.exports = [ node, config ];
16
+
package/esm.js CHANGED
@@ -1,10 +1,9 @@
1
1
  "use strict";
2
2
 
3
- module.exports = [
4
- {
5
- languageOptions: {
6
- ecmaVersion: "latest",
7
- sourceType: "module"
8
- }
3
+ module.exports = {
4
+ languageOptions: {
5
+ ecmaVersion: "latest",
6
+ sourceType: "module"
9
7
  }
10
- ];
8
+ };
9
+
package/node-esm.js CHANGED
@@ -2,16 +2,18 @@
2
2
  const common = require( "./common" );
3
3
  const nodePlugin = require( "eslint-plugin-n" );
4
4
  const nodeRecommended = nodePlugin.configs["flat/recommended-module"];
5
+ const { merge } = require( "./utils" );
5
6
 
6
- module.exports = [
7
- ...common,
8
- nodeRecommended,
9
- {
10
- languageOptions: {
11
- sourceType: "module"
12
- },
13
- rules: {
14
- "n/exports-style": [ "error" ]
15
- }
7
+ const config = {
8
+ name: "reverentgeek-node-esm",
9
+ languageOptions: {
10
+ sourceType: "module"
11
+ },
12
+ rules: {
13
+ "n/exports-style": [ "error" ]
16
14
  }
17
- ];
15
+ };
16
+ const merged = merge( common, nodeRecommended, config );
17
+
18
+ module.exports = merged;
19
+
package/node.js CHANGED
@@ -1,18 +1,22 @@
1
+
1
2
  "use strict";
2
3
  const common = require( "./common" );
3
4
  const nodePlugin = require( "eslint-plugin-n" );
4
- const nodeRecommended = nodePlugin.configs["flat/recommended"];
5
+ const nodeRecommended = nodePlugin.configs["flat/recommended-script"];
6
+ const { merge } = require( "./utils" );
5
7
 
6
- module.exports = [
7
- ...common,
8
- nodeRecommended,
9
- {
10
- languageOptions: {
11
- sourceType: "commonjs"
12
- },
13
- rules: {
14
- strict: [ "error", "global" ],
15
- "n/exports-style": [ "error" ]
16
- }
8
+ const config = {
9
+ name: "reverentgeek-node-commonjs",
10
+ languageOptions: {
11
+ sourceType: "commonjs"
12
+ },
13
+ rules: {
14
+ strict: [ "error", "global" ],
15
+ "n/exports-style": [ "error" ]
17
16
  }
18
- ];
17
+ };
18
+
19
+ const merged = merge( common, nodeRecommended, config );
20
+
21
+ module.exports = merged;
22
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-reverentgeek",
3
- "version": "5.5.3",
3
+ "version": "6.0.1",
4
4
  "description": "ESLint rules that ReverentGeek likes :)",
5
5
  "main": "index.js",
6
6
  "repository": {
package/react.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
 
3
- module.exports = [ {
4
- files: [ "**/*.{js,jsx,mjs,cjs,ts,tsx}" ],
3
+ module.exports = {
5
4
  languageOptions: {
6
5
  parserOptions: {
7
6
  ecmaFeatures: {
8
- jsx: true,
9
- },
10
- },
7
+ jsx: true
8
+ }
9
+ }
11
10
  }
12
- } ];
11
+ };
12
+
package/utils.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ // merge-configs.js
3
+ // Utility to merge ESLint config objects for name, plugins, languageOptions, and rules
4
+
5
+ function merge( ...configs ) {
6
+ const languageOptions = {
7
+ sourceType: configs.map( cfg => cfg?.languageOptions?.sourceType ).filter( Boolean ).pop(),
8
+ globals: Object.assign( {}, ...configs.map( cfg => cfg?.languageOptions?.globals || {} ) )
9
+ };
10
+ return {
11
+ name: configs.map( cfg => cfg?.name ).filter( Boolean ).pop(),
12
+ plugins: Object.assign( {}, ...configs.map( cfg => cfg?.plugins || {} ) ),
13
+ languageOptions,
14
+ rules: Object.assign( {}, ...configs.map( cfg => cfg?.rules || {} ) )
15
+ };
16
+ }
17
+
18
+ module.exports = { merge };