@asd14/eslint-config 10.3.0 → 12.0.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 +1 -1
- package/README.md +24 -177
- package/dist/types/eslint.config.d.ts +212 -0
- package/dist/types/src/configs/node-jest.d.ts +17 -0
- package/dist/types/src/configs/node.d.ts +210 -0
- package/dist/types/src/configs/nx.d.ts +66 -0
- package/dist/types/src/configs/react-jest.d.ts +20 -0
- package/dist/types/src/configs/react.d.ts +1481 -0
- package/dist/types/src/configs/ts-node.d.ts +252 -0
- package/dist/types/src/index.d.ts +6 -0
- package/dist/types/src/rules/base.d.ts +16 -0
- package/dist/types/src/rules/import.d.ts +44 -0
- package/dist/types/src/rules/jsdoc.d.ts +40 -0
- package/dist/types/src/rules/react.d.ts +120 -0
- package/dist/types/src/rules/rtl.d.ts +13 -0
- package/dist/types/src/rules/typescript.d.ts +53 -0
- package/dist/types/src/rules/unicorn.d.ts +42 -0
- package/dist/types/src/utils/find-up-sync.d.ts +34 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +52 -65
- package/src/configs/node-jest.js +29 -0
- package/src/configs/node.js +65 -0
- package/src/configs/nx.js +121 -0
- package/src/configs/react-jest.js +16 -0
- package/src/configs/react.js +86 -0
- package/src/configs/ts-node.js +23 -0
- package/src/index.js +6 -0
- package/src/rules/base.js +24 -0
- package/src/rules/import.js +55 -0
- package/src/rules/jsdoc.js +49 -0
- package/{rules → src/rules}/react.js +41 -27
- package/src/rules/rtl.js +6 -0
- package/src/rules/typescript.js +88 -0
- package/{rules → src/rules}/unicorn.js +19 -41
- package/src/utils/find-up-sync.js +56 -0
- package/rules/best-practices.js +0 -11
- package/rules/comments.js +0 -46
- package/rules/errors.js +0 -112
- package/rules/es6.js +0 -48
- package/rules/html.js +0 -59
- package/rules/import-ts.js +0 -41
- package/rules/import.js +0 -101
- package/rules/jsdoc-ts.js +0 -8
- package/rules/jsdoc.js +0 -103
- package/rules/json.js +0 -9
- package/rules/node.js +0 -56
- package/rules/prettier.js +0 -16
- package/rules/promise.js +0 -68
- package/rules/style.js +0 -252
- package/rules/variables.js +0 -70
- package/targets/node-esm.js +0 -25
- package/targets/node-ts.js +0 -36
- package/targets/node.js +0 -36
- package/targets/react-ts.js +0 -94
- package/targets/react.js +0 -90
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import prettierConfig from "eslint-plugin-prettier/recommended"
|
|
2
|
+
import globals from "globals"
|
|
3
|
+
|
|
4
|
+
import baseConfig from "../rules/base.js"
|
|
5
|
+
import importConfig from "../rules/import.js"
|
|
6
|
+
import jsdocConfig from "../rules/jsdoc.js"
|
|
7
|
+
import reactHooksConfig from "../rules/react.js"
|
|
8
|
+
import tsConfig from "../rules/typescript.js"
|
|
9
|
+
import unicornConfig from "../rules/unicorn.js"
|
|
10
|
+
|
|
11
|
+
/** @type {import("eslint").Linter.RulesRecord} */
|
|
12
|
+
const reactSpecificRules = {
|
|
13
|
+
"no-console": "off",
|
|
14
|
+
"unicorn/prevent-abbreviations": [
|
|
15
|
+
"error",
|
|
16
|
+
{
|
|
17
|
+
replacements: {
|
|
18
|
+
i: false,
|
|
19
|
+
params: false,
|
|
20
|
+
lib: false,
|
|
21
|
+
args: {
|
|
22
|
+
params: true,
|
|
23
|
+
},
|
|
24
|
+
props: false,
|
|
25
|
+
opts: {
|
|
26
|
+
props: true,
|
|
27
|
+
},
|
|
28
|
+
options: {
|
|
29
|
+
props: true,
|
|
30
|
+
},
|
|
31
|
+
fn: false,
|
|
32
|
+
acc: false,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** @satisfies {import("eslint").Linter.Config} */
|
|
39
|
+
export const reactConfig = /** @type {const} */ ({
|
|
40
|
+
name: "ASD14 config for React source files",
|
|
41
|
+
ignores: ["node_modules", "dist", "coverage", "build"],
|
|
42
|
+
languageOptions: {
|
|
43
|
+
...tsConfig.languageOptions,
|
|
44
|
+
ecmaVersion: "latest",
|
|
45
|
+
sourceType: "module",
|
|
46
|
+
parserOptions: {
|
|
47
|
+
projectService: true,
|
|
48
|
+
ecmaVersion: "latest",
|
|
49
|
+
ecmaFeatures: {
|
|
50
|
+
jsx: true,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
globals: {
|
|
54
|
+
...globals.serviceworker,
|
|
55
|
+
...globals.browser,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
plugins: {
|
|
59
|
+
...importConfig.plugins,
|
|
60
|
+
...jsdocConfig.plugins,
|
|
61
|
+
...reactHooksConfig.plugins,
|
|
62
|
+
...tsConfig.plugins,
|
|
63
|
+
...unicornConfig.plugins,
|
|
64
|
+
...prettierConfig.plugins,
|
|
65
|
+
},
|
|
66
|
+
rules: {
|
|
67
|
+
...baseConfig.rules,
|
|
68
|
+
...importConfig.rules,
|
|
69
|
+
...jsdocConfig.rules,
|
|
70
|
+
...reactHooksConfig.rules,
|
|
71
|
+
...reactSpecificRules,
|
|
72
|
+
...tsConfig.rules,
|
|
73
|
+
...unicornConfig.rules,
|
|
74
|
+
...prettierConfig.rules,
|
|
75
|
+
},
|
|
76
|
+
settings: {
|
|
77
|
+
...importConfig.settings,
|
|
78
|
+
...reactHooksConfig.settings,
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
* A list of regex strings that, if matched by a path, will not report
|
|
82
|
+
* the matching module if no exports are found.
|
|
83
|
+
*/
|
|
84
|
+
"import/ignore": [".(sass|scss|less|css)$"],
|
|
85
|
+
},
|
|
86
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { nodeConfig } from "./node.js"
|
|
2
|
+
import tsConfig from "../rules/typescript.js"
|
|
3
|
+
|
|
4
|
+
/** @satisfies {import("eslint").Linter.Config} */
|
|
5
|
+
export const tsNodeConfig = /** @type {const} */ ({
|
|
6
|
+
name: "ASD14 config for Typescript + Node.js source files",
|
|
7
|
+
ignores: ["node_modules", "dist", "coverage", "build"],
|
|
8
|
+
languageOptions: {
|
|
9
|
+
...nodeConfig.languageOptions,
|
|
10
|
+
...tsConfig.languageOptions,
|
|
11
|
+
},
|
|
12
|
+
plugins: {
|
|
13
|
+
...tsConfig.plugins,
|
|
14
|
+
...nodeConfig.plugins,
|
|
15
|
+
},
|
|
16
|
+
rules: {
|
|
17
|
+
...tsConfig.rules,
|
|
18
|
+
...nodeConfig.rules,
|
|
19
|
+
},
|
|
20
|
+
settings: {
|
|
21
|
+
...nodeConfig.settings,
|
|
22
|
+
},
|
|
23
|
+
})
|
package/src/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** @satisfies {import("eslint").Linter.Config} */
|
|
2
|
+
export default /** @type {const} */ ({
|
|
3
|
+
rules: {
|
|
4
|
+
// Allow default named exports, ie. `export { asd as default } from "lorem.js"`,
|
|
5
|
+
// to avoid conflicts with "unicorn/prefer-export-from"
|
|
6
|
+
"no-restricted-exports": [
|
|
7
|
+
"error",
|
|
8
|
+
{
|
|
9
|
+
restrictDefaultExports: {
|
|
10
|
+
named: false,
|
|
11
|
+
namedFrom: false,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
"no-underscore-dangle": [
|
|
16
|
+
"error",
|
|
17
|
+
{
|
|
18
|
+
allow: ["_dirname", "_testResult"],
|
|
19
|
+
allowInArrayDestructuring: true,
|
|
20
|
+
allowInObjectDestructuring: true,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
})
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import importPlugin from "eslint-plugin-import"
|
|
2
|
+
|
|
3
|
+
const importConfig = importPlugin.flatConfigs.recommended
|
|
4
|
+
const importTSConfig = importPlugin.flatConfigs.typescript
|
|
5
|
+
|
|
6
|
+
/** @satisfies {import("eslint").Linter.Config} */
|
|
7
|
+
export default /** @type {const} */ ({
|
|
8
|
+
plugins: importConfig.plugins,
|
|
9
|
+
rules: {
|
|
10
|
+
...importConfig.rules,
|
|
11
|
+
...importTSConfig.rules,
|
|
12
|
+
"import/no-extraneous-dependencies": ["error", { includeTypes: true }],
|
|
13
|
+
"import/no-cycle": ["error", { maxDepth: Infinity }],
|
|
14
|
+
"import/no-self-import": "error",
|
|
15
|
+
"import/no-absolute-path": "error",
|
|
16
|
+
"import/default": "error",
|
|
17
|
+
"import/export": "error",
|
|
18
|
+
"import/prefer-default-export": "off",
|
|
19
|
+
"import/namespace": ["error", { allowComputed: true }],
|
|
20
|
+
"import/no-duplicates": "error",
|
|
21
|
+
"import/no-named-as-default": "error",
|
|
22
|
+
"import/no-named-as-default-member": "error",
|
|
23
|
+
"import/unambiguous": "off",
|
|
24
|
+
"import/exports-last": "error",
|
|
25
|
+
"import/named": "off",
|
|
26
|
+
"import/no-unresolved": "off",
|
|
27
|
+
"import/extensions": ["error", "always", { ignorePackages: true }],
|
|
28
|
+
"import/order": [
|
|
29
|
+
"error",
|
|
30
|
+
{
|
|
31
|
+
groups: [
|
|
32
|
+
"builtin",
|
|
33
|
+
"external",
|
|
34
|
+
"internal",
|
|
35
|
+
["index", "sibling", "parent"],
|
|
36
|
+
"object",
|
|
37
|
+
"unknown",
|
|
38
|
+
],
|
|
39
|
+
pathGroups: [
|
|
40
|
+
{
|
|
41
|
+
pattern: "@self-ui/*",
|
|
42
|
+
group: "external",
|
|
43
|
+
position: "after",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
pathGroupsExcludedImportTypes: ["builtin"],
|
|
47
|
+
alphabetize: {
|
|
48
|
+
order: "asc",
|
|
49
|
+
caseInsensitive: true,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
settings: importTSConfig.settings,
|
|
55
|
+
})
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import jsdoc from "eslint-plugin-jsdoc"
|
|
2
|
+
|
|
3
|
+
/** @satisfies {import('eslint').Linter.Config} */
|
|
4
|
+
export default /** @type {const} */ ({
|
|
5
|
+
plugins: {
|
|
6
|
+
jsdoc,
|
|
7
|
+
},
|
|
8
|
+
rules: {
|
|
9
|
+
"jsdoc/sort-tags": [
|
|
10
|
+
"error",
|
|
11
|
+
{
|
|
12
|
+
reportIntraTagGroupSpacing: false,
|
|
13
|
+
reportTagGroupSpacing: false,
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
"jsdoc/tag-lines": [
|
|
17
|
+
"error",
|
|
18
|
+
"always",
|
|
19
|
+
{
|
|
20
|
+
startLines: 1,
|
|
21
|
+
endLines: 0,
|
|
22
|
+
applyToEndTag: false,
|
|
23
|
+
tags: {
|
|
24
|
+
returns: {
|
|
25
|
+
lines: "always",
|
|
26
|
+
},
|
|
27
|
+
property: {
|
|
28
|
+
lines: "any",
|
|
29
|
+
},
|
|
30
|
+
param: {
|
|
31
|
+
lines: "any",
|
|
32
|
+
},
|
|
33
|
+
example: {
|
|
34
|
+
lines: "always",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
"jsdoc/check-indentation": "error",
|
|
40
|
+
"jsdoc/check-alignment": "error",
|
|
41
|
+
"jsdoc/no-bad-blocks": "error",
|
|
42
|
+
"jsdoc/require-asterisk-prefix": ["error", "always"],
|
|
43
|
+
|
|
44
|
+
"jsdoc/require-description": "off",
|
|
45
|
+
"jsdoc/require-property-description": "off",
|
|
46
|
+
"jsdoc/require-param-description": "off",
|
|
47
|
+
"jsdoc/require-returns-description": "off",
|
|
48
|
+
},
|
|
49
|
+
})
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* "react/jsx-max-props-per-line": "off",
|
|
17
|
-
* "react/jsx-one-expression-per-line": "off",
|
|
18
|
-
* "react/jsx-props-no-multi-spaces": "off",
|
|
19
|
-
* "react/jsx-space-before-closing": "off",
|
|
20
|
-
* "react/jsx-tag-spacing": "off",
|
|
21
|
-
* "react/jsx-wrap-multilines": "off"
|
|
22
|
-
*/
|
|
1
|
+
import reactPlugin from "eslint-plugin-react"
|
|
2
|
+
import reactHooksPlugin from "eslint-plugin-react-hooks"
|
|
3
|
+
import reactRefresh from "eslint-plugin-react-refresh"
|
|
4
|
+
|
|
5
|
+
const reactRecommendedConfig = /** @type {import("eslint").Linter.Config} */ (
|
|
6
|
+
reactPlugin.configs.flat?.["recommended"]
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
/** @satisfies {import("eslint").Linter.Config} */
|
|
10
|
+
export default /** @type {const} */ ({
|
|
11
|
+
plugins: {
|
|
12
|
+
...reactRecommendedConfig.plugins,
|
|
13
|
+
"react-hooks": reactHooksPlugin,
|
|
14
|
+
"react-refresh": reactRefresh,
|
|
15
|
+
},
|
|
23
16
|
rules: {
|
|
17
|
+
...reactRecommendedConfig.rules,
|
|
18
|
+
|
|
19
|
+
// Validate that your components can safely be updated with Fast Refresh.
|
|
20
|
+
"react-refresh/only-export-components": "error",
|
|
21
|
+
|
|
24
22
|
// Checks rules of Hooks
|
|
25
23
|
"react-hooks/rules-of-hooks": "error",
|
|
26
24
|
|
|
27
25
|
// Checks effect dependencies
|
|
28
|
-
"react-hooks/exhaustive-deps": "
|
|
26
|
+
"react-hooks/exhaustive-deps": "error",
|
|
29
27
|
|
|
30
28
|
// Prevent missing displayName in a React component definition
|
|
31
29
|
"react/display-name": "off",
|
|
@@ -144,11 +142,19 @@ module.exports = {
|
|
|
144
142
|
// Prevent invalid characters from appearing in markup
|
|
145
143
|
"react/no-unknown-property": "error",
|
|
146
144
|
|
|
145
|
+
"react/function-component-definition": [
|
|
146
|
+
"error",
|
|
147
|
+
{
|
|
148
|
+
namedComponents: "arrow-function",
|
|
149
|
+
unnamedComponents: "arrow-function",
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
|
|
147
153
|
// Prevent missing props validation in a React component definition
|
|
148
|
-
"react/prop-types": "
|
|
154
|
+
"react/prop-types": "off",
|
|
149
155
|
|
|
150
156
|
// Prevent missing React when using JSX
|
|
151
|
-
"react/react-in-jsx-scope": "
|
|
157
|
+
"react/react-in-jsx-scope": "off",
|
|
152
158
|
|
|
153
159
|
// Enforce ES5 or ES6 class for returning value in render function
|
|
154
160
|
"react/require-render-return": "error",
|
|
@@ -183,7 +189,7 @@ module.exports = {
|
|
|
183
189
|
* Declaring only one component per file improves readability and
|
|
184
190
|
* reusability of components.
|
|
185
191
|
*/
|
|
186
|
-
"react/no-multi-comp": "
|
|
192
|
+
"react/no-multi-comp": "off",
|
|
187
193
|
|
|
188
194
|
/*
|
|
189
195
|
* Updating the state after a component update will trigger a second
|
|
@@ -234,6 +240,7 @@ module.exports = {
|
|
|
234
240
|
"react/require-default-props": [
|
|
235
241
|
"error",
|
|
236
242
|
{
|
|
243
|
+
functions: "defaultArguments",
|
|
237
244
|
forbidDefaultForRequired: true,
|
|
238
245
|
},
|
|
239
246
|
],
|
|
@@ -328,5 +335,12 @@ module.exports = {
|
|
|
328
335
|
|
|
329
336
|
// Prevent usage of button elements without an explicit type attribute
|
|
330
337
|
"react/button-has-type": "error",
|
|
338
|
+
|
|
339
|
+
"react/jsx-props-no-spreading": "off",
|
|
340
|
+
},
|
|
341
|
+
settings: {
|
|
342
|
+
react: {
|
|
343
|
+
version: "detect",
|
|
344
|
+
},
|
|
331
345
|
},
|
|
332
|
-
}
|
|
346
|
+
})
|
package/src/rules/rtl.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import tsPlugin from "@typescript-eslint/eslint-plugin"
|
|
2
|
+
import tsParser from "@typescript-eslint/parser"
|
|
3
|
+
|
|
4
|
+
/** @satisfies {import("eslint").Linter.Config} */
|
|
5
|
+
export default /** @type {const} */ ({
|
|
6
|
+
languageOptions: {
|
|
7
|
+
parser: tsParser,
|
|
8
|
+
},
|
|
9
|
+
plugins: {
|
|
10
|
+
"@typescript-eslint": /** @type {any} */ (tsPlugin),
|
|
11
|
+
},
|
|
12
|
+
rules: {
|
|
13
|
+
...tsPlugin.configs["strict-type-checked"]?.rules,
|
|
14
|
+
|
|
15
|
+
"@typescript-eslint/no-unused-vars": [
|
|
16
|
+
"error",
|
|
17
|
+
{
|
|
18
|
+
args: "all",
|
|
19
|
+
argsIgnorePattern: "^_",
|
|
20
|
+
caughtErrors: "all",
|
|
21
|
+
caughtErrorsIgnorePattern: "^_",
|
|
22
|
+
destructuredArrayIgnorePattern: "^_",
|
|
23
|
+
varsIgnorePattern: "^_",
|
|
24
|
+
ignoreRestSiblings: true,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
|
|
28
|
+
//
|
|
29
|
+
"@typescript-eslint/require-await": "warn",
|
|
30
|
+
|
|
31
|
+
// Conflicts with TypeScript's own error where accessing a property that
|
|
32
|
+
// doesn't exist on a type must be accessed with index notation.
|
|
33
|
+
"@typescript-eslint/dot-notation": "off",
|
|
34
|
+
|
|
35
|
+
"@typescript-eslint/restrict-template-expressions": [
|
|
36
|
+
"error",
|
|
37
|
+
{
|
|
38
|
+
allowBoolean: true,
|
|
39
|
+
allowNumber: true,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
|
|
43
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
44
|
+
"@typescript-eslint/no-use-before-define": "error",
|
|
45
|
+
|
|
46
|
+
"@typescript-eslint/naming-convention": [
|
|
47
|
+
"error",
|
|
48
|
+
{
|
|
49
|
+
selector: "default",
|
|
50
|
+
leadingUnderscore: "allow",
|
|
51
|
+
format: ["camelCase", "PascalCase", "UPPER_CASE"],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
selector: "variable",
|
|
55
|
+
types: ["boolean"],
|
|
56
|
+
format: ["camelCase", "PascalCase"],
|
|
57
|
+
prefix: ["is", "has", "can", "does", "should", "will", "did", "was"],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
selector: "variable",
|
|
61
|
+
types: ["boolean", "number", "string", "array"],
|
|
62
|
+
modifiers: ["const", "global"],
|
|
63
|
+
format: ["UPPER_CASE"],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
selector: "typeAlias",
|
|
67
|
+
format: ["PascalCase"],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
selector: "typeParameter",
|
|
71
|
+
format: ["PascalCase"],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
selector: [
|
|
75
|
+
"classProperty",
|
|
76
|
+
"objectLiteralProperty",
|
|
77
|
+
"typeProperty",
|
|
78
|
+
"classMethod",
|
|
79
|
+
"objectLiteralMethod",
|
|
80
|
+
"typeMethod",
|
|
81
|
+
"accessor",
|
|
82
|
+
"enumMember",
|
|
83
|
+
],
|
|
84
|
+
format: [],
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
})
|
|
@@ -1,40 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
plugins: ["unicorn"],
|
|
1
|
+
import unicornPlugin from "eslint-plugin-unicorn"
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Disabled by prettier
|
|
8
|
-
* https://github.com/prettier/eslint-config-prettier/blob/master/unicorn.js
|
|
9
|
-
*
|
|
10
|
-
* "unicorn/number-literal-case": "off"
|
|
11
|
-
*/
|
|
3
|
+
/** @satisfies {import('eslint').Linter.Config} */
|
|
4
|
+
export default /** @type {const} */ ({
|
|
5
|
+
...unicornPlugin.configs["flat/recommended"],
|
|
12
6
|
rules: {
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
/*
|
|
8
|
+
* Disabled by prettier
|
|
9
|
+
* https://github.com/prettier/eslint-config-prettier/blob/master/unicorn.js
|
|
10
|
+
*
|
|
11
|
+
* "unicorn/number-literal-case": "off"
|
|
12
|
+
*/
|
|
15
13
|
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
params: false,
|
|
22
|
-
lib: false,
|
|
23
|
-
args: {
|
|
24
|
-
params: true,
|
|
25
|
-
},
|
|
26
|
-
props: false,
|
|
27
|
-
opts: {
|
|
28
|
-
props: true,
|
|
29
|
-
},
|
|
30
|
-
source: {
|
|
31
|
-
input: true,
|
|
32
|
-
},
|
|
33
|
-
fn: false,
|
|
34
|
-
acc: false,
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
],
|
|
14
|
+
// Use "node:" protocol when importing Node.js builtin modules
|
|
15
|
+
"unicorn/prefer-node-protocol": "error",
|
|
16
|
+
|
|
17
|
+
// We like functional programming
|
|
18
|
+
"unicorn/no-array-for-each": "off",
|
|
38
19
|
|
|
39
20
|
// Move function definitions to the highest possible scope.
|
|
40
21
|
// Too noisy when curring functions
|
|
@@ -137,19 +118,16 @@ module.exports = {
|
|
|
137
118
|
// Enforce throwing TypeError in type checking conditions
|
|
138
119
|
"unicorn/prefer-type-error": "error",
|
|
139
120
|
|
|
121
|
+
// Cannot satisfy "consistent-return" with this rule enabled
|
|
122
|
+
"unicorn/no-useless-undefined": "off",
|
|
123
|
+
|
|
140
124
|
/*
|
|
141
125
|
* Enforce the use of new for all builtins, except String, Number and
|
|
142
126
|
* Boolean
|
|
143
127
|
*/
|
|
144
128
|
"unicorn/new-for-builtins": "error",
|
|
145
129
|
|
|
146
|
-
/*
|
|
147
|
-
* Disallow unsafe regular expressions. Uses safe-regex to disallow
|
|
148
|
-
* potentially catastrophic exponential-time regular expressions.
|
|
149
|
-
*/
|
|
150
|
-
"unicorn/no-unsafe-regex": "error",
|
|
151
|
-
|
|
152
130
|
// Enforce passing a message value when throwing a built-in error
|
|
153
131
|
"unicorn/error-message": "error",
|
|
154
132
|
},
|
|
155
|
-
}
|
|
133
|
+
})
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import fs from "node:fs"
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} FindUpSyncOptions
|
|
6
|
+
*
|
|
7
|
+
* @property {string} [cwd] - The current working directory to start from.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @callback FindUpSyncFn
|
|
12
|
+
*
|
|
13
|
+
* @param {string} fileName - The name of the file to find.
|
|
14
|
+
* @param {FindUpSyncOptions} [options] - Options for the function.
|
|
15
|
+
* @returns {string} The absolute path to the file.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Find a file up the directory tree synchronously.
|
|
20
|
+
*
|
|
21
|
+
* @type {FindUpSyncFn}
|
|
22
|
+
*
|
|
23
|
+
* @throws {Error} If the starting folder does not exist.
|
|
24
|
+
*
|
|
25
|
+
* @throws {Error} If the file does not exist up the tree.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const filePath = findUpSync("lerna.json");
|
|
29
|
+
* //=> "/Users/johndoe/Projects/WootWoot/lerna.json"
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
const findUpSync = (fileName, options = {}) => {
|
|
33
|
+
let { cwd } = options
|
|
34
|
+
cwd = path.resolve(cwd ?? process.cwd())
|
|
35
|
+
|
|
36
|
+
if (!fs.statSync(cwd).isDirectory()) {
|
|
37
|
+
throw new Error(`Path "${cwd}" does not exist or is not a directory`)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let { root } = path.parse(cwd)
|
|
41
|
+
|
|
42
|
+
while (cwd !== root) {
|
|
43
|
+
const file_path = path.join(cwd, fileName)
|
|
44
|
+
|
|
45
|
+
if (fs.existsSync(file_path)) {
|
|
46
|
+
return file_path
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
cwd = path.dirname(cwd)
|
|
50
|
+
root = path.parse(cwd).root
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
throw new Error(`File "${fileName}" does not exist up the tree`)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { findUpSync }
|
package/rules/best-practices.js
DELETED
package/rules/comments.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
rules: {
|
|
3
|
-
/*
|
|
4
|
-
* Enforce a consistent style of comments across your codebase,
|
|
5
|
-
* specifically by either requiring or disallowing a capitalized
|
|
6
|
-
* letter as the first word character in a comment. This rule will not
|
|
7
|
-
* issue warnings when non-cased letters are used.
|
|
8
|
-
*/
|
|
9
|
-
"capitalized-comments": "off",
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
* Enforces consistent position of line comments. Block comments are
|
|
13
|
-
* not affected by this rule. By default, this rule ignores comments
|
|
14
|
-
* starting with the following words: eslint, jshint, jslint,
|
|
15
|
-
* istanbul, global, exported, jscs, falls through.
|
|
16
|
-
*/
|
|
17
|
-
"line-comment-position": [
|
|
18
|
-
"error",
|
|
19
|
-
{
|
|
20
|
-
position: "above",
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
|
|
24
|
-
// Disallow usage of configurable warning terms in comments: e.g. todo
|
|
25
|
-
"no-warning-comments": [
|
|
26
|
-
0,
|
|
27
|
-
{
|
|
28
|
-
location: "start",
|
|
29
|
-
terms: ["todo", "fixme", "xxx"],
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
|
|
33
|
-
/*
|
|
34
|
-
* Enforce consistency of spacing after the start of a comment // or
|
|
35
|
-
* /*. It also provides several exceptions for various documentation
|
|
36
|
-
* styles.
|
|
37
|
-
*/
|
|
38
|
-
"spaced-comment": ["error", "always"],
|
|
39
|
-
|
|
40
|
-
/*
|
|
41
|
-
* This rule aims to enforce a particular style for
|
|
42
|
-
* multiline comments.
|
|
43
|
-
*/
|
|
44
|
-
"multiline-comment-style": "off",
|
|
45
|
-
},
|
|
46
|
-
}
|