@commercetools-backend/eslint-config-node 0.0.0-canary-20220329132038
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/CHANGELOG.md +19 -0
- package/LICENSE +21 -0
- package/README.md +25 -0
- package/helpers/eslint.js +8 -0
- package/index.js +221 -0
- package/package.json +46 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @commercetools-backend/eslint-config-node
|
|
2
|
+
|
|
3
|
+
## 0.0.0-canary-20220329132038
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2527](https://github.com/commercetools/merchant-center-application-kit/pull/2527) [`a6be74b0`](https://github.com/commercetools/merchant-center-application-kit/commit/a6be74b06223544e7ddae8bb71e3bac380b352f2) Thanks [@emmenko](https://github.com/emmenko)! - Add new ESLint config for Node.js projects. It includes TypeScript support.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
$ yarn add eslint @commercetools-backend/eslint-config-node
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
// .eslintrc.js
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
extends: ['@commercetools-backend/eslint-config-node'],
|
|
18
|
+
};
|
|
19
|
+
```
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 commercetools GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @commercetools-backend/eslint-config-node
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://www.npmjs.com/package/@commercetools-backend/eslint-config-node"><img src="https://badgen.net/npm/v/@commercetools-backend/eslint-config-node" alt="Latest release (latest dist-tag)" /></a> <a href="https://www.npmjs.com/package/@commercetools-backend/eslint-config-node"><img src="https://badgen.net/npm/v/@commercetools-backend/eslint-config-node/next" alt="Latest release (next dist-tag)" /></a> <a href="https://bundlephobia.com/result?p=@commercetools-backend/eslint-config-node"><img src="https://badgen.net/bundlephobia/minzip/@commercetools-backend/eslint-config-node" alt="Minified + GZipped size" /></a> <a href="https://github.com/commercetools/merchant-center-application-kit/blob/main/LICENSE"><img src="https://badgen.net/github/license/commercetools/merchant-center-application-kit" alt="GitHub license" /></a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
ESLint config for Node.js projects.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
$ npm install --save @commercetools-backend/eslint-config-node
|
|
13
|
+
|
|
14
|
+
$ npx install-peerdeps --dev @commercetools-backend/eslint-config-node
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
// .eslintrc.js
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
extends: ['@commercetools-backend/eslint-config-node'],
|
|
24
|
+
};
|
|
25
|
+
```
|
package/index.js
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// This is a workaround for https://github.com/eslint/eslint/issues/3458
|
|
2
|
+
require('@rushstack/eslint-patch/modern-module-resolution');
|
|
3
|
+
|
|
4
|
+
const { statusCode, allSupportedExtensions } = require('./helpers/eslint');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @type {import("eslint").Linter.Config}
|
|
8
|
+
*/
|
|
9
|
+
module.exports = {
|
|
10
|
+
root: true,
|
|
11
|
+
|
|
12
|
+
parser: '@babel/eslint-parser',
|
|
13
|
+
|
|
14
|
+
parserOptions: {
|
|
15
|
+
sourceType: 'module',
|
|
16
|
+
requireConfigFile: false,
|
|
17
|
+
/**
|
|
18
|
+
* @type {import('@babel/core').TransformOptions}
|
|
19
|
+
*/
|
|
20
|
+
babelOptions: {
|
|
21
|
+
presets: [['@babel/preset-env', { targets: { node: 'current' } }]],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
env: {
|
|
26
|
+
browser: false,
|
|
27
|
+
commonjs: true,
|
|
28
|
+
es6: true,
|
|
29
|
+
jest: true,
|
|
30
|
+
node: true,
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
extends: [
|
|
34
|
+
'eslint:recommended',
|
|
35
|
+
// https://github.com/mysticatea/eslint-plugin-node
|
|
36
|
+
'plugin:node/recommended',
|
|
37
|
+
// https://github.com/benmosher/eslint-plugin-import
|
|
38
|
+
'plugin:import/errors',
|
|
39
|
+
'plugin:import/warnings',
|
|
40
|
+
// https://github.com/jest-community/eslint-plugin-jest
|
|
41
|
+
'plugin:jest/recommended',
|
|
42
|
+
// NOTE: this should go last.
|
|
43
|
+
'prettier',
|
|
44
|
+
],
|
|
45
|
+
|
|
46
|
+
plugins: [
|
|
47
|
+
// https://github.com/import-js/eslint-plugin-import
|
|
48
|
+
'import',
|
|
49
|
+
// https://github.com/jest-community/eslint-plugin-jest
|
|
50
|
+
'jest',
|
|
51
|
+
// https://github.com/prettier/prettier-eslint
|
|
52
|
+
'prettier',
|
|
53
|
+
],
|
|
54
|
+
|
|
55
|
+
settings: {
|
|
56
|
+
'import/resolver': {
|
|
57
|
+
node: {
|
|
58
|
+
extensions: allSupportedExtensions,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
rules: {
|
|
64
|
+
// Nodejs
|
|
65
|
+
'node/no-missing-import': statusCode.off,
|
|
66
|
+
'node/no-unsupported-features/es-syntax': statusCode.off,
|
|
67
|
+
|
|
68
|
+
// NOTE: The regular rule does not support do-expressions. The equivalent rule of babel does.
|
|
69
|
+
'no-unused-expressions': statusCode.off,
|
|
70
|
+
|
|
71
|
+
// Imports
|
|
72
|
+
'import/extensions': [
|
|
73
|
+
statusCode.error,
|
|
74
|
+
{
|
|
75
|
+
js: 'never',
|
|
76
|
+
jsx: 'never',
|
|
77
|
+
ts: 'never',
|
|
78
|
+
tsx: 'never',
|
|
79
|
+
mjs: 'never',
|
|
80
|
+
json: 'always',
|
|
81
|
+
svg: 'always',
|
|
82
|
+
graphql: 'always',
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
'import/default': statusCode.off,
|
|
86
|
+
'import/first': statusCode.error,
|
|
87
|
+
// TODO: enable this once there is support for `import type`
|
|
88
|
+
// 'import/order': statusCode.error,
|
|
89
|
+
'import/named': statusCode.off,
|
|
90
|
+
'import/namespace': statusCode.off,
|
|
91
|
+
'import/no-extraneous-dependencies': statusCode.off,
|
|
92
|
+
'import/no-named-as-default': statusCode.off,
|
|
93
|
+
'import/no-named-as-default-member': statusCode.off,
|
|
94
|
+
'import/no-unresolved': statusCode.error,
|
|
95
|
+
|
|
96
|
+
// Jest
|
|
97
|
+
'jest/expect-expect': statusCode.off,
|
|
98
|
+
'jest/no-identical-title': statusCode.warn,
|
|
99
|
+
'jest/no-focused-tests': statusCode.error,
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
overrides: [
|
|
103
|
+
{
|
|
104
|
+
files: ['*.{spec,test}.*'],
|
|
105
|
+
env: {
|
|
106
|
+
'jest/globals': true,
|
|
107
|
+
},
|
|
108
|
+
rules: {
|
|
109
|
+
'node/no-extraneous-require': [
|
|
110
|
+
statusCode.error,
|
|
111
|
+
{
|
|
112
|
+
allowModules: ['jest-each', 'msw'],
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
// https://github.com/jest-community/eslint-plugin-jest
|
|
116
|
+
'jest/no-conditional-expect': statusCode.error,
|
|
117
|
+
'jest/no-identical-title': statusCode.error,
|
|
118
|
+
'jest/no-interpolation-in-snapshots': statusCode.error,
|
|
119
|
+
'jest/no-jasmine-globals': statusCode.error,
|
|
120
|
+
'jest/no-jest-import': statusCode.error,
|
|
121
|
+
'jest/no-mocks-import': statusCode.error,
|
|
122
|
+
'jest/valid-describe-callback': statusCode.error,
|
|
123
|
+
'jest/valid-expect': statusCode.error,
|
|
124
|
+
'jest/valid-expect-in-promise': statusCode.error,
|
|
125
|
+
'jest/valid-title': statusCode.warn,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
files: ['**/*.ts?(x)'],
|
|
130
|
+
parser: '@typescript-eslint/parser',
|
|
131
|
+
parserOptions: {
|
|
132
|
+
ecmaVersion: 2022,
|
|
133
|
+
sourceType: 'module',
|
|
134
|
+
// typescript-eslint specific options
|
|
135
|
+
warnOnUnsupportedTypeScriptVersion: true,
|
|
136
|
+
/**
|
|
137
|
+
* @type {import('@babel/core').TransformOptions}
|
|
138
|
+
*/
|
|
139
|
+
babelOptions: {
|
|
140
|
+
presets: [
|
|
141
|
+
['@babel/preset-env', { targets: { node: 'current' } }],
|
|
142
|
+
['@babel/preset-typescript'],
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
plugins: ['@typescript-eslint'],
|
|
147
|
+
rules: {
|
|
148
|
+
// TypeScript's `noFallthroughCasesInSwitch` option is more robust (#6906)
|
|
149
|
+
'default-case': statusCode.off,
|
|
150
|
+
// 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/291)
|
|
151
|
+
'no-dupe-class-members': statusCode.off,
|
|
152
|
+
// 'tsc' already handles this (https://github.com/typescript-eslint/typescript-eslint/issues/477)
|
|
153
|
+
'no-undef': statusCode.off,
|
|
154
|
+
|
|
155
|
+
// Add TypeScript specific rules (and turn off ESLint equivalents)
|
|
156
|
+
'@typescript-eslint/consistent-type-assertions': statusCode.warn,
|
|
157
|
+
'no-array-constructor': statusCode.off,
|
|
158
|
+
'@typescript-eslint/no-array-constructor': statusCode.warn,
|
|
159
|
+
'no-redeclare': statusCode.off,
|
|
160
|
+
'@typescript-eslint/no-redeclare': statusCode.warn,
|
|
161
|
+
'no-use-before-define': statusCode.off,
|
|
162
|
+
'@typescript-eslint/no-use-before-define': [
|
|
163
|
+
statusCode.error,
|
|
164
|
+
{
|
|
165
|
+
functions: false,
|
|
166
|
+
classes: false,
|
|
167
|
+
variables: false,
|
|
168
|
+
typedefs: false,
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
'no-unused-expressions': statusCode.off,
|
|
172
|
+
'@typescript-eslint/no-unused-expressions': [
|
|
173
|
+
statusCode.error,
|
|
174
|
+
{
|
|
175
|
+
allowShortCircuit: true,
|
|
176
|
+
allowTernary: true,
|
|
177
|
+
allowTaggedTemplates: true,
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
'no-unused-vars': statusCode.off,
|
|
181
|
+
'@typescript-eslint/no-unused-vars': [
|
|
182
|
+
statusCode.warn,
|
|
183
|
+
{
|
|
184
|
+
args: 'none',
|
|
185
|
+
ignoreRestSiblings: true,
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
'no-useless-constructor': statusCode.off,
|
|
189
|
+
'@typescript-eslint/no-useless-constructor': statusCode.warn,
|
|
190
|
+
|
|
191
|
+
// TypeScript
|
|
192
|
+
'@typescript-eslint/ban-types': statusCode.off,
|
|
193
|
+
'@typescript-eslint/naming-convention': statusCode.off,
|
|
194
|
+
'@typescript-eslint/consistent-type-definitions': statusCode.off,
|
|
195
|
+
'@typescript-eslint/no-explicit-any': statusCode.error,
|
|
196
|
+
'@typescript-eslint/no-var-requires': statusCode.off,
|
|
197
|
+
'@typescript-eslint/unbound-method': statusCode.off,
|
|
198
|
+
'@typescript-eslint/ban-ts-comment': statusCode.off,
|
|
199
|
+
'@typescript-eslint/explicit-function-return-type': statusCode.off,
|
|
200
|
+
'@typescript-eslint/explicit-member-accessibility': [
|
|
201
|
+
statusCode.error,
|
|
202
|
+
{ accessibility: 'no-public' },
|
|
203
|
+
],
|
|
204
|
+
'@typescript-eslint/no-require-imports': statusCode.off,
|
|
205
|
+
'@typescript-eslint/promise-function-async': statusCode.off,
|
|
206
|
+
},
|
|
207
|
+
settings: {
|
|
208
|
+
'import/parsers': {
|
|
209
|
+
'@typescript-eslint/parser': allSupportedExtensions,
|
|
210
|
+
},
|
|
211
|
+
'import/resolver': {
|
|
212
|
+
'eslint-import-resolver-typescript': true,
|
|
213
|
+
typescript: {},
|
|
214
|
+
node: {
|
|
215
|
+
extensions: allSupportedExtensions,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@commercetools-backend/eslint-config-node",
|
|
3
|
+
"version": "0.0.0-canary-20220329132038",
|
|
4
|
+
"description": "ESLint config for Node.js projects.",
|
|
5
|
+
"bugs": "https://github.com/commercetools/merchant-center-application-kit/issues",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/commercetools/merchant-center-application-kit.git",
|
|
9
|
+
"directory": "packages-backend/eslint-config-node"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://docs.commercetools.com/custom-applications",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"javascript",
|
|
14
|
+
"nodejs",
|
|
15
|
+
"toolkit",
|
|
16
|
+
"eslint"
|
|
17
|
+
],
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "public"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@babel/core": "^7.17.8",
|
|
24
|
+
"@babel/eslint-parser": "^7.17.0",
|
|
25
|
+
"@babel/preset-env": "^7.16.11",
|
|
26
|
+
"@babel/preset-typescript": "^7.16.7",
|
|
27
|
+
"@rushstack/eslint-patch": "^1.1.1",
|
|
28
|
+
"@typescript-eslint/eslint-plugin": "^5.16.0",
|
|
29
|
+
"@typescript-eslint/parser": "^5.16.0",
|
|
30
|
+
"eslint-config-prettier": "^8.5.0",
|
|
31
|
+
"eslint-import-resolver-typescript": "^2.7.0",
|
|
32
|
+
"eslint-plugin-import": "^2.25.4",
|
|
33
|
+
"eslint-plugin-jest": "^25.7.0",
|
|
34
|
+
"eslint-plugin-node": "^11.1.0",
|
|
35
|
+
"eslint-plugin-prettier": "^4.0.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"eslint": "8.x"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"eslint": "8.11.0"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=14"
|
|
45
|
+
}
|
|
46
|
+
}
|