-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
150 lines (143 loc) · 5.43 KB
/
eslint.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import blumilkDefault from '@blumilksoftware/eslint-config'
const custom = {
rules: {
'function-multiline-arguments': {
meta: {
type: 'layout',
fixable: 'code',
schema: []
},
create: context => ({
CallExpression: node => {
if (node.arguments.length <= 1) return
let startLine = node.callee.loc.end.line
let endLine = node.loc.end.line
if (startLine === endLine) return
let argLines = node.arguments
.flatMap(
node => node.loc.start.line === node.loc.end.line
? [node.loc.start.line]
: [node.loc.start.line, node.loc.end.line]
)
let endsInFunction = !!node.arguments[node.arguments.length - 1].body
if (new Set(argLines.slice(0, -1)).size === 1 && endsInFunction) return
argLines.push(startLine)
argLines.push(endLine)
if (new Set(argLines).size === argLines.length) return
context.report({
node,
message: 'Enforce line breaks for multi-line function arguments',
fix(fixer) {
let actions = []
node.arguments.forEach(
(arg, i, arr) => {
let prev = i === 0 ? startLine : arr[i - 1].loc.end.line
if (arg.loc.start.line === prev) {
actions.push(fixer.insertTextBefore(arg, '\n'))
}
}
)
let lastArg = node.arguments[node.arguments.length - 1]
if (lastArg.loc.start.line === endLine) {
actions.push(fixer.insertTextAfter(lastArg, '\n'))
}
return actions
}
})
}
})
}
}
}
export default [
...blumilkDefault,
{
plugins: {
'custom': custom,
},
rules: {
'quotes': 'off',
'indent': 'off',
'semi': 'off',
'comma-dangle': 'off',
'eol-last': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/prefer-ts-expect-error': 'off',
'@typescript-eslint/member-delimiter-style': 'off',
'custom/function-multiline-arguments': 'warn',
'no-console': 'warn',
'no-empty': 'warn',
'arrow-body-style': ['warn', 'as-needed'],
'quotes': ['warn', 'single'],
'indent': ['warn', 2],
'semi': ['warn', 'never'],
'comma-dangle': ['warn', 'always-multiline'],
'eol-last': ['warn', 'always'],
'no-multiple-empty-lines': ['warn', { max: 2, maxBOF: 0, maxEOF: 0 }],
'@typescript-eslint/member-delimiter-style': ['warn', {
multiline: { delimiter: 'none' },
singleline: { delimiter: 'comma', requireLast: false },
}],
'comma-spacing': ['warn', { 'after': true }],
'quote-props': ['warn', 'as-needed'],
'rest-spread-spacing': ['warn', 'never'],
'array-bracket-spacing': ['warn', 'never'],
'array-bracket-newline': ['warn', { multiline: true }],
'array-element-newline': ['warn', 'consistent'],
'object-curly-spacing': ['warn', 'always'],
'object-curly-newline': ['warn', { multiline: true }],
'object-property-newline': ['warn', { allowMultiplePropertiesPerLine: true }],
'key-spacing': 'warn',
'@typescript-eslint/type-annotation-spacing': 'warn',
'switch-colon-spacing': 'warn',
'implicit-arrow-linebreak': ['warn', 'beside'],
'arrow-spacing': 'warn',
'brace-style': ['warn', 'stroustrup'],
'function-paren-newline': ['warn', 'multiline-arguments'],
'space-in-parens': ['warn', 'never'],
'space-unary-ops': 'warn',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/consistent-type-exports': ['warn', {
fixMixedExportsWithInlineTypeSpecifier: true,
}],
'@typescript-eslint/consistent-type-imports': ['warn', {
prefer: 'type-imports',
disallowTypeAnnotations: true,
fixStyle: 'inline-type-imports',
}],
'@typescript-eslint/method-signature-style': 'warn',
'@typescript-eslint/naming-convention': ['warn', {
selector: 'variableLike',
leadingUnderscore: 'allow',
trailingUnderscore: 'allow',
format: ['camelCase', 'PascalCase', 'UPPER_CASE'],
}],
'@typescript-eslint/no-base-to-string': 'warn',
'@typescript-eslint/no-dynamic-delete': 'warn',
'@typescript-eslint/no-implied-eval': 'warn',
'@typescript-eslint/no-namespace': 'warn',
'@typescript-eslint/prefer-includes': 'warn',
'@typescript-eslint/prefer-readonly': 'warn',
'@typescript-eslint/promise-function-async': 'warn',
'@typescript-eslint/consistent-type-assertions': ['warn', {
assertionStyle: 'as',
objectLiteralTypeAssertions: 'never',
}],
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-inferrable-types': 'warn',
'vue/max-attributes-per-line': ['warn', {
'singleline': 1,
'multiline': { 'max': 1 }
}],
'vue/singleline-html-element-content-newline': ['warn', { ignores: [] }],
'vue/multiline-html-element-content-newline': ['warn', { ignores: [] }],
'vue/first-attribute-linebreak': ['warn', {
'singleline': 'beside',
'multiline': 'below'
}],
'vue/block-tag-newline': ['warn', { 'maxEmptyLines': 0 }],
'vue/padding-line-between-blocks': 'warn',
'vue/padding-line-between-tags': 'warn'
}
}
]