@daldalso/eslint-plugin 1.2.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.
- package/LICENSE +21 -0
- package/README.md +29 -0
- package/dist/configs/all.js +320 -0
- package/dist/index.js +18 -0
- package/dist/rules/_template.js +17 -0
- package/dist/rules/function-type-annotation-style.js +138 -0
- package/dist/rules/homing-instinct.js +61 -0
- package/dist/rules/iterator-name.js +315 -0
- package/dist/rules/jsx-expression-condition-type.js +76 -0
- package/dist/rules/jsx-indent.js +220 -0
- package/dist/rules/key-quotation-style.js +150 -0
- package/dist/rules/lone-semicolon-indent.js +92 -0
- package/dist/rules/multiline-expression-spacing.js +130 -0
- package/dist/rules/no-class-expression.js +20 -0
- package/dist/rules/no-type-name-affix.js +62 -0
- package/dist/rules/no-unsafe-unquoted-key.js +80 -0
- package/dist/rules/no-useless-template-literal.js +81 -0
- package/dist/rules/one-exported-react-component.js +50 -0
- package/dist/rules/parenthesis-spacing.js +206 -0
- package/dist/rules/prefer-const.js +123 -0
- package/dist/rules/return-type.js +96 -0
- package/dist/rules/semantic-quotes.js +240 -0
- package/dist/rules/sort-keys.js +411 -0
- package/dist/rules/ternary-spacing.js +155 -0
- package/dist/rules/type-colon-spacing.js +128 -0
- package/dist/rules/type-operator-spacing.js +200 -0
- package/dist/rules/variable-name.js +253 -0
- package/dist/utils/code.js +21 -0
- package/dist/utils/patterns.js +16 -0
- package/dist/utils/text.js +15 -0
- package/dist/utils/type.js +82 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 JJoriping
|
|
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,29 @@
|
|
|
1
|
+
# @daldalso/eslint-plugin
|
|
2
|
+
|
|
3
|
+
ESLint plugin for [Daldalso](https://daldal.so)-style programming.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
1. `yarn add @daldalso/eslint-plugin`
|
|
7
|
+
2. Add following values to your ESLint configuration file.
|
|
8
|
+
```json
|
|
9
|
+
{
|
|
10
|
+
"plugins": [
|
|
11
|
+
"@daldalso/eslint-plugin"
|
|
12
|
+
],
|
|
13
|
+
"extends": [
|
|
14
|
+
"plugin:@daldalso/eslint-plugin/all"
|
|
15
|
+
],
|
|
16
|
+
"parserOptions": {
|
|
17
|
+
"project": "./tsconfig.json"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Caveats
|
|
23
|
+
- This plugin is just for describing the code conventions of [Daldalso](https://daldal.so). I have no intention of arguing that it is better than any other conventions.
|
|
24
|
+
- For originality, you had better remove the following plugins from your configuration file.
|
|
25
|
+
- `@typescript-eslint/eslint-plugin`
|
|
26
|
+
- `eslint-plugin-import`
|
|
27
|
+
- `eslint-plugin-react`
|
|
28
|
+
- `eslint-plugin-react-hooks`
|
|
29
|
+
- `eslint-plugin-unicorn`
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = {
|
|
4
|
+
parser: "@typescript-eslint/parser",
|
|
5
|
+
parserOptions: {
|
|
6
|
+
sourceType: "module",
|
|
7
|
+
ecmaFeatures: {
|
|
8
|
+
"jsx": true
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
plugins: [
|
|
12
|
+
"@typescript-eslint",
|
|
13
|
+
"import",
|
|
14
|
+
"react",
|
|
15
|
+
"react-hooks",
|
|
16
|
+
"unicorn"
|
|
17
|
+
],
|
|
18
|
+
settings: {
|
|
19
|
+
react: {
|
|
20
|
+
version: "detect"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
rules: {
|
|
24
|
+
// ESLint rules - errors
|
|
25
|
+
'default-case-last': "error",
|
|
26
|
+
'eqeqeq': "error",
|
|
27
|
+
'grouped-accessor-pairs': ["error", "getBeforeSet"],
|
|
28
|
+
'no-async-promise-executor': "error",
|
|
29
|
+
'no-case-declarations': "error",
|
|
30
|
+
'no-compare-neg-zero': "error",
|
|
31
|
+
'no-constant-binary-expression': "error",
|
|
32
|
+
'no-constant-condition': ["error", { checkLoops: false }],
|
|
33
|
+
'no-empty-pattern': "error",
|
|
34
|
+
'no-ex-assign': "error",
|
|
35
|
+
'no-floating-decimal': "error",
|
|
36
|
+
'no-implicit-coercion': "error",
|
|
37
|
+
'no-invalid-regexp': "error",
|
|
38
|
+
'no-lonely-if': "error",
|
|
39
|
+
'no-negated-condition': "error",
|
|
40
|
+
'no-new-wrappers': "error",
|
|
41
|
+
'no-regex-spaces': "error",
|
|
42
|
+
'no-self-assign': "error",
|
|
43
|
+
'no-self-compare': "error",
|
|
44
|
+
'no-sparse-arrays': "error",
|
|
45
|
+
'no-underscore-dangle': ["error", { allowFunctionParams: false }],
|
|
46
|
+
'no-unreachable-loop': "error",
|
|
47
|
+
'no-unsafe-finally': "error",
|
|
48
|
+
'no-useless-backreference': "error",
|
|
49
|
+
'no-useless-catch': "error",
|
|
50
|
+
'no-useless-rename': "error",
|
|
51
|
+
'no-useless-return': "error",
|
|
52
|
+
'no-var': "error",
|
|
53
|
+
'object-shorthand': "error",
|
|
54
|
+
'operator-assignment': "error",
|
|
55
|
+
'prefer-numeric-literals': "error",
|
|
56
|
+
'prefer-regex-literals': "error",
|
|
57
|
+
'spaced-comment': ["error", "always", { markers: ["/"] }],
|
|
58
|
+
'use-isnan': "error",
|
|
59
|
+
'yoda': "error",
|
|
60
|
+
// ESLint rules - warnings
|
|
61
|
+
'accessor-pairs': "warn",
|
|
62
|
+
'arrow-body-style': "warn",
|
|
63
|
+
'logical-assignment-operators': ["warn", "always", { enforceForIfStatements: true }],
|
|
64
|
+
'no-debugger': "warn",
|
|
65
|
+
'no-else-return': ["warn", { allowElseIf: false }],
|
|
66
|
+
'no-empty': "warn",
|
|
67
|
+
'no-extra-bind': "warn",
|
|
68
|
+
'no-extra-boolean-cast': "warn",
|
|
69
|
+
'no-misleading-character-class': "warn",
|
|
70
|
+
'no-template-curly-in-string': "warn",
|
|
71
|
+
'no-unmodified-loop-condition': "warn",
|
|
72
|
+
'no-useless-call': "warn",
|
|
73
|
+
'no-useless-concat': "warn",
|
|
74
|
+
'no-useless-escape': "warn",
|
|
75
|
+
'prefer-arrow-callback': "warn",
|
|
76
|
+
'require-yield': "warn",
|
|
77
|
+
'symbol-description': "warn",
|
|
78
|
+
// ESLint rules - styles
|
|
79
|
+
'array-bracket-newline': ["warn", "consistent"],
|
|
80
|
+
'array-element-newline': ["warn", "consistent"],
|
|
81
|
+
'arrow-parens': ["warn", "as-needed"],
|
|
82
|
+
'arrow-spacing': "warn",
|
|
83
|
+
'computed-property-spacing': "warn",
|
|
84
|
+
'dot-location': ["warn", "property"],
|
|
85
|
+
'eol-last': ["warn", "never"],
|
|
86
|
+
'function-call-argument-newline': ["warn", "consistent"],
|
|
87
|
+
'generator-star-spacing': "warn",
|
|
88
|
+
'implicit-arrow-linebreak': "warn",
|
|
89
|
+
'jsx-quotes': "warn",
|
|
90
|
+
'key-spacing': "warn",
|
|
91
|
+
'linebreak-style': "warn",
|
|
92
|
+
'new-parens': "warn",
|
|
93
|
+
'no-multi-spaces': "warn",
|
|
94
|
+
'no-multiple-empty-lines': "warn",
|
|
95
|
+
'no-trailing-spaces': "warn",
|
|
96
|
+
'nonblock-statement-body-position': "warn",
|
|
97
|
+
'object-curly-newline': "warn",
|
|
98
|
+
'operator-linebreak': ["warn", "before"],
|
|
99
|
+
'padded-blocks': ["warn", "never"],
|
|
100
|
+
'rest-spread-spacing': "warn",
|
|
101
|
+
'semi-spacing': "warn",
|
|
102
|
+
'space-in-parens': "warn",
|
|
103
|
+
'space-infix-ops': "warn",
|
|
104
|
+
'space-unary-ops': "warn",
|
|
105
|
+
'switch-colon-spacing': "warn",
|
|
106
|
+
'template-curly-spacing': "warn",
|
|
107
|
+
'template-tag-spacing': "warn",
|
|
108
|
+
'yield-star-spacing': ["warn", "before"],
|
|
109
|
+
// TSLint rules - extensions
|
|
110
|
+
'@typescript-eslint/brace-style': "warn",
|
|
111
|
+
'@typescript-eslint/comma-dangle': [
|
|
112
|
+
"warn",
|
|
113
|
+
// NOTE Problem with `<T,>() => ...`
|
|
114
|
+
{ generics: "ignore" }
|
|
115
|
+
],
|
|
116
|
+
'@typescript-eslint/comma-spacing': "warn",
|
|
117
|
+
'@typescript-eslint/func-call-spacing': ["warn", "never"],
|
|
118
|
+
'@typescript-eslint/indent': [
|
|
119
|
+
"warn",
|
|
120
|
+
2,
|
|
121
|
+
{
|
|
122
|
+
SwitchCase: 1,
|
|
123
|
+
ignoredNodes: [
|
|
124
|
+
// NOTE https://github.com/typescript-eslint/typescript-eslint/issues/1824
|
|
125
|
+
"TSUnionType",
|
|
126
|
+
"TSIntersectionType",
|
|
127
|
+
"TSTypeParameterInstantiation",
|
|
128
|
+
"ConditionalExpression",
|
|
129
|
+
"PropertyDefinition"
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
'@typescript-eslint/keyword-spacing': ["warn", {
|
|
134
|
+
overrides: {
|
|
135
|
+
catch: { before: false, after: false },
|
|
136
|
+
do: { before: true, after: false },
|
|
137
|
+
else: { before: false, after: false },
|
|
138
|
+
finally: { before: false, after: false },
|
|
139
|
+
for: { before: true, after: false },
|
|
140
|
+
if: { before: true, after: false },
|
|
141
|
+
static: { before: false, after: false },
|
|
142
|
+
super: { before: true, after: false },
|
|
143
|
+
switch: { before: true, after: false },
|
|
144
|
+
try: { before: true, after: false },
|
|
145
|
+
while: { before: true, after: false },
|
|
146
|
+
with: { before: true, after: false }
|
|
147
|
+
}
|
|
148
|
+
}],
|
|
149
|
+
'@typescript-eslint/no-extra-parens': [
|
|
150
|
+
"warn",
|
|
151
|
+
"all",
|
|
152
|
+
{ ignoreJSX: "all", nestedBinaryExpressions: false }
|
|
153
|
+
],
|
|
154
|
+
'@typescript-eslint/no-extra-semi': "error",
|
|
155
|
+
'@typescript-eslint/no-shadow': ["warn", { allow: ["_"] }],
|
|
156
|
+
'@typescript-eslint/no-throw-literal': "error",
|
|
157
|
+
'@typescript-eslint/no-unused-expressions': ["error", { allowShortCircuit: true, enforceForJSX: true }],
|
|
158
|
+
'@typescript-eslint/no-useless-constructor': "warn",
|
|
159
|
+
'@typescript-eslint/return-await': "error",
|
|
160
|
+
'@typescript-eslint/semi': "warn",
|
|
161
|
+
'@typescript-eslint/space-before-blocks': ["warn", "never"],
|
|
162
|
+
'@typescript-eslint/space-before-function-paren': ["warn", { anonymous: "never", named: "never", asyncArrow: "always" }],
|
|
163
|
+
// TSLint rules - errors
|
|
164
|
+
'@typescript-eslint/adjacent-overload-signatures': "error",
|
|
165
|
+
'@typescript-eslint/consistent-indexed-object-style': "error",
|
|
166
|
+
'@typescript-eslint/consistent-type-exports': ["error", { fixMixedExportsWithInlineTypeSpecifier: true }],
|
|
167
|
+
'@typescript-eslint/consistent-type-imports': "error",
|
|
168
|
+
'@typescript-eslint/explicit-member-accessibility': ["error", { overrides: { constructors: "off" } }],
|
|
169
|
+
'@typescript-eslint/no-confusing-void-expression': ["error", { ignoreArrowShorthand: true, ignoreVoidOperator: true }],
|
|
170
|
+
'@typescript-eslint/no-duplicate-enum-values': "error",
|
|
171
|
+
'@typescript-eslint/no-extra-non-null-assertion': "error",
|
|
172
|
+
'@typescript-eslint/no-misused-new': "error",
|
|
173
|
+
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': "error",
|
|
174
|
+
'@typescript-eslint/no-parameter-properties': "error",
|
|
175
|
+
'@typescript-eslint/no-this-alias': "error",
|
|
176
|
+
'@typescript-eslint/no-unnecessary-type-constraint': "error",
|
|
177
|
+
'@typescript-eslint/no-unsafe-call': "error",
|
|
178
|
+
'@typescript-eslint/no-useless-empty-export': "error",
|
|
179
|
+
'@typescript-eslint/prefer-literal-enum-member': "error",
|
|
180
|
+
'@typescript-eslint/restrict-plus-operands': "error",
|
|
181
|
+
// TSLint rules - warnings
|
|
182
|
+
'@typescript-eslint/array-type': ["warn", { default: "array-simple" }],
|
|
183
|
+
'@typescript-eslint/class-literal-property-style': "warn",
|
|
184
|
+
'@typescript-eslint/consistent-generic-constructors': "warn",
|
|
185
|
+
'@typescript-eslint/consistent-type-assertions': ["warn", {
|
|
186
|
+
assertionStyle: "as",
|
|
187
|
+
objectLiteralTypeAssertions: "allow"
|
|
188
|
+
}],
|
|
189
|
+
'@typescript-eslint/member-delimiter-style': ["warn", {
|
|
190
|
+
overrides: {
|
|
191
|
+
interface: {
|
|
192
|
+
singleline: { delimiter: "semi", requireLast: true },
|
|
193
|
+
multiline: { delimiter: "semi", requireLast: true }
|
|
194
|
+
},
|
|
195
|
+
typeLiteral: {
|
|
196
|
+
singleline: { delimiter: "comma", requireLast: false },
|
|
197
|
+
multiline: { delimiter: "comma", requireLast: false }
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}],
|
|
201
|
+
'@typescript-eslint/no-base-to-string': "warn",
|
|
202
|
+
'@typescript-eslint/no-empty-interface': "warn",
|
|
203
|
+
'@typescript-eslint/no-misused-promises': ["warn", { checksVoidReturn: false }],
|
|
204
|
+
'@typescript-eslint/no-non-null-asserted-optional-chain': "warn",
|
|
205
|
+
'@typescript-eslint/no-redundant-type-constituents': "warn",
|
|
206
|
+
'@typescript-eslint/no-unnecessary-boolean-literal-compare': "warn",
|
|
207
|
+
'@typescript-eslint/no-unnecessary-qualifier': "warn",
|
|
208
|
+
'@typescript-eslint/no-unnecessary-type-arguments': "warn",
|
|
209
|
+
'@typescript-eslint/no-unnecessary-type-assertion': "warn",
|
|
210
|
+
'@typescript-eslint/non-nullable-type-assertion-style': "warn",
|
|
211
|
+
'@typescript-eslint/prefer-as-const': "warn",
|
|
212
|
+
'@typescript-eslint/prefer-function-type': "warn",
|
|
213
|
+
'@typescript-eslint/prefer-includes': "warn",
|
|
214
|
+
'@typescript-eslint/prefer-namespace-keyword': "warn",
|
|
215
|
+
'@typescript-eslint/prefer-optional-chain': "warn",
|
|
216
|
+
'@typescript-eslint/prefer-string-starts-ends-with': "warn",
|
|
217
|
+
'@typescript-eslint/unified-signatures': "warn",
|
|
218
|
+
// React rules
|
|
219
|
+
'react-hooks/exhaustive-deps': "warn",
|
|
220
|
+
'react-hooks/rules-of-hooks': "error",
|
|
221
|
+
'react/boolean-prop-naming': ["error", { rule: /^'?\b(?!is[\dA-Z])/.source, message: "The name of the boolean prop `{{propName}}` cannot start with `is`." }],
|
|
222
|
+
'react/function-component-definition': ["error", { namedComponents: "arrow-function", unnamedComponents: "arrow-function" }],
|
|
223
|
+
'react/hook-use-state': "warn",
|
|
224
|
+
'react/jsx-boolean-value': "warn",
|
|
225
|
+
'react/jsx-curly-brace-presence': ["warn", { props: "never", children: "never", propElementValues: "always" }],
|
|
226
|
+
'react/jsx-curly-spacing': ["warn", { when: "never", attributes: true, children: true }],
|
|
227
|
+
'react/jsx-equals-spacing': "warn",
|
|
228
|
+
'react/jsx-fragments': "warn",
|
|
229
|
+
'react/jsx-handler-names': "warn",
|
|
230
|
+
'react/jsx-key': "warn",
|
|
231
|
+
'react/jsx-no-constructed-context-values': "warn",
|
|
232
|
+
'react/jsx-no-script-url': "error",
|
|
233
|
+
'react/jsx-no-target-blank': "warn",
|
|
234
|
+
'react/jsx-no-useless-fragment': "warn",
|
|
235
|
+
'react/no-access-state-in-setstate': "warn",
|
|
236
|
+
'react/no-arrow-function-lifecycle': "error",
|
|
237
|
+
'react/no-children-prop': "error",
|
|
238
|
+
'react/no-danger-with-children': "error",
|
|
239
|
+
'react/no-redundant-should-component-update': "warn",
|
|
240
|
+
'react/no-string-refs': "error",
|
|
241
|
+
'react/no-this-in-sfc': "error",
|
|
242
|
+
'react/no-unescaped-entities': "warn",
|
|
243
|
+
'react/no-unstable-nested-components': "warn",
|
|
244
|
+
'react/no-unused-state': "warn",
|
|
245
|
+
'react/prefer-es6-class': "error",
|
|
246
|
+
'react/require-optimization': "warn",
|
|
247
|
+
'react/self-closing-comp': "warn",
|
|
248
|
+
'react/void-dom-elements-no-children': "error",
|
|
249
|
+
// Import rules
|
|
250
|
+
'import/first': "error",
|
|
251
|
+
'import/order': [
|
|
252
|
+
"warn",
|
|
253
|
+
{
|
|
254
|
+
'newlines-between': "never"
|
|
255
|
+
}
|
|
256
|
+
],
|
|
257
|
+
// Unicorn rules
|
|
258
|
+
'unicorn/better-regex': "warn",
|
|
259
|
+
'unicorn/catch-error-name': "error",
|
|
260
|
+
'unicorn/empty-brace-spaces': "warn",
|
|
261
|
+
'unicorn/error-message': "warn",
|
|
262
|
+
'unicorn/escape-case': "warn",
|
|
263
|
+
'unicorn/no-array-for-each': "warn",
|
|
264
|
+
'unicorn/no-instanceof-array': "error",
|
|
265
|
+
'unicorn/no-invalid-remove-event-listener': "warn",
|
|
266
|
+
'unicorn/no-thenable': "error",
|
|
267
|
+
'unicorn/no-this-assignment': "warn",
|
|
268
|
+
'unicorn/no-useless-promise-resolve-reject': "warn",
|
|
269
|
+
'unicorn/no-useless-spread': "error",
|
|
270
|
+
'unicorn/numeric-separators-style': ["error", { onlyIfContainsSeparator: true }],
|
|
271
|
+
'unicorn/prefer-add-event-listener': "error",
|
|
272
|
+
'unicorn/prefer-array-find': "error",
|
|
273
|
+
'unicorn/prefer-array-some': "warn",
|
|
274
|
+
'unicorn/prefer-date-now': "warn",
|
|
275
|
+
'unicorn/prefer-export-from': "warn",
|
|
276
|
+
'unicorn/prefer-includes': "warn",
|
|
277
|
+
'unicorn/prefer-logical-operator-over-ternary': "warn",
|
|
278
|
+
'unicorn/prefer-math-trunc': "warn",
|
|
279
|
+
'unicorn/prefer-prototype-methods': "warn",
|
|
280
|
+
'unicorn/prefer-query-selector': "warn",
|
|
281
|
+
'unicorn/prevent-abbreviations': ["warn", {
|
|
282
|
+
replacements: {
|
|
283
|
+
args: false,
|
|
284
|
+
db: false,
|
|
285
|
+
e: false,
|
|
286
|
+
i: false,
|
|
287
|
+
j: false,
|
|
288
|
+
prev: false,
|
|
289
|
+
props: false,
|
|
290
|
+
ref: false,
|
|
291
|
+
req: false,
|
|
292
|
+
res: false,
|
|
293
|
+
temp: false
|
|
294
|
+
}
|
|
295
|
+
}],
|
|
296
|
+
// Custom rules
|
|
297
|
+
'@daldalso/function-type-annotation-style': "warn",
|
|
298
|
+
'@daldalso/homing-instinct': "warn",
|
|
299
|
+
'@daldalso/iterator-name': "warn",
|
|
300
|
+
'@daldalso/jsx-expression-condition-type': "warn",
|
|
301
|
+
'@daldalso/jsx-indent': "warn",
|
|
302
|
+
'@daldalso/key-quotation-style': "warn",
|
|
303
|
+
'@daldalso/lone-semicolon-indent': "warn",
|
|
304
|
+
'@daldalso/multiline-expression-spacing': "warn",
|
|
305
|
+
'@daldalso/no-class-expression': "warn",
|
|
306
|
+
'@daldalso/no-type-name-affix': "warn",
|
|
307
|
+
'@daldalso/no-unsafe-unquoted-key': "warn",
|
|
308
|
+
'@daldalso/no-useless-template-literal': "warn",
|
|
309
|
+
'@daldalso/one-exported-react-component': "warn",
|
|
310
|
+
'@daldalso/parenthesis-spacing': "warn",
|
|
311
|
+
'@daldalso/prefer-const': "warn",
|
|
312
|
+
'@daldalso/return-type': "warn",
|
|
313
|
+
'@daldalso/semantic-quotes': "warn",
|
|
314
|
+
'@daldalso/sort-keys': "warn",
|
|
315
|
+
'@daldalso/ternary-spacing': "warn",
|
|
316
|
+
'@daldalso/type-colon-spacing': "warn",
|
|
317
|
+
'@daldalso/type-operator-spacing': "warn",
|
|
318
|
+
'@daldalso/variable-name': "warn"
|
|
319
|
+
}
|
|
320
|
+
};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var fs_1 = require("fs");
|
|
3
|
+
var path_1 = require("path");
|
|
4
|
+
var all_1 = require("./configs/all");
|
|
5
|
+
var rules = (0, fs_1.readdirSync)((0, path_1.resolve)(__dirname, "rules"));
|
|
6
|
+
var fileNamePattern = /^(.+)\.js$/;
|
|
7
|
+
module.exports = {
|
|
8
|
+
rules: rules.reduce(function (pv, v) {
|
|
9
|
+
var chunk = v.match(fileNamePattern);
|
|
10
|
+
if (!chunk)
|
|
11
|
+
return pv;
|
|
12
|
+
pv[chunk[1]] = require("./rules/".concat(v))['default'];
|
|
13
|
+
return pv;
|
|
14
|
+
}, {}),
|
|
15
|
+
configs: {
|
|
16
|
+
all: all_1.default
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var utils_1 = require("@typescript-eslint/utils");
|
|
4
|
+
exports.default = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
5
|
+
meta: {
|
|
6
|
+
type: "layout",
|
|
7
|
+
fixable: "code",
|
|
8
|
+
messages: {
|
|
9
|
+
'default': ""
|
|
10
|
+
},
|
|
11
|
+
schema: []
|
|
12
|
+
},
|
|
13
|
+
defaultOptions: [],
|
|
14
|
+
create: function (context) {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
});
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
3
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
4
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
5
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
6
|
+
function step(op) {
|
|
7
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
8
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
9
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
10
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
11
|
+
switch (op[0]) {
|
|
12
|
+
case 0: case 1: t = op; break;
|
|
13
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
14
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
15
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
16
|
+
default:
|
|
17
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
18
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
19
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
20
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
21
|
+
if (t[2]) _.ops.pop();
|
|
22
|
+
_.trys.pop(); continue;
|
|
23
|
+
}
|
|
24
|
+
op = body.call(thisArg, _);
|
|
25
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
26
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
var utils_1 = require("@typescript-eslint/utils");
|
|
31
|
+
exports.default = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
32
|
+
meta: {
|
|
33
|
+
type: "layout",
|
|
34
|
+
fixable: "code",
|
|
35
|
+
messages: {
|
|
36
|
+
'default': "Signature of `{{key}}` should be {{type}}-like."
|
|
37
|
+
},
|
|
38
|
+
schema: [{
|
|
39
|
+
type: "object",
|
|
40
|
+
properties: {
|
|
41
|
+
typeAlias: { type: "string", enum: ["property", "method"] },
|
|
42
|
+
interface: { type: "string", enum: ["property", "method"] }
|
|
43
|
+
}
|
|
44
|
+
}]
|
|
45
|
+
},
|
|
46
|
+
defaultOptions: [{
|
|
47
|
+
typeAlias: "property",
|
|
48
|
+
interface: "method"
|
|
49
|
+
}],
|
|
50
|
+
create: function (context, _a) {
|
|
51
|
+
var options = _a[0];
|
|
52
|
+
var sourceCode = context.getSourceCode();
|
|
53
|
+
return {
|
|
54
|
+
TSPropertySignature: function (node) {
|
|
55
|
+
var _a, _b, _c;
|
|
56
|
+
if (((_a = node.typeAnnotation) === null || _a === void 0 ? void 0 : _a.typeAnnotation.type) !== utils_1.AST_NODE_TYPES.TSFunctionType) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
var type = ((_b = node.parent) === null || _b === void 0 ? void 0 : _b.type) === utils_1.AST_NODE_TYPES.TSTypeLiteral
|
|
60
|
+
? "typeAlias"
|
|
61
|
+
: ((_c = node.parent) === null || _c === void 0 ? void 0 : _c.type) === utils_1.AST_NODE_TYPES.TSInterfaceBody
|
|
62
|
+
? "interface"
|
|
63
|
+
: undefined;
|
|
64
|
+
if (!type) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (options[type] === "property") {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
var returnType = node.typeAnnotation.typeAnnotation.returnType;
|
|
71
|
+
context.report({
|
|
72
|
+
node: node.typeAnnotation,
|
|
73
|
+
messageId: "default",
|
|
74
|
+
data: { key: sourceCode.getText(node.key), type: options[type] },
|
|
75
|
+
fix: function (fixer) {
|
|
76
|
+
var colon, arrow;
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
switch (_a.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
colon = node.typeAnnotation && sourceCode.getFirstToken(node.typeAnnotation);
|
|
81
|
+
arrow = returnType && sourceCode.getFirstToken(returnType);
|
|
82
|
+
if (!colon) return [3 /*break*/, 2];
|
|
83
|
+
return [4 /*yield*/, fixer.remove(colon)];
|
|
84
|
+
case 1:
|
|
85
|
+
_a.sent();
|
|
86
|
+
_a.label = 2;
|
|
87
|
+
case 2:
|
|
88
|
+
if (!arrow) return [3 /*break*/, 4];
|
|
89
|
+
return [4 /*yield*/, fixer.replaceText(arrow, ":")];
|
|
90
|
+
case 3:
|
|
91
|
+
_a.sent();
|
|
92
|
+
_a.label = 4;
|
|
93
|
+
case 4: return [2 /*return*/];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
TSMethodSignature: function (node) {
|
|
100
|
+
var _a, _b;
|
|
101
|
+
var type = ((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) === utils_1.AST_NODE_TYPES.TSTypeLiteral
|
|
102
|
+
? "typeAlias"
|
|
103
|
+
: ((_b = node.parent) === null || _b === void 0 ? void 0 : _b.type) === utils_1.AST_NODE_TYPES.TSInterfaceBody
|
|
104
|
+
? "interface"
|
|
105
|
+
: undefined;
|
|
106
|
+
if (!type) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (options[type] === "method") {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
context.report({
|
|
113
|
+
node: node,
|
|
114
|
+
messageId: "default",
|
|
115
|
+
data: { key: sourceCode.getText(node.key), type: options[type] },
|
|
116
|
+
fix: function (fixer) {
|
|
117
|
+
var colon;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
colon = node.returnType && sourceCode.getFirstToken(node.returnType);
|
|
122
|
+
return [4 /*yield*/, fixer.insertTextAfter(node.key, ":")];
|
|
123
|
+
case 1:
|
|
124
|
+
_a.sent();
|
|
125
|
+
if (!colon) return [3 /*break*/, 3];
|
|
126
|
+
return [4 /*yield*/, fixer.replaceText(colon, "=>")];
|
|
127
|
+
case 2:
|
|
128
|
+
_a.sent();
|
|
129
|
+
_a.label = 3;
|
|
130
|
+
case 3: return [2 /*return*/];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var utils_1 = require("@typescript-eslint/utils");
|
|
4
|
+
var desirousnessPattern = /집에\s*가고\s*싶다/;
|
|
5
|
+
exports.default = utils_1.ESLintUtils.RuleCreator.withoutDocs({
|
|
6
|
+
meta: {
|
|
7
|
+
type: "problem",
|
|
8
|
+
messages: {
|
|
9
|
+
'default': "집에 가기까지 {{left}} 남았습니다... 🥺"
|
|
10
|
+
},
|
|
11
|
+
schema: [{
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
hourFrom: { type: "integer" },
|
|
15
|
+
hourTo: { type: "integer" },
|
|
16
|
+
ignoreWeekend: { type: "boolean" }
|
|
17
|
+
}
|
|
18
|
+
}]
|
|
19
|
+
},
|
|
20
|
+
defaultOptions: [{
|
|
21
|
+
hourFrom: 9,
|
|
22
|
+
hourTo: 18,
|
|
23
|
+
ignoreWeekend: true
|
|
24
|
+
}],
|
|
25
|
+
create: function (context, _a) {
|
|
26
|
+
var _b = _a[0], hourFrom = _b.hourFrom, hourTo = _b.hourTo, ignoreWeekend = _b.ignoreWeekend;
|
|
27
|
+
var now = new Date();
|
|
28
|
+
var sourceCode = context.getSourceCode();
|
|
29
|
+
var weekend = now.getDay() % 6 === 0;
|
|
30
|
+
var inRange = hourFrom <= now.getHours() && now.getHours() < hourTo;
|
|
31
|
+
if (ignoreWeekend && weekend) {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
if (!inRange) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
Program: function () {
|
|
39
|
+
var left = new Date(now.getFullYear(), now.getMonth(), now.getDate(), hourTo).getTime() - now.getTime();
|
|
40
|
+
var leftMinutes = Math.floor(left / 60000);
|
|
41
|
+
for (var _i = 0, _a = sourceCode.getAllComments(); _i < _a.length; _i++) {
|
|
42
|
+
var v = _a[_i];
|
|
43
|
+
if (!desirousnessPattern.test(v.value)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
context.report({
|
|
47
|
+
node: v,
|
|
48
|
+
messageId: "default",
|
|
49
|
+
data: {
|
|
50
|
+
left: leftMinutes > 60
|
|
51
|
+
? "".concat(Math.floor(leftMinutes / 60), "\uC2DC\uAC04 ").concat(leftMinutes % 60, "\uBD84")
|
|
52
|
+
: leftMinutes > 0
|
|
53
|
+
? "".concat(leftMinutes, "\uBD84")
|
|
54
|
+
: "1분도 안"
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
});
|