eslint-config-uphold 6.0.0 → 6.2.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.
Files changed (3) hide show
  1. package/README.md +30 -4
  2. package/package.json +30 -19
  3. package/src/index.js +134 -63
package/README.md CHANGED
@@ -7,6 +7,10 @@ extend the [eslint-recommended](https://github.com/eslint/eslint/blob/master/con
7
7
  as well as the [overrides](https://github.com/prettier/eslint-config-prettier/blob/master/index.js)
8
8
  that allow the [Prettier](https://prettier.io) pretty-printer to reformat the code without conflicts.
9
9
 
10
+ ## Status
11
+
12
+ [![npm version][npm-image]][npm-url]
13
+
10
14
  ## Installation
11
15
 
12
16
  ```sh
@@ -15,18 +19,37 @@ npm install eslint eslint-config-uphold prettier --save-dev
15
19
 
16
20
  ## Usage
17
21
 
18
- Create an `.eslintrc.yml` file with the following content:
22
+ Create an `eslint.config.js` file with the following content:
23
+
24
+ ```js
25
+ const uphold = require('eslint-config-uphold');
26
+
27
+ module.exports = uphold;
28
+ ```
29
+
30
+ If you'd like to extend the config, you can do so like this:
31
+
32
+ ```js
33
+ const uphold = require('eslint-config-uphold');
34
+ const yourPlugin = require('your-eslint-plugin');
19
35
 
20
- ```yaml
21
- extends: uphold
36
+ module.exports = [
37
+ ...uphold,
38
+ plugins: {
39
+ ...uphold[0].plugins,
40
+ yourPlugin,
41
+ }
42
+ ];
22
43
  ```
23
44
 
45
+ See [Using a Shareable Config](https://eslint.org/docs/latest/extend/shareable-configs#using-a-shareable-config) for more information.
46
+
24
47
  Add a `lint` command to the `scripts` section of your `package.json`, like so:
25
48
 
26
49
  ```json
27
50
  {
28
51
  "scripts": {
29
- "lint": "eslint ."
52
+ "lint": "eslint"
30
53
  }
31
54
  }
32
55
  ```
@@ -62,3 +85,6 @@ Run it by clicking the "Run workflow" button.
62
85
  ## License
63
86
 
64
87
  MIT
88
+
89
+ [npm-image]: https://img.shields.io/npm/v/eslint-config-uphold.svg
90
+ [npm-url]: https://www.npmjs.com/package/eslint-config-uphold
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-config-uphold",
3
- "version": "6.0.0",
3
+ "version": "6.2.0",
4
4
  "description": "Uphold-flavored ESLint config",
5
5
  "keywords": [
6
6
  "config",
@@ -31,36 +31,47 @@
31
31
  "test": "mocha $npm_package_options_mocha"
32
32
  },
33
33
  "dependencies": {
34
- "@babel/core": "^7.23.6",
35
- "@babel/eslint-parser": "^7.23.3",
36
- "eslint-config-prettier": "^8.8.0",
37
- "eslint-plugin-mocha": "^10.1.0",
38
- "eslint-plugin-prettier": "^4.2.1",
39
- "eslint-plugin-promise": "^6.1.1",
34
+ "@babel/core": "^7.26.10",
35
+ "@babel/eslint-parser": "^7.26.10",
36
+ "@eslint/js": "^9.22.0",
37
+ "@stylistic/eslint-plugin-js": "4.2.0",
38
+ "eslint-config-prettier": "^10.1.1",
39
+ "eslint-plugin-jsdoc": "^50.6.8",
40
+ "eslint-plugin-mocha": "^10.5.0",
41
+ "eslint-plugin-n": "^17.16.2",
42
+ "eslint-plugin-prettier": "^5.2.3",
43
+ "eslint-plugin-promise": "^7.2.1",
40
44
  "eslint-plugin-rulesdir": "^0.2.2",
41
- "eslint-plugin-sort-destructure-keys": "^1.5.0",
42
- "eslint-plugin-sort-imports-requires": "^1.0.2",
45
+ "eslint-plugin-sort-destructure-keys": "^2.0.0",
46
+ "eslint-plugin-sort-imports-requires": "^2.0.0",
43
47
  "eslint-plugin-sort-keys-fix": "^1.1.2",
44
- "eslint-plugin-sql-template": "^2.0.0"
48
+ "eslint-plugin-sql-template": "^3.1.0",
49
+ "globals": "^16.0.0"
45
50
  },
46
51
  "devDependencies": {
47
- "@uphold/github-changelog-generator": "^3.4.0",
48
- "eslint": "^8.56.0",
49
- "mocha": "^10.2.0",
50
- "pre-commit": "^1.2.2",
51
- "prettier": "^2.8.7",
52
- "release-it": "^17.1.1",
52
+ "@fastify/pre-commit": "^2.2.0",
53
+ "@types/eslint": "^9.6.1",
54
+ "@uphold/github-changelog-generator": "^4.0.2",
55
+ "eslint": "^9.22.0",
56
+ "mocha": "^11.1.0",
57
+ "prettier": "^3.5.3",
58
+ "release-it": "^18.1.2",
53
59
  "should": "^13.2.3"
54
60
  },
55
61
  "peerDependencies": {
56
- "eslint": "^8.20.0",
57
- "prettier": "^2.8.7"
62
+ "eslint": "~9.22.0",
63
+ "prettier": ">=3.0.0"
64
+ },
65
+ "peerDependenciesMeta": {
66
+ "prettier": {
67
+ "optional": true
68
+ }
58
69
  },
59
70
  "pre-commit": [
60
71
  "lint"
61
72
  ],
62
73
  "engines": {
63
- "node": ">=18"
74
+ "node": ">=20"
64
75
  },
65
76
  "options": {
66
77
  "mocha": "-t 10000 --require should test"
package/src/index.js CHANGED
@@ -1,51 +1,71 @@
1
1
  /**
2
2
  * Module dependencies.
3
+ *
4
+ * @typedef {import('eslint').Linter.Config} LinterConfig
3
5
  */
4
6
 
7
+ const babelParser = require('@babel/eslint-parser');
8
+ const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
9
+ const globals = require('globals');
10
+ const js = require('@eslint/js');
11
+ const jsdoc = require('eslint-plugin-jsdoc');
12
+ const mocha = require('eslint-plugin-mocha');
13
+ const nodePlugin = require('eslint-plugin-n');
14
+ const path = require('node:path');
15
+ const promise = require('eslint-plugin-promise');
5
16
  const rulesDir = require('eslint-plugin-rulesdir');
17
+ const sortDestructureKeys = require('eslint-plugin-sort-destructure-keys');
18
+ const sortImportsRequires = require('eslint-plugin-sort-imports-requires');
19
+ const sortKeysFix = require('eslint-plugin-sort-keys-fix');
20
+ const sqlTemplate = require('eslint-plugin-sql-template');
21
+ const stylistic = require('@stylistic/eslint-plugin-js');
6
22
 
7
23
  /**
8
- * Configure the rulesdir plugin.
24
+ * Configure the `rulesDir` plugin.
9
25
  */
10
26
 
11
- rulesDir.RULES_DIR = `${__dirname}/rules`;
27
+ rulesDir.RULES_DIR = path.join(__dirname, 'rules');
12
28
 
13
29
  /**
14
- * Export `uphold` shared configuration preset.
30
+ * Language options.
31
+ *
32
+ * @type {LinterConfig['languageOptions']}
15
33
  */
16
-
17
- module.exports = {
18
- env: {
19
- es6: true,
20
- jasmine: true,
21
- jest: true,
22
- mocha: true,
23
- node: true
34
+ const languageOptions = {
35
+ ecmaVersion: 2020,
36
+ globals: {
37
+ ...globals.jasmine,
38
+ ...globals.jest,
39
+ ...globals.mocha,
40
+ ...globals.node
24
41
  },
25
- extends: ['eslint:recommended', 'plugin:prettier/recommended'],
26
- overrides: [
27
- {
28
- files: ['**/bin/**', '**/scripts/**'],
29
- rules: {
30
- 'no-console': 'off'
31
- }
32
- }
33
- ],
34
- parser: '@babel/eslint-parser',
42
+ parser: babelParser,
35
43
  parserOptions: {
36
44
  requireConfigFile: false
45
+ }
46
+ };
47
+
48
+ /**
49
+ * Base configuration for Uphold.
50
+ *
51
+ * @type {LinterConfig}
52
+ */
53
+ const upholdBaseConfig = {
54
+ languageOptions,
55
+ plugins: {
56
+ jsdoc,
57
+ mocha,
58
+ 'node-plugin': nodePlugin,
59
+ promise,
60
+ rulesdir: rulesDir,
61
+ 'sort-destructure-keys': sortDestructureKeys,
62
+ 'sort-imports-requires': sortImportsRequires,
63
+ 'sort-keys-fix': sortKeysFix,
64
+ 'sql-template': sqlTemplate,
65
+ stylistic
37
66
  },
38
- plugins: [
39
- 'mocha',
40
- 'promise',
41
- 'rulesdir',
42
- 'sort-destructure-keys',
43
- 'sort-imports-requires',
44
- 'sort-keys-fix',
45
- 'sql-template'
46
- ],
47
- root: true,
48
67
  rules: {
68
+ ...js.configs.recommended.rules,
49
69
  'accessor-pairs': 'error',
50
70
  'array-callback-return': 'error',
51
71
  'block-scoped-var': 'error',
@@ -59,8 +79,15 @@ module.exports = {
59
79
  'id-match': [
60
80
  'error',
61
81
  '^_$|^[$_a-zA-Z]*[_a-zA-Z0-9]*[a-zA-Z0-9]*$|^[A-Z][_A-Z0-9]+[A-Z0-9]$',
62
- { onlyDeclarations: true, properties: true }
82
+ {
83
+ onlyDeclarations: true,
84
+ properties: true
85
+ }
63
86
  ],
87
+ 'jsdoc/no-defaults': 0,
88
+ 'jsdoc/require-description-complete-sentence': 'error',
89
+ 'jsdoc/require-jsdoc': 0,
90
+ 'jsdoc/tag-lines': 0,
64
91
  'max-depth': 'error',
65
92
  'max-params': ['error', 4],
66
93
  'mocha/no-exclusive-tests': 'error',
@@ -90,50 +117,52 @@ module.exports = {
90
117
  'no-lone-blocks': 'error',
91
118
  'no-lonely-if': 'error',
92
119
  'no-loop-func': 'error',
93
- 'no-mixed-requires': 'error',
94
120
  'no-multi-str': 'error',
95
121
  'no-nested-ternary': 'error',
96
122
  'no-new': 'error',
97
123
  'no-new-func': 'error',
98
- 'no-new-object': 'error',
99
- 'no-new-require': 'error',
100
124
  'no-new-wrappers': 'error',
125
+ 'no-object-constructor': 'error',
101
126
  'no-octal-escape': 'error',
102
- 'no-path-concat': 'error',
103
- 'no-process-env': 'error',
104
- 'no-process-exit': 'error',
105
127
  'no-proto': 'error',
106
- 'no-restricted-modules': 'error',
107
128
  'no-return-assign': 'error',
108
129
  'no-script-url': 'error',
109
130
  'no-self-compare': 'error',
110
131
  'no-sequences': 'error',
111
- 'no-sync': 'error',
112
- 'no-tabs': ['error', { allowIndentationTabs: true }],
113
132
  'no-throw-literal': 'error',
114
133
  'no-undef-init': 'error',
115
134
  'no-underscore-dangle': 'error',
116
135
  'no-unneeded-ternary': 'error',
117
136
  'no-unused-expressions': 'error',
137
+ 'no-unused-vars': ['error', { caughtErrors: 'none' }],
118
138
  'no-use-before-define': 'error',
119
139
  'no-useless-call': 'error',
120
140
  'no-useless-concat': 'error',
121
141
  'no-var': 'error',
122
142
  'no-void': 'error',
143
+ 'node-plugin/no-mixed-requires': 'error',
144
+ 'node-plugin/no-new-require': 'error',
145
+ 'node-plugin/no-path-concat': 'error',
146
+ 'node-plugin/no-process-env': 'error',
147
+ 'node-plugin/no-process-exit': 'error',
148
+ 'node-plugin/no-restricted-import': 'error',
149
+ 'node-plugin/no-restricted-require': 'error',
150
+ 'node-plugin/no-sync': 'error',
123
151
  'object-shorthand': 'error',
124
152
  'operator-assignment': 'error',
125
- 'padding-line-between-statements': [
126
- 'error',
127
- { blankLine: 'always', next: 'return', prev: '*' },
128
- { blankLine: 'always', next: '*', prev: ['const', 'let', 'var'] },
129
- { blankLine: 'any', next: ['const', 'let', 'var'], prev: ['const', 'let', 'var'] }
130
- ],
131
153
  'prefer-const': 'error',
132
154
  'prefer-destructuring': [
133
155
  'error',
134
156
  {
135
- AssignmentExpression: { array: false, object: false },
136
- VariableDeclarator: { array: true, object: true }
157
+ AssignmentExpression: {
158
+ array: false,
159
+ object: false
160
+ },
161
+
162
+ VariableDeclarator: {
163
+ array: true,
164
+ object: true
165
+ }
137
166
  },
138
167
  {
139
168
  enforceForRenamedProperties: false
@@ -141,33 +170,75 @@ module.exports = {
141
170
  ],
142
171
  'prefer-spread': 'error',
143
172
  'prefer-template': 'error',
144
- 'prettier/prettier': ['error', { arrowParens: 'avoid', printWidth: 120, singleQuote: true, trailingComma: 'none' }],
173
+ 'prettier/prettier': [
174
+ 'error',
175
+ {
176
+ arrowParens: 'avoid',
177
+ printWidth: 120,
178
+ singleQuote: true,
179
+ trailingComma: 'none'
180
+ }
181
+ ],
145
182
  'promise/prefer-await-to-then': 'error',
146
183
  radix: 'error',
147
184
  'require-atomic-updates': 'off',
148
185
  'require-await': 'error',
149
186
  'rulesdir/explicit-sinon-use-fake-timers': 'error',
150
187
  'sort-destructure-keys/sort-destructure-keys': 'error',
151
- 'sort-imports-requires/sort-imports': [
188
+ 'sort-imports-requires/sort-imports': ['error', { unsafeAutofix: true, useOldSingleMemberSyntax: true }],
189
+ 'sort-imports-requires/sort-requires': [
152
190
  'error',
153
- {
154
- unsafeAutofix: true,
155
- useOldSingleMemberSyntax: true
156
- }
191
+ { unsafeAutofix: true, useAliases: false, useOldSingleMemberSyntax: true }
157
192
  ],
158
- 'sort-imports-requires/sort-requires': [
193
+ 'sort-keys-fix/sort-keys-fix': ['error', 'asc', { natural: true }],
194
+ 'sql-template/no-unsafe-query': 'error',
195
+ 'stylistic/no-tabs': ['error', { allowIndentationTabs: true }],
196
+ 'stylistic/padding-line-between-statements': [
159
197
  'error',
160
198
  {
161
- unsafeAutofix: true,
162
- useAliases: false,
163
- useOldSingleMemberSyntax: true
199
+ blankLine: 'always',
200
+ next: 'return',
201
+ prev: '*'
202
+ },
203
+ {
204
+ blankLine: 'always',
205
+ next: '*',
206
+ prev: ['const', 'let', 'var']
207
+ },
208
+ {
209
+ blankLine: 'any',
210
+ next: ['const', 'let', 'var'],
211
+ prev: ['const', 'let', 'var']
164
212
  }
165
213
  ],
166
- 'sort-keys-fix/sort-keys-fix': ['error', 'asc', { natural: true }],
167
- 'spaced-comment': 'error',
168
- 'sql-template/no-unsafe-query': 'error',
169
- 'valid-jsdoc': 'error',
214
+ 'stylistic/spaced-comment': 'error',
170
215
  'vars-on-top': 'error',
171
216
  yoda: 'error'
172
217
  }
173
218
  };
219
+
220
+ /**
221
+ * Configuration for bin and scripts files.
222
+ *
223
+ * @type {LinterConfig}
224
+ */
225
+ const upholdBinScriptsConfig = {
226
+ files: ['**/bin/**', '**/scripts/**'],
227
+ languageOptions,
228
+ rules: {
229
+ 'no-console': 'off',
230
+ 'node-plugin/no-process-exit': 'off'
231
+ }
232
+ };
233
+
234
+ /**
235
+ * Export `uphold` shared configuration preset.
236
+ *
237
+ * @type {LinterConfig[]}
238
+ */
239
+ module.exports = [
240
+ jsdoc.configs['flat/recommended-error'],
241
+ eslintPluginPrettierRecommended,
242
+ upholdBaseConfig,
243
+ upholdBinScriptsConfig
244
+ ];