Skip to content

Commit be32e7b

Browse files
authored
chore(dev-infra): configure eslint rule padding-line-between-statements (#1676)
1 parent 8f2b2dc commit be32e7b

26 files changed

Lines changed: 126 additions & 71 deletions

.eslintrc.js

Lines changed: 75 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,36 @@ module.exports = {
2424
},
2525
plugins: ['@typescript-eslint', 'jest', 'jsdoc'],
2626
rules: {
27-
'prettier/prettier': 'error',
28-
'no-unused-vars': 'off', // let typescript-eslint handle this
29-
'no-console': 'error',
30-
'linebreak-style': 'off',
27+
'arrow-body-style': 'warn',
28+
'arrow-parens': ['off', 'always'],
29+
'brace-style': ['off', 'off'],
30+
camelcase: 'warn',
31+
'class-methods-use-this': 'warn',
3132
'comma-dangle': 'off',
33+
complexity: 'off',
3234
'constructor-super': 'error',
35+
curly: ['warn', 'multi-line'],
36+
'default-case': 'error',
37+
'dot-notation': 'error',
38+
'eol-last': 'off',
39+
eqeqeq: ['error', 'smart'],
3340
'for-direction': ['error'],
3441
'getter-return': 'warn',
42+
'guard-for-in': 'error',
43+
'id-match': 'error',
44+
'jsdoc/check-alignment': 'error',
45+
'jsdoc/check-indentation': 'error',
46+
'jsdoc/newline-after-description': 'warn',
47+
'linebreak-style': 'off',
48+
'max-classes-per-file': 'off',
49+
'max-len': 'off',
50+
'new-parens': 'off',
51+
'newline-per-chained-call': 'off',
52+
'no-bitwise': 'off',
53+
'no-caller': 'error',
54+
'no-duplicate-imports': 'error',
55+
'no-eval': 'error',
56+
'no-console': 'error',
3557
'no-async-promise-executor': ['error'],
3658
'no-case-declarations': ['error'],
3759
'no-class-assign': ['error'],
@@ -61,40 +83,79 @@ module.exports = {
6183
'no-func-assign': ['error'],
6284
'no-global-assign': ['error'],
6385
'no-inner-declarations': ['error'],
86+
'no-invalid-this': 'off',
6487
'no-invalid-regexp': ['error'],
6588
'no-irregular-whitespace': 'off',
6689
'no-misleading-character-class': ['error'],
6790
'no-mixed-spaces-and-tabs': ['error'],
91+
'no-multiple-empty-lines': 'off',
6892
'no-new-symbol': ['error'],
93+
'no-new-wrappers': 'error',
6994
'no-obj-calls': ['error'],
7095
'no-octal': ['error'],
7196
'no-prototype-builtins': ['error'],
7297
'no-redeclare': 'warn',
7398
'no-regex-spaces': ['error'],
99+
'no-return-await': 'error',
74100
'no-self-assign': ['error'],
101+
'no-shadow': [
102+
'off',
103+
{
104+
hoist: 'all',
105+
},
106+
],
75107
'no-shadow-restricted-names': ['error'],
76108
'no-sparse-arrays': ['error'],
109+
'no-template-curly-in-string': 'error',
77110
'no-this-before-super': ['error'],
111+
'no-throw-literal': 'error',
112+
'no-trailing-spaces': 'off',
113+
'no-undef-init': 'error',
114+
'no-underscore-dangle': 'off',
115+
'no-unused-expressions': 'error',
78116
'no-undef': ['error'],
79117
'no-unexpected-multiline': ['error'],
80118
'no-unreachable': ['error'],
81119
'no-unsafe-finally': 'error',
82120
'no-unsafe-negation': ['error'],
83121
'no-unused-labels': 'error',
122+
'no-unused-vars': 'off', // let typescript-eslint handle this
84123
'no-useless-catch': ['error'],
85124
'no-useless-escape': 'warn',
125+
'no-var': 'error',
86126
'no-with': ['error'],
127+
'object-shorthand': 'error',
128+
'one-var': ['error', 'never'],
129+
'padding-line-between-statements': [
130+
"error",
131+
{ blankLine: "always", prev: "*", next: "return" }
132+
],
133+
'prefer-const': 'error',
134+
'prefer-object-spread': 'error',
135+
'prefer-template': 'error',
136+
'prettier/prettier': 'error',
137+
'quote-props': 'off',
138+
radix: 'error',
87139
'require-yield': ['error'],
140+
'space-before-function-paren': 'off',
141+
'space-in-parens': ['off', 'never'],
142+
'spaced-comment': [
143+
'warn',
144+
'always',
145+
{
146+
markers: ['/'],
147+
},
148+
],
88149
'use-isnan': 'error',
89150
'valid-typeof': 'off',
90-
'@typescript-eslint/no-unused-vars': ["error", { "argsIgnorePattern": "^_" }],
91151
'@typescript-eslint/adjacent-overload-signatures': 'error',
92152
'@typescript-eslint/array-type': [
93153
'warn',
94154
{
95155
default: 'array',
96156
},
97157
],
158+
'@typescript-eslint/ban-ts-ignore': 'off',
98159
'@typescript-eslint/ban-types': [
99160
'error',
100161
{
@@ -120,12 +181,9 @@ module.exports = {
120181
},
121182
},
122183
],
123-
'@typescript-eslint/prefer-regexp-exec': 'warn',
124-
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
125-
'@typescript-eslint/unbound-method': 'off',
126-
'@typescript-eslint/prefer-includes': 'warn',
127184
'@typescript-eslint/consistent-type-assertions': 'error',
128185
'@typescript-eslint/consistent-type-definitions': 'error',
186+
'@typescript-eslint/explicit-function-return-type': 'off',
129187
'@typescript-eslint/explicit-member-accessibility': [
130188
'error',
131189
{
@@ -146,11 +204,9 @@ module.exports = {
146204
},
147205
},
148206
],
149-
'@typescript-eslint/require-await': 'off',
150-
'@typescript-eslint/ban-ts-ignore': 'off',
207+
'@typescript-eslint/no-unused-vars': ["error", { "argsIgnorePattern": "^_" }],
151208
'@typescript-eslint/no-empty-function': ['error', { 'allow': ['arrowFunctions']}],
152209
'@typescript-eslint/no-empty-interface': 'off',
153-
'@typescript-eslint/explicit-function-return-type': 'off',
154210
'@typescript-eslint/no-explicit-any': 'off',
155211
'@typescript-eslint/no-for-in-array': 'error',
156212
'@typescript-eslint/no-inferrable-types': 'error',
@@ -163,13 +219,18 @@ module.exports = {
163219
'@typescript-eslint/no-unsafe-member-access': 'off',
164220
'@typescript-eslint/no-unsafe-return': 'off',
165221
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
222+
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
166223
'@typescript-eslint/no-use-before-define': 'off',
167224
'@typescript-eslint/no-var-requires': 'off',
168-
'@typescript-eslint/restrict-template-expressions': 'off',
225+
'@typescript-eslint/prefer-includes': 'warn',
226+
'@typescript-eslint/prefer-regexp-exec': 'warn',
227+
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
169228
'@typescript-eslint/prefer-for-of': 'off',
170229
'@typescript-eslint/prefer-function-type': 'error',
171230
'@typescript-eslint/prefer-namespace-keyword': 'error',
172231
'@typescript-eslint/prefer-readonly': 'error',
232+
'@typescript-eslint/restrict-template-expressions': 'off',
233+
'@typescript-eslint/require-await': 'off',
173234
'@typescript-eslint/triple-slash-reference': [
174235
'error',
175236
{
@@ -179,65 +240,8 @@ module.exports = {
179240
},
180241
],
181242
'@typescript-eslint/type-annotation-spacing': 'off',
243+
'@typescript-eslint/unbound-method': 'off',
182244
'@typescript-eslint/unified-signatures': 'error',
183-
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
184-
'arrow-body-style': 'warn',
185-
'arrow-parens': ['off', 'always'],
186-
'brace-style': ['off', 'off'],
187-
camelcase: 'warn',
188-
'class-methods-use-this': 'warn',
189-
complexity: 'off',
190-
curly: ['warn', 'multi-line'],
191-
'default-case': 'error',
192-
'dot-notation': 'error',
193-
'eol-last': 'off',
194-
eqeqeq: ['error', 'smart'],
195-
'guard-for-in': 'error',
196-
'id-match': 'error',
197-
'jsdoc/check-alignment': 'error',
198-
'jsdoc/check-indentation': 'error',
199-
'jsdoc/newline-after-description': 'warn',
200-
'max-classes-per-file': 'off',
201-
'max-len': 'off',
202-
'new-parens': 'off',
203-
'newline-per-chained-call': 'off',
204-
'no-bitwise': 'off',
205-
'no-caller': 'error',
206-
'no-duplicate-imports': 'error',
207-
'no-eval': 'error',
208-
'no-invalid-this': 'off',
209-
'no-multiple-empty-lines': 'off',
210-
'no-new-wrappers': 'error',
211-
'no-return-await': 'error',
212-
'no-shadow': [
213-
'off',
214-
{
215-
hoist: 'all',
216-
},
217-
],
218-
'no-template-curly-in-string': 'error',
219-
'no-throw-literal': 'error',
220-
'no-trailing-spaces': 'off',
221-
'no-undef-init': 'error',
222-
'no-underscore-dangle': 'off',
223-
'no-unused-expressions': 'error',
224-
'no-var': 'error',
225-
'object-shorthand': 'error',
226-
'one-var': ['error', 'never'],
227-
'prefer-const': 'warn',
228-
'prefer-object-spread': 'error',
229-
'prefer-template': 'error',
230-
'quote-props': 'off',
231-
radix: 'error',
232-
'space-before-function-paren': 'off',
233-
'space-in-parens': ['off', 'never'],
234-
'spaced-comment': [
235-
'warn',
236-
'always',
237-
{
238-
markers: ['/'],
239-
},
240-
],
241245
},
242246
settings: {},
243247
}

e2e/__helpers__/test-case/run-descriptor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ function createIteratorContext(templateName: string, expectedStatus?: number): R
101101
if (status == null) {
102102
return 'run'
103103
}
104+
104105
return status === 0 ? 'pass' : 'fail'
105106
}
106107

e2e/__helpers__/test-case/run-result.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default class RunResult {
3636
const lines = this.logFileContent.split(/\n/g)
3737
// remove last, empty line
3838
lines.pop()
39+
3940
return lines.map(s => JSON.parse(s))
4041
}
4142

e2e/__helpers__/test-case/runtime.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ function hooksSourceWith(vars: Record<string, any>): string {
4949
if (!__hooksSource) {
5050
__hooksSource = readFileSync(join(__dirname, '__hooks-source__.js.hbs'), 'utf8')
5151
}
52+
5253
// eslint-disable-next-line no-useless-escape
5354
return __hooksSource.replace(/\{\{([^\}]+)\}\}/g, (_, key) => JSON.stringify(vars[key]))
5455
}
@@ -253,6 +254,7 @@ export function prepareTest(name: string, template: string, options: RunTestOpti
253254
segments.pop()
254255
}
255256
snapshotDirs[segments.join(sep)] = 0
257+
256258
return false
257259
} else if (relPath === 'jest.config.js') {
258260
// extend base if it's a function
@@ -263,8 +265,10 @@ export function prepareTest(name: string, template: string, options: RunTestOpti
263265
const mod = require(src)
264266
if (typeof mod === 'function') {
265267
writeFileSync(dest, `module.exports = ${JSON.stringify(mod(baseConfig, configUtils))}`)
268+
266269
return false
267270
}
271+
268272
return true
269273
} else {
270274
return true

e2e/__helpers__/test-case/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export function templateNameForPath(path: string): string {
1212
if (existsSync(e2eFile)) {
1313
return require(e2eFile).template || 'default'
1414
}
15+
1516
return 'default'
1617
}
1718

@@ -21,6 +22,7 @@ const FAIL_MARKS = ['×', '✕']
2122
const normalizeTestMark = (mark: string): string => {
2223
if (PASS_MARKS.includes(mark)) return PASS_MARKS[0]
2324
if (FAIL_MARKS.includes(mark)) return FAIL_MARKS[0]
25+
2426
return '?'
2527
}
2628

@@ -41,6 +43,7 @@ export function normalizeJestOutput(output: string): string {
4143
if (process.platform === 'win32') {
4244
out = out.replace(/\\/g, '/')
4345
}
46+
4447
return out
4548
}
4649

scripts/e2e.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function getDirectories(rootDir) {
3131
function sha1(...data) {
3232
const hash = createHash('sha1')
3333
data.forEach((item) => hash.update(item))
34+
3435
return hash.digest('hex').toString()
3536
}
3637

@@ -105,6 +106,7 @@ function setupE2e() {
105106
// no package-lock.json => this template doesn't provide any package-set
106107
if (!fs.existsSync(pkgLockFile)) {
107108
log(` [template: ${name}]`, 'not a package-set template, nothing to do')
109+
108110
return
109111
}
110112

@@ -119,6 +121,7 @@ function setupE2e() {
119121
if (bundleOk && packagesOk) {
120122
log(` [template: ${name}]`, 'bundle and packages unchanged, nothing to do')
121123
logPackageVersions()
124+
122125
return
123126
}
124127
}

scripts/lib/bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ function computePackageDigest(noWriteFile = false) {
4242
if (!noWriteFile) {
4343
writeFileSync(pkgDigestFile, digest, 'utf8')
4444
}
45+
4546
return digest
4647
}
4748

scripts/lib/npm.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function directDepsPkg(dir) {
2222
if (res[key]) return
2323
res[key] = require(join(dir, 'node_modules', key, 'package.json'))
2424
})
25+
2526
return res
2627
}
2728

scripts/lib/spawn-sync.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const spawnSync = (...args) => {
1515
msgs.push('unknown error')
1616
throw new Error(msgs.find((s) => s))
1717
}
18+
1819
return res
1920
}
2021

src/__helpers__/fakers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export function getJestConfig<T extends Config.ProjectConfig>(
3737
if (tsJestOptions) {
3838
res.globals['ts-jest'] = tsJestOptions
3939
}
40+
4041
return res
4142
}
4243

0 commit comments

Comments
 (0)