eslint-config-auditor 0.5.0 → 1.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/README.md CHANGED
@@ -3,97 +3,135 @@
3
3
 
4
4
  # eslint-config-auditor [![npm][npm-image]][npm-url]
5
5
 
6
- > Shareable ESLint Config to help you write clear, efficient JavaScript code. 😼
6
+ > Shareable ESLint flat config to help you write clear, efficient JavaScript code. 😼
7
7
 
8
8
  Auditor uses sane defaults focused on code readability. The Auditor's philosophy is that good code means easy to understand code.
9
9
 
10
- Along with its own rules, Auditor by default includes battle-tested rules from [`eslint:recommended`](https://eslint.org/docs/rules/), [`plugin:import`](https://github.com/benmosher/eslint-plugin-import), [`plugin:promise`](https://github.com/xjamundx/eslint-plugin-promise), and [`plugin:node`](https://github.com/mysticatea/eslint-plugin-node). Both on browser and Node.js, **Auditor gives you the confidence you need to write efficient JavaScript code**.
10
+ Along with its own rules, Auditor by default includes battle-tested rules from [`eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import), [`eslint-plugin-promise`](https://github.com/eslint-community/eslint-plugin-promise), and [`eslint-plugin-n`](https://github.com/eslint-community/eslint-plugin-n). Both on browser and Node.js, **Auditor gives you the confidence you need to write efficient JavaScript code**.
11
11
 
12
- Besides linting standard JavaScript code gracefully, Auditor also has first-class support to React, Jest, and TypeScript. See [rules](#rules) about usage.
12
+ Besides linting standard JavaScript code gracefully, Auditor also has first-class support for React, Jest, and TypeScript. See [rules](#rules) about usage.
13
+
14
+ Version 1.0.0 targets **ESLint 9+ and the flat config format** (`eslint.config.js`). All plugins ship as regular dependencies, so installing this package is all you need.
13
15
 
14
16
  ## Installation
15
17
 
16
18
  ```
17
- npm install --save-dev eslint-config-auditor
19
+ npm install --save-dev eslint eslint-config-auditor
18
20
  ```
19
21
 
22
+ Requires ESLint `>=9` and Node.js `>=18.18.0`.
23
+
20
24
  ## Usage
21
25
 
22
- Auditor's shareable config is meant to be the source of rules for another application (yet to be built), but as a shareable config, you can use it the same way by installing its peer dependencies.
26
+ In your `eslint.config.js` (or `eslint.config.mjs`):
23
27
 
28
+ ```js
29
+ import auditor from 'eslint-config-auditor';
30
+
31
+ export default [...auditor];
24
32
  ```
25
- npm install --save-dev eslint-plugin-{import,promise,node}
26
- ```
27
33
 
28
- Will install [import](https://github.com/benmosher/eslint-plugin-import), [promise](https://github.com/xjamundx/eslint-plugin-promise), and [node](https://github.com/mysticatea/eslint-plugin-node) plugins. You can now extend your config as you usually would.
34
+ The default export is the equivalent of the old root config: `recommended` + `finest` combined.
35
+
36
+ CommonJS (`eslint.config.cjs`) works too:
29
37
 
30
- In your `.eslintrc`
38
+ ```js
39
+ const auditor = require('eslint-config-auditor').default;
31
40
 
32
- ```json
33
- {
34
- "extends": "auditor"
35
- }
41
+ module.exports = [...auditor];
36
42
  ```
37
43
 
38
44
  ## Rules
39
45
 
40
- Installing the above adds all default rules for Auditor. Auditor has two main rule configs:
46
+ Auditor has two main rule configs, available as named exports and subpath imports:
41
47
 
42
- * `auditor/recommended` all the needed rules to write consise JavaScript. Includes all best-practices, Node.js, import, and promise rules. Recommended for most users.
43
- * `auditor/finest` Auditor at its finest. Strict rules for advanced use cases such as code refactors and open-source software where code changes can break infinite clients. Includes the recommended config.
48
+ * `recommended` all the needed rules to write concise JavaScript. Includes all best-practices, Node.js, import, and promise rules. Recommended for most users.
49
+ * `finest` Auditor at its finest. Strict rules for advanced use cases such as code refactors and open-source software where code changes can break infinite clients. Use it on top of `recommended`.
44
50
 
45
- Auditor also offers first-class support to Jest, React, and TypeScript but since these are opinionated tools, you need to activate them for usage manually.
51
+ ```js
52
+ // eslint.config.js
53
+ import recommended from 'eslint-config-auditor/recommended';
54
+ import finest from 'eslint-config-auditor/finest';
46
55
 
47
- ### Jest
56
+ export default [...recommended, ...finest];
57
+ ```
48
58
 
49
- Uses [`eslint-plugin-jest`](https://www.npmjs.com/package/eslint-plugin-jest).
59
+ Auditor also offers first-class support for Jest, React, and TypeScript but since these are opinionated tools, you need to activate them manually.
50
60
 
51
- ```
52
- npm install --save-dev eslint-plugin-jest -D
53
- ```
61
+ ### Jest
54
62
 
55
- ```json
56
- {
57
- "extends": [
58
- "auditor",
59
- "auditor/jest"
60
- ]
61
- }
63
+ Uses [`eslint-plugin-jest`](https://www.npmjs.com/package/eslint-plugin-jest) (already included).
64
+
65
+ ```js
66
+ // eslint.config.js
67
+ import auditor from 'eslint-config-auditor';
68
+ import jest from 'eslint-config-auditor/jest';
69
+
70
+ export default [
71
+ ...auditor,
72
+ // Scope Jest rules to your test files
73
+ ...jest.map((config) => ({
74
+ ...config,
75
+ files: ['**/*.test.{js,jsx,ts,tsx}', '**/*.spec.{js,jsx,ts,tsx}'],
76
+ })),
77
+ ];
62
78
  ```
63
79
 
64
80
  ### React
65
81
 
66
- Uses [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react), [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks), and [`eslint-plugin-jsx-a11y`](https://www.npmjs.com/package/eslint-plugin-jsx-a11y).
82
+ Uses [`eslint-plugin-react`](https://www.npmjs.com/package/eslint-plugin-react), [`eslint-plugin-react-hooks`](https://www.npmjs.com/package/eslint-plugin-react-hooks), and [`eslint-plugin-jsx-a11y`](https://www.npmjs.com/package/eslint-plugin-jsx-a11y) (already included).
67
83
 
68
- ```
69
- npm install --save-dev eslint-plugin-{react,react-hooks,jsx-a11y} -D
70
- ```
84
+ ```js
85
+ // eslint.config.js
86
+ import auditor from 'eslint-config-auditor';
87
+ import react from 'eslint-config-auditor/react';
71
88
 
72
- ```json
73
- {
74
- "extends": [
75
- "auditor",
76
- "auditor/react"
77
- ]
78
- }
89
+ export default [...auditor, ...react];
79
90
  ```
91
+
80
92
  ### TypeScript
81
93
 
82
- Uses [`@typescript-eslint/eslint-plugin`](https://www.npmjs.com/package/@typescript-eslint/eslint-plugin), [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import), and[`@typescript-eslint/parser`](https://www.npmjs.com/package/@typescript-eslint/parser).
94
+ Uses [`typescript-eslint`](https://typescript-eslint.io) and [`eslint-plugin-import`](https://www.npmjs.com/package/eslint-plugin-import) (already included). Rules are scoped to `**/*.ts`/`**/*.tsx` files and use the [project service](https://typescript-eslint.io/packages/parser/#projectservice) for type-aware linting, so a `tsconfig.json` in your project root is all you need.
83
95
 
84
- ```
85
- npm install --save-dev @typescript-eslint/{eslint-plugin,parser} -D
96
+ ```js
97
+ // eslint.config.js
98
+ import auditor from 'eslint-config-auditor';
99
+ import typescript from 'eslint-config-auditor/typescript';
100
+
101
+ export default [...auditor, ...typescript];
86
102
  ```
87
103
 
88
- ```json
89
- {
90
- "extends": [
91
- "auditor",
92
- "auditor/typescript"
93
- ]
94
- }
104
+ All variants can also be pulled from the root entry as named exports:
105
+
106
+ ```js
107
+ import { recommended, finest, jest, react, typescript } from 'eslint-config-auditor';
95
108
  ```
96
109
 
110
+ ## Migrating from 0.x
111
+
112
+ Version 0.x shipped legacy `.eslintrc` configs for ESLint 8. Version 1.0.0 is a flat-config rewrite for ESLint 9. To migrate:
113
+
114
+ 1. Upgrade to `eslint@>=9` and remove the plugin packages you installed manually for 0.x (`eslint-plugin-import`, `eslint-plugin-promise`, `eslint-plugin-node`, `eslint-plugin-jest`, `eslint-plugin-react`, `eslint-plugin-react-hooks`, `eslint-plugin-jsx-a11y`, `@typescript-eslint/parser`, `@typescript-eslint/eslint-plugin`). They are now bundled as dependencies of this package.
115
+ 2. Replace your `.eslintrc`/`.eslintrc.json` with an `eslint.config.js`:
116
+
117
+ ```diff
118
+ - { "extends": ["auditor", "auditor/react"] }
119
+ ```
120
+
121
+ ```js
122
+ // eslint.config.js
123
+ import auditor from 'eslint-config-auditor';
124
+ import react from 'eslint-config-auditor/react';
125
+
126
+ export default [...auditor, ...react];
127
+ ```
128
+
129
+ 3. Note these behavioral changes:
130
+ * `eslint-plugin-node` was replaced by its maintained fork [`eslint-plugin-n`](https://github.com/eslint-community/eslint-plugin-n). The `node/` rule prefix is preserved, so inline directives like `// eslint-disable-next-line node/no-sync` keep working. `node/shebang` is now `node/hashbang`.
131
+ * `@typescript-eslint/parser` + `@typescript-eslint/eslint-plugin` were replaced by [`typescript-eslint`](https://typescript-eslint.io) v8. The TypeScript config now uses `projectService: true` instead of `parserOptions.project` globs.
132
+ * Environments (`env`) and `parserOptions` were translated to `languageOptions`, with globals provided by the [`globals`](https://www.npmjs.com/package/globals) package.
133
+ * A few rules were removed or renamed upstream. See [MIGRATION.md](./MIGRATION.md) for the complete old-rule → disposition table.
134
+
97
135
  ## License
98
136
 
99
137
  MIT (c) Cezar Augusto.
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ default: ()=>src_finest
37
+ });
38
+ const external_eslint_plugin_jsx_a11y_namespaceObject = require("eslint-plugin-jsx-a11y");
39
+ var external_eslint_plugin_jsx_a11y_default = /*#__PURE__*/ __webpack_require__.n(external_eslint_plugin_jsx_a11y_namespaceObject);
40
+ const external_eslint_plugin_n_namespaceObject = require("eslint-plugin-n");
41
+ var external_eslint_plugin_n_default = /*#__PURE__*/ __webpack_require__.n(external_eslint_plugin_n_namespaceObject);
42
+ const external_eslint_plugin_promise_namespaceObject = require("eslint-plugin-promise");
43
+ var external_eslint_plugin_promise_default = /*#__PURE__*/ __webpack_require__.n(external_eslint_plugin_promise_namespaceObject);
44
+ const external_eslint_plugin_import_namespaceObject = require("eslint-plugin-import");
45
+ var external_eslint_plugin_import_default = /*#__PURE__*/ __webpack_require__.n(external_eslint_plugin_import_namespaceObject);
46
+ const importPlugin = external_eslint_plugin_import_default() ?? external_eslint_plugin_import_namespaceObject;
47
+ const import_plugin = importPlugin;
48
+ const finest = [
49
+ {
50
+ name: 'auditor/finest',
51
+ plugins: {
52
+ import: import_plugin,
53
+ 'jsx-a11y': external_eslint_plugin_jsx_a11y_default(),
54
+ node: external_eslint_plugin_n_default(),
55
+ promise: external_eslint_plugin_promise_default()
56
+ },
57
+ rules: {
58
+ complexity: [
59
+ 'warn',
60
+ 10
61
+ ],
62
+ 'func-names': 'warn',
63
+ 'max-lines': [
64
+ 'warn',
65
+ 500
66
+ ],
67
+ 'max-lines-per-function': [
68
+ 'warn',
69
+ {
70
+ max: 45,
71
+ skipComments: true
72
+ }
73
+ ],
74
+ 'max-nested-callbacks': [
75
+ 'warn',
76
+ 6
77
+ ],
78
+ 'max-params': [
79
+ 'warn',
80
+ 3
81
+ ],
82
+ 'max-statements-per-line': [
83
+ 'warn',
84
+ {
85
+ max: 1
86
+ }
87
+ ],
88
+ 'no-await-in-loop': 'warn',
89
+ 'no-console': [
90
+ 'off',
91
+ {
92
+ allow: [
93
+ 'info',
94
+ 'warn',
95
+ 'error'
96
+ ]
97
+ }
98
+ ],
99
+ 'no-promise-executor-return': 'error',
100
+ 'node/no-unpublished-bin': 'warn',
101
+ 'node/no-unpublished-import': 'warn',
102
+ 'node/no-unpublished-require': 'warn',
103
+ 'node/prefer-promises/dns': 'warn',
104
+ 'node/prefer-promises/fs': 'warn',
105
+ 'promise/prefer-await-to-callbacks': 'warn',
106
+ 'promise/prefer-await-to-then': 'warn',
107
+ 'prefer-arrow-callback': [
108
+ 'warn',
109
+ {
110
+ allowNamedFunctions: false,
111
+ allowUnboundThis: true
112
+ }
113
+ ],
114
+ 'node/no-unsupported-features/es-syntax': 'warn',
115
+ 'node/no-missing-import': 'warn',
116
+ 'import/no-relative-parent-imports': 'warn',
117
+ 'node/no-unsupported-features/node-builtins': 'warn',
118
+ 'no-duplicate-imports': 'warn',
119
+ 'import/exports-last': 'error',
120
+ 'node/no-callback-literal': 'error',
121
+ 'jsx-a11y/aria-role': 'error',
122
+ 'jsx-a11y/alt-text': 'error',
123
+ 'array-callback-return': [
124
+ 'error',
125
+ {
126
+ allowImplicit: false,
127
+ checkForEach: false
128
+ }
129
+ ],
130
+ 'object-shorthand': [
131
+ 'error',
132
+ 'always',
133
+ {
134
+ avoidQuotes: true,
135
+ ignoreConstructors: false
136
+ }
137
+ ]
138
+ }
139
+ }
140
+ ];
141
+ const src_finest = finest;
142
+ exports["default"] = __webpack_exports__["default"];
143
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
144
+ "default"
145
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
146
+ Object.defineProperty(exports, '__esModule', {
147
+ value: true
148
+ });
@@ -0,0 +1,3 @@
1
+ import type { Linter } from 'eslint';
2
+ declare const finest: Linter.Config[];
3
+ export default finest;
package/dist/finest.js ADDED
@@ -0,0 +1,101 @@
1
+ import * as __WEBPACK_EXTERNAL_MODULE_eslint_plugin_jsx_a11y_fe6a299b__ from "eslint-plugin-jsx-a11y";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_eslint_plugin_n_9e0a97d1__ from "eslint-plugin-n";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_eslint_plugin_promise_3f421790__ from "eslint-plugin-promise";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_eslint_plugin_import_fddde6bb__ from "eslint-plugin-import";
5
+ const importPlugin = __WEBPACK_EXTERNAL_MODULE_eslint_plugin_import_fddde6bb__["default"] ?? __WEBPACK_EXTERNAL_MODULE_eslint_plugin_import_fddde6bb__;
6
+ const import_plugin = importPlugin;
7
+ const finest = [
8
+ {
9
+ name: 'auditor/finest',
10
+ plugins: {
11
+ import: import_plugin,
12
+ 'jsx-a11y': __WEBPACK_EXTERNAL_MODULE_eslint_plugin_jsx_a11y_fe6a299b__["default"],
13
+ node: __WEBPACK_EXTERNAL_MODULE_eslint_plugin_n_9e0a97d1__["default"],
14
+ promise: __WEBPACK_EXTERNAL_MODULE_eslint_plugin_promise_3f421790__["default"]
15
+ },
16
+ rules: {
17
+ complexity: [
18
+ 'warn',
19
+ 10
20
+ ],
21
+ 'func-names': 'warn',
22
+ 'max-lines': [
23
+ 'warn',
24
+ 500
25
+ ],
26
+ 'max-lines-per-function': [
27
+ 'warn',
28
+ {
29
+ max: 45,
30
+ skipComments: true
31
+ }
32
+ ],
33
+ 'max-nested-callbacks': [
34
+ 'warn',
35
+ 6
36
+ ],
37
+ 'max-params': [
38
+ 'warn',
39
+ 3
40
+ ],
41
+ 'max-statements-per-line': [
42
+ 'warn',
43
+ {
44
+ max: 1
45
+ }
46
+ ],
47
+ 'no-await-in-loop': 'warn',
48
+ 'no-console': [
49
+ 'off',
50
+ {
51
+ allow: [
52
+ 'info',
53
+ 'warn',
54
+ 'error'
55
+ ]
56
+ }
57
+ ],
58
+ 'no-promise-executor-return': 'error',
59
+ 'node/no-unpublished-bin': 'warn',
60
+ 'node/no-unpublished-import': 'warn',
61
+ 'node/no-unpublished-require': 'warn',
62
+ 'node/prefer-promises/dns': 'warn',
63
+ 'node/prefer-promises/fs': 'warn',
64
+ 'promise/prefer-await-to-callbacks': 'warn',
65
+ 'promise/prefer-await-to-then': 'warn',
66
+ 'prefer-arrow-callback': [
67
+ 'warn',
68
+ {
69
+ allowNamedFunctions: false,
70
+ allowUnboundThis: true
71
+ }
72
+ ],
73
+ 'node/no-unsupported-features/es-syntax': 'warn',
74
+ 'node/no-missing-import': 'warn',
75
+ 'import/no-relative-parent-imports': 'warn',
76
+ 'node/no-unsupported-features/node-builtins': 'warn',
77
+ 'no-duplicate-imports': 'warn',
78
+ 'import/exports-last': 'error',
79
+ 'node/no-callback-literal': 'error',
80
+ 'jsx-a11y/aria-role': 'error',
81
+ 'jsx-a11y/alt-text': 'error',
82
+ 'array-callback-return': [
83
+ 'error',
84
+ {
85
+ allowImplicit: false,
86
+ checkForEach: false
87
+ }
88
+ ],
89
+ 'object-shorthand': [
90
+ 'error',
91
+ 'always',
92
+ {
93
+ avoidQuotes: true,
94
+ ignoreConstructors: false
95
+ }
96
+ ]
97
+ }
98
+ }
99
+ ];
100
+ const src_finest = finest;
101
+ export { src_finest as default };
@@ -0,0 +1,12 @@
1
+ import type { ESLint, Linter } from 'eslint';
2
+ type ImportPlugin = ESLint.Plugin & {
3
+ flatConfigs: {
4
+ recommended: Linter.Config;
5
+ errors: Linter.Config;
6
+ warnings: Linter.Config;
7
+ typescript: Linter.Config;
8
+ react: Linter.Config;
9
+ };
10
+ };
11
+ declare const importPlugin: ImportPlugin;
12
+ export default importPlugin;