@enormora/eslint-config-mocha 0.0.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2023]
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/constants.js ADDED
@@ -0,0 +1,4 @@
1
+ export const ecmaVersion = 2022;
2
+ export const indentSize = 4;
3
+ export const javascriptExtensions = ['.js', '.cjs', '.mjs'];
4
+ export const typescriptExtensions = ['.ts', '.cts', '.mts'];
package/mocha.js ADDED
@@ -0,0 +1,39 @@
1
+ import mochaPlugin from 'eslint-plugin-mocha';
2
+ import globals from 'globals';
3
+ import { testRuleSet } from './rule-sets/test-rules.js';
4
+
5
+ export const mochaConfig = {
6
+ plugins: {
7
+ mocha: mochaPlugin
8
+ },
9
+ languageOptions: {
10
+ globals: globals.mocha
11
+ },
12
+ rules: {
13
+ ...testRuleSet.rules,
14
+
15
+ 'mocha/handle-done-callback': 'error',
16
+ 'mocha/max-top-level-suites': 'error',
17
+ 'mocha/no-async-describe': 'error',
18
+ 'mocha/no-empty-description': 'error',
19
+ 'mocha/no-exclusive-tests': 'error',
20
+ 'mocha/no-exports': 'error',
21
+ 'mocha/no-global-tests': 'error',
22
+ 'mocha/no-hooks': 'error',
23
+ 'mocha/no-hooks-for-single-case': 'error',
24
+ 'mocha/no-identical-title': 'error',
25
+ 'mocha/no-mocha-arrows': 'error',
26
+ 'mocha/no-nested-tests': 'error',
27
+ 'mocha/no-pending-tests': 'error',
28
+ 'mocha/no-return-and-callback': 'error',
29
+ 'mocha/no-return-from-async': 'off',
30
+ 'mocha/no-setup-in-describe': 'error',
31
+ 'mocha/no-sibling-hooks': 'error',
32
+ 'mocha/no-skipped-tests': 'error',
33
+ 'mocha/no-synchronous-tests': 'off',
34
+ 'mocha/no-top-level-hooks': 'error',
35
+ 'mocha/prefer-arrow-callback': 'off',
36
+ 'mocha/valid-suite-description': 'off',
37
+ 'mocha/valid-test-description': 'off'
38
+ }
39
+ };
package/package.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "dependencies": {
3
+ "@stylistic/eslint-plugin": "1.5.1",
4
+ "eslint-plugin-destructuring": "2.2.1",
5
+ "eslint-plugin-mocha": "10.2.0",
6
+ "eslint-plugin-prettier": "5.0.1",
7
+ "globals": "13.21.0"
8
+ },
9
+ "license": "MIT",
10
+ "main": "mocha.js",
11
+ "name": "@enormora/eslint-config-mocha",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git://github.com/enormora/eslint-config.git"
15
+ },
16
+ "type": "module",
17
+ "version": "0.0.1"
18
+ }
@@ -0,0 +1,234 @@
1
+ import prettierPlugin from 'eslint-plugin-prettier';
2
+ import destructuringPlugin from 'eslint-plugin-destructuring';
3
+ import stylisticPlugin from '@stylistic/eslint-plugin';
4
+ import { indentSize } from '../constants.js';
5
+
6
+ export const stylisticRuleSet = {
7
+ plugins: {
8
+ prettier: prettierPlugin,
9
+ destructuring: destructuringPlugin,
10
+ '@stylistic': stylisticPlugin
11
+ },
12
+
13
+ settings: {},
14
+
15
+ rules: {
16
+ 'prettier/prettier': 'error',
17
+
18
+ 'destructuring/in-methods-params': 'error',
19
+ 'destructuring/in-params': ['error', { 'max-params': 0 }],
20
+ 'destructuring/no-rename': 'off',
21
+
22
+ '@stylistic/array-bracket-newline': ['error', 'consistent'],
23
+ '@stylistic/array-bracket-spacing': ['error', 'never'],
24
+ '@stylistic/array-element-newline': ['error', 'consistent'],
25
+ '@stylistic/arrow-parens': ['error', 'always'],
26
+ '@stylistic/arrow-spacing': [
27
+ 'error',
28
+ {
29
+ before: true,
30
+ after: true
31
+ }
32
+ ],
33
+ '@stylistic/block-spacing': 'off',
34
+ '@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: false }],
35
+ '@stylistic/comma-dangle': ['error', 'never'],
36
+ '@stylistic/comma-spacing': [
37
+ 'error',
38
+ {
39
+ before: false,
40
+ after: true
41
+ }
42
+ ],
43
+ '@stylistic/comma-style': ['error', 'last'],
44
+ '@stylistic/computed-property-spacing': [
45
+ 'error',
46
+ 'never',
47
+ {
48
+ enforceForClassMembers: true
49
+ }
50
+ ],
51
+ '@stylistic/dot-location': ['error', 'property'],
52
+ '@stylistic/eol-last': 'error',
53
+ '@stylistic/func-call-spacing': ['error', 'never'],
54
+ '@stylistic/function-call-spacing': ['error', 'never'],
55
+ '@stylistic/function-call-argument-newline': ['error', 'consistent'],
56
+ '@stylistic/function-paren-newline': 'off',
57
+ '@stylistic/generator-star-spacing': ['error', { before: false, after: true }],
58
+ '@stylistic/indent-binary-ops': ['error', indentSize],
59
+ '@stylistic/implicit-arrow-linebreak': 'off',
60
+ '@stylistic/indent': [
61
+ 'error',
62
+ indentSize,
63
+ {
64
+ SwitchCase: 1,
65
+ VariableDeclarator: 1,
66
+ MemberExpression: 1
67
+ }
68
+ ],
69
+ '@stylistic/jsx-child-element-spacing': 'off',
70
+ '@stylistic/jsx-closing-bracket-location': 'off',
71
+ '@stylistic/jsx-closing-tag-location': 'off',
72
+ '@stylistic/jsx-curly-brace-presence': 'off',
73
+ '@stylistic/jsx-curly-newline': 'off',
74
+ '@stylistic/jsx-curly-spacing': 'off',
75
+ '@stylistic/jsx-equals-spacing': 'off',
76
+ '@stylistic/jsx-first-prop-new-line': 'off',
77
+ '@stylistic/jsx-indent': 'off',
78
+ '@stylistic/jsx-indent-props': 'off',
79
+ '@stylistic/jsx-max-props-per-line': 'off',
80
+ '@stylistic/jsx-newline': 'off',
81
+ '@stylistic/jsx-one-expression-per-line': 'off',
82
+ '@stylistic/jsx-props-no-multi-spaces': 'off',
83
+ '@stylistic/jsx-self-closing-comp': 'off',
84
+ '@stylistic/jsx-sort-props': 'off',
85
+ '@stylistic/jsx-tag-spacing': 'off',
86
+ '@stylistic/jsx-quotes': 'off',
87
+ '@stylistic/jsx-wrap-multilines': 'off',
88
+ '@stylistic/key-spacing': [
89
+ 'error',
90
+ {
91
+ beforeColon: false,
92
+ afterColon: true
93
+ }
94
+ ],
95
+ '@stylistic/keyword-spacing': [
96
+ 'error',
97
+ {
98
+ before: true,
99
+ after: true
100
+ }
101
+ ],
102
+ '@stylistic/linebreak-style': ['error', 'unix'],
103
+ '@stylistic/lines-between-class-members': [
104
+ 'error',
105
+ 'always',
106
+ {
107
+ exceptAfterSingleLine: true
108
+ }
109
+ ],
110
+ '@stylistic/lines-around-comment': 'off',
111
+ '@stylistic/max-len': [
112
+ 'error',
113
+ {
114
+ code: 120,
115
+ tabWidth: indentSize,
116
+ ignoreComments: true,
117
+ ignoreTrailingComments: true,
118
+ ignoreUrls: true,
119
+ ignoreStrings: false,
120
+ ignoreTemplateLiterals: false,
121
+ ignoreRegExpLiterals: true
122
+ }
123
+ ],
124
+ '@stylistic/max-statements-per-line': ['error', { max: 1 }],
125
+ '@stylistic/member-delimiter-style': [
126
+ 'error',
127
+ {
128
+ multiline: {
129
+ delimiter: 'semi',
130
+ requireLast: true
131
+ },
132
+ singleline: {
133
+ delimiter: 'semi',
134
+ requireLast: false
135
+ }
136
+ }
137
+ ],
138
+ '@stylistic/multiline-ternary': 'off',
139
+ '@stylistic/new-parens': 'error',
140
+ '@stylistic/newline-per-chained-call': 'off',
141
+ '@stylistic/no-confusing-arrow': 'error',
142
+ // Currently this rule conflicts with prettier, because in some cases prettier adds unnecessary extra parens. Unfortunately there is no way to turn this off yet. We should re-enable this rule once this has been fixed in prettier or once there is a better formatter that doesn’t add unnecessary parens. See https://github.com/prettier/prettier/issues/3089
143
+ '@stylistic/no-extra-parens': 'off',
144
+ '@stylistic/no-extra-semi': 'error',
145
+ '@stylistic/no-floating-decimal': 'error',
146
+ '@stylistic/no-mixed-operators': 'off',
147
+ '@stylistic/no-mixed-spaces-and-tabs': 'error',
148
+ '@stylistic/no-multi-spaces': 'error',
149
+ '@stylistic/no-multiple-empty-lines': ['error', { max: 1 }],
150
+ '@stylistic/no-tabs': 'error',
151
+ '@stylistic/no-trailing-spaces': 'error',
152
+ '@stylistic/no-whitespace-before-property': 'error',
153
+ '@stylistic/nonblock-statement-body-position': 'off',
154
+ '@stylistic/object-curly-newline': 'off',
155
+ '@stylistic/object-curly-spacing': ['error', 'always'],
156
+ '@stylistic/object-property-newline': 'off',
157
+ '@stylistic/one-var-declaration-per-line': 'error',
158
+ '@stylistic/operator-linebreak': ['error', 'after', { overrides: { '?': 'before', ':': 'before' } }],
159
+ '@stylistic/padded-blocks': [
160
+ 'error',
161
+ 'never',
162
+ {
163
+ allowSingleLineBlocks: false
164
+ }
165
+ ],
166
+ '@stylistic/padding-line-between-statements': [
167
+ 'error',
168
+ {
169
+ blankLine: 'always',
170
+ prev: 'directive',
171
+ next: '*'
172
+ },
173
+ {
174
+ blankLine: 'any',
175
+ prev: 'directive',
176
+ next: 'directive'
177
+ }
178
+ ],
179
+ '@stylistic/quote-props': ['error', 'as-needed'],
180
+ '@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
181
+ '@stylistic/rest-spread-spacing': ['error', 'never'],
182
+ '@stylistic/semi': ['error', 'always'],
183
+ '@stylistic/semi-spacing': [
184
+ 'error',
185
+ {
186
+ before: false,
187
+ after: true
188
+ }
189
+ ],
190
+ '@stylistic/semi-style': ['error', 'last'],
191
+ '@stylistic/space-before-blocks': ['error', 'always'],
192
+ '@stylistic/space-before-function-paren': [
193
+ 'error',
194
+ {
195
+ anonymous: 'always',
196
+ named: 'never',
197
+ asyncArrow: 'always'
198
+ }
199
+ ],
200
+ '@stylistic/space-in-parens': ['error', 'never'],
201
+ '@stylistic/space-infix-ops': 'error',
202
+ '@stylistic/space-unary-ops': 'error',
203
+ '@stylistic/spaced-comment': [
204
+ 'error',
205
+ 'always',
206
+ {
207
+ line: {
208
+ exceptions: ['-', '+', '*'],
209
+ markers: ['!', '/', '=>']
210
+ },
211
+ block: {
212
+ exceptions: ['-', '+', '*'],
213
+ markers: ['!', '*'],
214
+ balanced: true
215
+ }
216
+ }
217
+ ],
218
+ '@stylistic/switch-colon-spacing': [
219
+ 'error',
220
+ {
221
+ after: true,
222
+ before: false
223
+ }
224
+ ],
225
+ '@stylistic/template-curly-spacing': 'error',
226
+ '@stylistic/template-tag-spacing': ['error', 'never'],
227
+ '@stylistic/type-annotation-spacing': 'error',
228
+ '@stylistic/type-generic-spacing': 'error',
229
+ '@stylistic/type-named-tuple-spacing': 'error',
230
+ '@stylistic/wrap-iife': ['error', 'inside'],
231
+ '@stylistic/wrap-regex': 'off',
232
+ '@stylistic/yield-star-spacing': ['error', { before: false, after: true }]
233
+ }
234
+ };
@@ -0,0 +1,13 @@
1
+ import { stylisticRuleSet } from './stylistic.js';
2
+
3
+ export const testRuleSet = {
4
+ rules: {
5
+ 'max-len': [
6
+ 'error',
7
+ {
8
+ ...stylisticRuleSet.rules['@stylistic/max-len'][1],
9
+ ignoreStrings: true
10
+ }
11
+ ]
12
+ }
13
+ };