@jgarber/eslint-config 2.0.0 → 4.0.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2022–present Jason Garber
3
+ Copyright (c) 2022 Jason Garber
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # eslint-config
1
+ # @jgarber/eslint-config
2
2
 
3
- Shareable [ESLint](https://eslint.org) configurations.
3
+ **Shareable [ESLint](https://eslint.org) configuration.**
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@jgarber/eslint-config.svg?logo=npm&style=for-the-badge)](https://www.npmjs.com/package/@jgarber/eslint-config)
6
6
  [![Downloads](https://img.shields.io/npm/dt/@jgarber/eslint-config.svg?logo=npm&style=for-the-badge)](https://www.npmjs.com/package/@jgarber/eslint-config)
7
7
  [![Build](https://img.shields.io/github/actions/workflow/status/jgarber623/eslint-config/ci.yml?branch=main&logo=github&style=for-the-badge)](https://github.com/jgarber623/eslint-config/actions/workflows/ci.yml)
8
8
 
9
9
  > [!IMPORTANT]\
10
- > These shareable configurations use ESLint's new "flat" configuration file format, which may not be suitable for every project. See [the official documentation](https://eslint.org/docs/latest/use/configure/configuration-files-new) for details.
10
+ > This shareable configuration uses ESLint's new "flat" configuration file format, which may not be suitable for every project. See [the official documentation](https://eslint.org/docs/latest/use/configure/configuration-files-new) for details.
11
11
 
12
12
  ## Installation
13
13
 
@@ -21,31 +21,16 @@ Using [ECMAScript module (ESM)](https://nodejs.org/api/esm.html) syntax:
21
21
 
22
22
  ```js
23
23
  // eslint.config.js
24
- import config from '@jgarber/eslint-config';
25
-
26
- export default config;
24
+ export { default } from "@jgarber/eslint-config";
27
25
  ```
28
26
 
29
27
  Using [CommonJS module](https://nodejs.org/api/modules.html) syntax:
30
28
 
31
29
  ```js
32
30
  // eslint.config.js
33
- const config = require('@jgarber/eslint-config');
34
- const commonjs = require('@jgarber/eslint-config/commonjs');
35
-
36
- module.exports = [
37
- ...commonjs,
38
- ...config
39
- ];
31
+ module.exports = (async () => await require("@jgarber/eslint-config"))();
40
32
  ```
41
33
 
42
- ### Additional Configurations
43
-
44
- This package exports several other configurations that may be useful in conjunction with the main configuration (or, by themselves!):
45
-
46
- - `@jgarber/eslint-config/commonjs`: configures `languageOptions` and `globals` for CommonJS modules (especially useful if your `*.js` files target Node.js environments)
47
- - `@jgarber/eslint-config/ava`: configures linting for tests written using the [AVA](https://www.npmjs.com/package/ava) test framework
48
-
49
34
  ## License
50
35
 
51
- Ths package is freely available under the [MIT License](https://opensource.org/licenses/MIT). Use it, learn from it, fork it, improve it, change it, tailor it to your needs.
36
+ @jgarber/eslint-config is freely available under the [MIT License](https://opensource.org/licenses/MIT).
package/index.cjs ADDED
@@ -0,0 +1,24 @@
1
+ module.exports = (async () => {
2
+ const { default: eslintConfig } = await import("./index.js");
3
+
4
+ return [
5
+ ...eslintConfig,
6
+ {
7
+ languageOptions: {
8
+ /**
9
+ * @see {@link https://www.npmjs.com/package/globals}
10
+ * @see {@link https://github.com/sindresorhus/globals/blob/main/globals.json}
11
+ */
12
+ globals: {
13
+ __dirname: "readonly",
14
+ __filename: "readonly",
15
+ exports: "writable",
16
+ global: "readonly",
17
+ module: "readonly",
18
+ require: "readonly",
19
+ },
20
+ sourceType: "commonjs",
21
+ },
22
+ },
23
+ ];
24
+ })();
package/index.js ADDED
@@ -0,0 +1,186 @@
1
+ import js from "@eslint/js";
2
+ import stylistic from "@stylistic/eslint-plugin";
3
+
4
+ import arrayFunc from "eslint-plugin-array-func";
5
+ import jsdoc from "eslint-plugin-jsdoc";
6
+ import n from "eslint-plugin-n";
7
+ import regexp from "eslint-plugin-regexp";
8
+ import sortClassMembers from "eslint-plugin-sort-class-members";
9
+
10
+ export default [
11
+ /**
12
+ * @see {@link https://www.npmjs.com/package/eslint-plugin-jsdoc}
13
+ */
14
+ jsdoc.configs["flat/recommended"],
15
+
16
+ /**
17
+ * @see {@link https://www.npmjs.com/package/@eslint/js}
18
+ * @see {@link https://eslint.org/docs/latest/rules/}
19
+ */
20
+ js.configs.recommended,
21
+
22
+ /**
23
+ * @see {@link https://eslint.style/guide/config-presets}
24
+ * @see {@link https://eslint.style/packages/default}
25
+ * @see {@link https://github.com/eslint-stylistic/eslint-stylistic/blob/main/packages/eslint-plugin/configs/customize.ts}
26
+ */
27
+ stylistic.configs.customize({
28
+ braceStyle: "1tbs",
29
+ jsx: false,
30
+ quotes: "double",
31
+ semi: true,
32
+ }),
33
+
34
+ /**
35
+ * @see {@link https://www.npmjs.com/package/eslint-plugin-array-func}
36
+ */
37
+ arrayFunc.configs.all,
38
+
39
+ /**
40
+ * @see {@link https://www.npmjs.com/package/eslint-plugin-n}
41
+ */
42
+ n.configs["flat/recommended"],
43
+
44
+ /**
45
+ * @see {@link https://www.npmjs.com/package/eslint-plugin-regexp}
46
+ * @see {@link https://github.com/ota-meshi/eslint-plugin-regexp/issues/695}
47
+ */
48
+ {
49
+ plugins: { regexp },
50
+ rules: regexp.configs.recommended.rules,
51
+ },
52
+
53
+ /**
54
+ * @see {@link https://www.npmjs.com/package/eslint-plugin-sort-class-members}
55
+ */
56
+ {
57
+ plugins: { "sort-class-members": sortClassMembers },
58
+ rules: sortClassMembers.configs.recommended.rules,
59
+ },
60
+
61
+ /**
62
+ * @see {@link https://www.npmjs.com/package/@jgarber/eslint-config}
63
+ */
64
+ {
65
+ rules: {
66
+ /**
67
+ * Enforce consistent line breaks between array elements.
68
+ *
69
+ * @see {@link https://eslint.style/rules/default/array-element-newline}
70
+ */
71
+ "@stylistic/array-element-newline": ["error", "consistent"],
72
+
73
+ /**
74
+ * Enforce consistent usage of line breaks between arguments of a function
75
+ * call.
76
+ *
77
+ * @see {@link https://eslint.style/rules/js/function-call-argument-newline}
78
+ */
79
+ "@stylistic/function-call-argument-newline": ["error", "consistent"],
80
+
81
+ /**
82
+ * Disallow spaces between the function name and the opening parenthesis
83
+ * that calls it.
84
+ *
85
+ * @see {@link https://eslint.style/rules/default/function-call-spacing}
86
+ */
87
+ "@stylistic/function-call-spacing": ["error"],
88
+
89
+ /**
90
+ * Enforce a consistent location for an arrow function containing an
91
+ * implicit return.
92
+ *
93
+ * @see {@link https://eslint.style/rules/default/implicit-arrow-linebreak}
94
+ */
95
+ "@stylistic/implicit-arrow-linebreak": "error",
96
+
97
+ /**
98
+ * Enforce consistent line endings independent of operating system, VCS,
99
+ * or editor.
100
+ *
101
+ * @see {@link https://eslint.style/rules/default/linebreak-style}
102
+ */
103
+ "@stylistic/linebreak-style": "warn",
104
+
105
+ /**
106
+ * Enforces a maximum line length to increase code readability and
107
+ * maintainability.
108
+ *
109
+ * @see {@link https://eslint.style/rules/default/max-len}
110
+ */
111
+ "@stylistic/max-len": ["warn", {
112
+ code: 120,
113
+ comments: 80,
114
+ ignoreUrls: true,
115
+ tabWidth: 2,
116
+ }],
117
+
118
+ /**
119
+ * Disallow unnecessary semicolons.
120
+ *
121
+ * @see {@link https://eslint.style/rules/default/no-extra-semi}
122
+ */
123
+ "@stylistic/no-extra-semi": "error",
124
+
125
+ /**
126
+ * Warns against using the arrow function syntax in places where it could
127
+ * be confused with a comparison operator.
128
+ *
129
+ * @see {@link https://eslint.style/rules/default/no-confusing-arrow}
130
+ */
131
+ "@stylistic/no-confusing-arrow": "warn",
132
+
133
+ /**
134
+ * Enforce consistent spacing before function parentheses.
135
+ *
136
+ * @see {@link https://eslint.style/rules/js/space-before-function-paren}
137
+ */
138
+ "@stylistic/space-before-function-paren": ["error", {
139
+ anonymous: "never",
140
+ asyncArrow: "always",
141
+ named: "never",
142
+ }],
143
+
144
+ /**
145
+ * Control spacing around colons of `case` and `default` clauses in
146
+ * switch statements.
147
+ *
148
+ * @see {@link https://eslint.style/rules/default/switch-colon-spacing}
149
+ */
150
+ "@stylistic/switch-colon-spacing": "error",
151
+
152
+ /**
153
+ * Sorts tags by a specified sequence according to tag name, optionally
154
+ * adding line breaks between tag groups.
155
+ *
156
+ * @see {@link https://github.com/gajus/eslint-plugin-jsdoc/blob/HEAD/docs/rules/sort-tags.md#user-content-sort-tags-options-linesbetween}
157
+ */
158
+ "jsdoc/sort-tags": ["warn"],
159
+
160
+ /**
161
+ * Enforces lines (or no lines) between tags.
162
+ *
163
+ * @see {@link https://github.com/gajus/eslint-plugin-jsdoc/blob/HEAD/docs/rules/tag-lines.md}
164
+ */
165
+ "jsdoc/tag-lines": ["warn", "any", { startLines: 1 }],
166
+
167
+ /**
168
+ * Enforce sorted import declarations within modules.
169
+ *
170
+ * @see {@link https://eslint.org/docs/latest/rules/sort-imports}
171
+ */
172
+ "sort-imports": ["error", { allowSeparatedGroups: true }],
173
+
174
+ /**
175
+ * Require object keys to be sorted.
176
+ *
177
+ * @see {@link https://eslint.org/docs/latest/rules/sort-keys}
178
+ */
179
+ "sort-keys": ["error", "asc", {
180
+ allowLineSeparatedGroups: true,
181
+ caseSensitive: false,
182
+ natural: true,
183
+ }],
184
+ },
185
+ },
186
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jgarber/eslint-config",
3
- "version": "2.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "Shareable ESLint configuration.",
5
5
  "keywords": [
6
6
  "config",
@@ -16,41 +16,36 @@
16
16
  "license": "MIT",
17
17
  "author": "Jason Garber <jason@sixtwothree.org> (https://sixtwothree.org)",
18
18
  "files": [
19
- "lib/*"
19
+ "index.cjs",
20
+ "index.js"
20
21
  ],
22
+ "type": "module",
21
23
  "exports": {
22
- "./package.json": "./package.json",
23
- ".": "./lib/index.js",
24
- "./ava": "./lib/ava.js",
25
- "./commonjs": "./lib/commonjs.js"
24
+ "import": "./index.js",
25
+ "require": "./index.cjs"
26
26
  },
27
27
  "repository": "github:jgarber623/eslint-config",
28
28
  "scripts": {
29
29
  "lint": "eslint .",
30
- "test": "c8 ava"
31
- },
32
- "engines": {
33
- "node": ">=18.0.0"
30
+ "test": "NODE_V8_COVERAGE=coverage node --experimental-test-coverage --test"
34
31
  },
35
32
  "dependencies": {
36
- "@eslint/js": "^8.50.0",
37
- "eslint-config-standard": "^17.1.0",
38
- "eslint-plugin-ava": "^14.0.0",
39
- "eslint-plugin-array-func": "^4.0.0",
40
- "eslint-plugin-jsdoc": "^46.8.2",
41
- "eslint-plugin-n": "^16.1.0",
42
- "eslint-plugin-promise": "^6.1.1",
43
- "eslint-plugin-regexp": "^1.15.0",
44
- "eslint-plugin-sort-class-members": "^1.19.0",
45
- "eslint-plugin-unicorn": "^48.0.1"
33
+ "@eslint/js": "^8.56.0",
34
+ "@stylistic/eslint-plugin": "^1.6.1",
35
+ "eslint-plugin-array-func": "^5.0.1",
36
+ "eslint-plugin-jsdoc": "^48.0.6",
37
+ "eslint-plugin-n": "^16.6.2",
38
+ "eslint-plugin-regexp": "^2.2.0",
39
+ "eslint-plugin-sort-class-members": "^1.19.0"
46
40
  },
47
41
  "devDependencies": {
48
- "ava": "^5.3.1",
49
- "c8": "^8.0.1",
50
- "eslint": "^8.50.0"
42
+ "eslint": "^8.56.0"
51
43
  },
52
44
  "peerDependencies": {
53
- "eslint": ">=8.50.0"
45
+ "eslint": ">=8.56.0"
46
+ },
47
+ "engines": {
48
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
54
49
  },
55
50
  "publishConfig": {
56
51
  "access": "public"
package/lib/ava.js DELETED
@@ -1,22 +0,0 @@
1
- const ava = require('eslint-plugin-ava');
2
-
3
- module.exports = [
4
- {
5
- // Use AVA's default file-matching patterns.
6
- //
7
- // https://github.com/avajs/ava/blob/HEAD/docs/05-command-line.md
8
- files: [
9
- 'test.js',
10
- 'src/test.js',
11
- 'source/test.js',
12
- '**/test-*.js',
13
- '**/*.spec.js',
14
- '**/*.test.js',
15
- '**/test/**/*.js',
16
- '**/tests/**/*.js',
17
- '**/__tests__/**/*.js'
18
- ],
19
- plugins: { ava },
20
- rules: ava.configs.recommended.rules
21
- }
22
- ];
package/lib/commonjs.js DELETED
@@ -1,29 +0,0 @@
1
- // By default, ESLint's "flat" config considers `*.js` files to be ECMAScript
2
- // modules (ESM). `*.mjs` files are always parsed as ESM modules and `*.cjs`
3
- // files are always parsed as CommonJS modules.
4
- //
5
- // This configures ESLint to treat `*.js` files as CommonJS modules.
6
- //
7
- // Authors may also specify the module type in `package.json` using either
8
- // `"type": "commonjs"` or `"type": "module"`.
9
- //
10
- // https://eslint.org/docs/latest/use/configure/configuration-files-new#configuration-objects
11
- // https://nodejs.org/dist/latest-v18.x/docs/api/modules.html#enabling
12
- module.exports = [
13
- {
14
- files: ['**/*.js'],
15
- languageOptions: {
16
- // https://www.npmjs.com/package/globals
17
- // https://github.com/sindresorhus/globals/blob/HEAD/globals.json
18
- globals: {
19
- __dirname: 'readonly',
20
- __filename: 'readonly',
21
- exports: 'writable',
22
- global: 'readonly',
23
- module: 'readonly',
24
- require: 'readonly'
25
- },
26
- sourceType: 'commonjs'
27
- }
28
- }
29
- ];
@@ -1,21 +0,0 @@
1
- const plugin = require('eslint-plugin-array-func');
2
- const { configs, rules } = plugin;
3
-
4
- module.exports = {
5
- configs: {
6
- 'flat/all': {
7
- plugins: { 'array-func': plugin },
8
- rules: {
9
- ...configs.recommended.rules,
10
- ...configs.all.rules
11
- }
12
- },
13
- 'flat/recommended': {
14
- plugins: { 'array-func': plugin },
15
- rules: {
16
- ...configs.recommended.rules
17
- }
18
- }
19
- },
20
- rules
21
- };
@@ -1,12 +0,0 @@
1
- const plugin = require('eslint-plugin-promise');
2
- const { configs, rules } = plugin;
3
-
4
- module.exports = {
5
- configs: {
6
- 'flat/recommended': {
7
- plugins: { promise: plugin },
8
- rules: configs.recommended.rules
9
- }
10
- },
11
- rules
12
- };
@@ -1,16 +0,0 @@
1
- const plugin = require('eslint-plugin-regexp');
2
- const { configs, rules } = plugin;
3
-
4
- module.exports = {
5
- configs: {
6
- 'flat/all': {
7
- plugins: { regexp: plugin },
8
- rules: configs.all.rules
9
- },
10
- 'flat/recommended': {
11
- plugins: { regexp: plugin },
12
- rules: configs.recommended.rules
13
- }
14
- },
15
- rules
16
- };
@@ -1,12 +0,0 @@
1
- const plugin = require('eslint-plugin-sort-class-members');
2
- const { configs, rules } = plugin;
3
-
4
- module.exports = {
5
- configs: {
6
- 'flat/recommended': {
7
- plugins: { 'sort-class-members': plugin },
8
- rules: configs.recommended.rules
9
- }
10
- },
11
- rules
12
- };
@@ -1,16 +0,0 @@
1
- const plugin = require('eslint-plugin-unicorn');
2
- const { configs, rules } = plugin;
3
-
4
- module.exports = {
5
- configs: {
6
- 'flat/all': {
7
- plugins: { unicorn: plugin },
8
- rules: configs.all.rules
9
- },
10
- 'flat/recommended': {
11
- plugins: { unicorn: plugin },
12
- rules: configs.recommended.rules
13
- }
14
- },
15
- rules
16
- };
@@ -1,5 +0,0 @@
1
- module.exports.arrayFunc = require('./eslint-plugin-array-func');
2
- module.exports.promise = require('./eslint-plugin-promise');
3
- module.exports.regexp = require('./eslint-plugin-regexp');
4
- module.exports.sortClassMembers = require('./eslint-plugin-sort-class-members');
5
- module.exports.unicorn = require('./eslint-plugin-unicorn');
package/lib/index.js DELETED
@@ -1,88 +0,0 @@
1
- // ESLint shared configurations
2
- const js = require('@eslint/js');
3
- const standard = require('eslint-config-standard');
4
-
5
- // ESLint plugins
6
- const jsdoc = require('eslint-plugin-jsdoc');
7
- const n = require('eslint-plugin-n');
8
-
9
- // Compat module for non-"flat"-compatible plugins
10
- const compat = require('./compat');
11
-
12
- module.exports = [
13
- // https://www.npmjs.com/package/eslint-plugin-jsdoc
14
- jsdoc.configs['flat/recommended-error'],
15
-
16
- // https://www.npmjs.com/package/eslint-plugin-n
17
- n.configs['flat/recommended'],
18
-
19
- // https://www.npmjs.com/package/eslint-plugin-array-func
20
- compat.arrayFunc.configs['flat/all'],
21
-
22
- // https://www.npmjs.com/package/eslint-plugin-promise
23
- compat.promise.configs['flat/recommended'],
24
-
25
- // https://www.npmjs.com/package/eslint-plugin-regexp
26
- compat.regexp.configs['flat/recommended'],
27
-
28
- // https://www.npmjs.com/package/eslint-plugin-sort-class-members
29
- compat.sortClassMembers.configs['flat/recommended'],
30
-
31
- // https://www.npmjs.com/package/eslint-plugin-unicorn
32
- compat.unicorn.configs['flat/recommended'],
33
-
34
- {
35
- rules: {
36
- // https://www.npmjs.com/package/@eslint/js
37
- ...js.configs.recommended.rules,
38
-
39
- // https://www.npmjs.com/package/eslint-config-standard
40
- //
41
- // Remove eslint-plugin-import rules until the following "flat" config-
42
- // related issues are resolved.
43
- //
44
- // https://github.com/import-js/eslint-plugin-import/issues/2556
45
- // https://github.com/import-js/eslint-plugin-import/pull/2829
46
- ...Object.fromEntries(
47
- Object.entries(standard.rules).filter(([key]) => {
48
- return !key.startsWith('import/');
49
- })
50
- ),
51
-
52
- // https://eslint.org/docs/latest/rules/semi
53
- semi: ['error', 'always'],
54
-
55
- // https://eslint.org/docs/latest/rules/sort-keys
56
- 'sort-keys': ['error', 'asc', {
57
- allowLineSeparatedGroups: true,
58
- natural: true
59
- }],
60
-
61
- // https://eslint.org/docs/latest/rules/space-before-function-paren
62
- 'space-before-function-paren': ['error', {
63
- anonymous: 'never',
64
- asyncArrow: 'always',
65
- named: 'never'
66
- }],
67
-
68
- // Disable rules conflicting with eslint-plugin-unicorn.
69
- //
70
- // https://www.npmjs.com/package/eslint-plugin-array-func
71
- 'array-func/prefer-flat': 'off',
72
- 'array-func/prefer-flat-map': 'off',
73
-
74
- // https://github.com/gajus/eslint-plugin-jsdoc/blob/HEAD/docs/rules/tag-lines.md
75
- 'jsdoc/tag-lines': ['error', 'any', { startLines: 1 }],
76
-
77
- // ¯\_(ツ)_/¯
78
- //
79
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/no-null.md}
80
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prefer-module.md}
81
- 'unicorn/no-null': 'off',
82
- 'unicorn/prefer-module': 'off',
83
-
84
- // https://github.com/sindresorhus/eslint-plugin-unicorn/blob/HEAD/docs/rules/prevent-abbreviations.md
85
- 'unicorn/prevent-abbreviations': ['warn', { checkFilenames: false }]
86
- }
87
- }
88
- ];