eslint-config-uphold 5.0.1 → 6.1.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 +49 -11
  2. package/package.json +34 -20
  3. package/src/index.js +134 -63
package/README.md CHANGED
@@ -7,26 +7,49 @@ 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
13
- $ npm install eslint eslint-config-uphold prettier --save-dev
17
+ npm install eslint eslint-config-uphold prettier --save-dev
14
18
  ```
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
  ```
@@ -34,19 +57,34 @@ Add a `lint` command to the `scripts` section of your `package.json`, like so:
34
57
  and run the linter with:
35
58
 
36
59
  ```sh
37
- $ npm run lint
60
+ npm run lint
38
61
  ```
39
62
 
40
63
  To automatically fix all lint issues, use the `--fix` option:
41
64
 
42
65
  ```sh
43
- $ npm run lint --fix
66
+ npm run lint --fix
44
67
  ```
45
68
 
46
- ## Upgrading eslint
69
+ ## Upgrading ESLint
70
+
71
+ See the [ESLint repo](https://github.com/eslint/eslint#semantic-versioning-policy) for ESLint's guidelines on semantic versioning.
72
+
73
+ A [tilde range](https://docs.npmjs.com/cli/v6/using-npm/semver#tilde-ranges-123-12-1) is set for the ESLint dependency to pick up any patch changes by default.
74
+
75
+ For any minor/major upgrades to ESLint it is recommended to update both `eslint` and `eslint-config-uphold` and keep them in parallel.
76
+ This is down to the fact that no guarantee is made that minor upgrades do not cause conflicts or issues with existing or new rules.
77
+ The downside here is a package update is required for any security or other bug fixes.
78
+ The benefit however is the included rules are always guaranteed to be stable.
79
+
80
+ ## Release process
81
+
82
+ The release of a version is automated via the [release](https://github.com/uphold/eslint-config-uphold/.github/workflows/release.yml) GitHub workflow.
83
+ Run it by clicking the "Run workflow" button.
47
84
 
48
- See the [eslint repo](https://github.com/eslint/eslint#semantic-versioning-policy) for eslint's guidelines on semantic versioning.
85
+ ## License
49
86
 
50
- A [tilde range](https://docs.npmjs.com/cli/v6/using-npm/semver#tilde-ranges-123-12-1) is set for the eslint dependency to pick up any patch changes by default.
87
+ MIT
51
88
 
52
- For any minor/major upgrades to `eslint` it is recommended to update both eslint and `eslint-config-uphold` and keep them in parallel. This is down to the fact that no guarantee is made that minor upgrades do not cause conflicts or issues with existing or new rules. The downside here is a package update is required for any security or other bug fixes. The benefit however is the included rules are always guaranteed to be stable.
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": "5.0.1",
3
+ "version": "6.1.0",
4
4
  "description": "Uphold-flavored ESLint config",
5
5
  "keywords": [
6
6
  "config",
@@ -22,42 +22,56 @@
22
22
  "files": [
23
23
  "src"
24
24
  ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
25
28
  "scripts": {
26
- "changelog": "echo \"$(github-changelog-generator --owner uphold --repo eslint-config-uphold --future-release=$npm_package_version)\n$(tail -n +2 CHANGELOG.md)\" > CHANGELOG.md",
27
29
  "lint": "eslint src test/index.js",
28
- "test": "mocha $npm_package_options_mocha",
29
- "version": "npm run changelog --future-release=$npm_package_version && git add -A CHANGELOG.md"
30
+ "release": "release-it",
31
+ "test": "mocha $npm_package_options_mocha"
30
32
  },
31
33
  "dependencies": {
32
- "@babel/core": "^7.21.4",
33
- "@babel/eslint-parser": "^7.21.3",
34
- "eslint-config-prettier": "^8.8.0",
35
- "eslint-plugin-mocha": "^10.1.0",
36
- "eslint-plugin-prettier": "^4.2.1",
37
- "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": "2.13.0",
38
+ "eslint-config-prettier": "^9.1.0",
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.1",
43
+ "eslint-plugin-promise": "^7.2.1",
38
44
  "eslint-plugin-rulesdir": "^0.2.2",
39
- "eslint-plugin-sort-destructure-keys": "^1.5.0",
40
- "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",
41
47
  "eslint-plugin-sort-keys-fix": "^1.1.2",
42
- "eslint-plugin-sql-template": "^2.0.0"
48
+ "eslint-plugin-sql-template": "^3.1.0",
49
+ "globals": "^15.15.0"
43
50
  },
44
51
  "devDependencies": {
45
- "@uphold/github-changelog-generator": "^3.3.1",
46
- "eslint": "^8.38.0",
47
- "mocha": "^10.2.0",
52
+ "@types/eslint": "^9.6.1",
53
+ "@uphold/github-changelog-generator": "^3.4.0",
54
+ "eslint": "9.22.0",
55
+ "mocha": "^10.4.0",
48
56
  "pre-commit": "^1.2.2",
49
- "prettier": "^2.8.7",
57
+ "prettier": "3.5.3",
58
+ "release-it": "^17.11.0",
50
59
  "should": "^13.2.3"
51
60
  },
52
61
  "peerDependencies": {
53
- "eslint": "^8.20.0",
54
- "prettier": "^2.8.7"
62
+ "eslint": "~9.22.0",
63
+ "prettier": ">=3.0.0"
64
+ },
65
+ "peerDependenciesMeta": {
66
+ "prettier": {
67
+ "optional": true
68
+ }
55
69
  },
56
70
  "pre-commit": [
57
71
  "lint"
58
72
  ],
59
73
  "engines": {
60
- "node": ">=14"
74
+ "node": ">=20"
61
75
  },
62
76
  "options": {
63
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
+ ];