chayns-toolkit 2.0.0-beta.2 → 2.0.0-beta.22
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 -21
- package/README.md +38 -491
- package/babel.js +6 -11
- package/cli.js +1 -1
- package/eslint/index.js +65 -0
- package/eslint/javascriptRules.js +8 -0
- package/eslint/sharedRules.js +32 -0
- package/eslint/typescriptRules.js +20 -0
- package/lib/cli.js +42 -37
- package/package.json +143 -139
- package/eslint.js +0 -3
- package/lib/eslint.js +0 -150
package/eslint/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const path = require("path")
|
|
2
|
+
const javascriptRules = require("./javascriptRules")
|
|
3
|
+
const sharedRules = require("./sharedRules")
|
|
4
|
+
const typescriptRules = require("./typescriptRules")
|
|
5
|
+
|
|
6
|
+
// eslint-disable-next-line import/no-dynamic-require
|
|
7
|
+
const packageJson = require(path.resolve("package.json"))
|
|
8
|
+
|
|
9
|
+
const usesTypeScript = Object.keys({
|
|
10
|
+
...packageJson.dependencies,
|
|
11
|
+
...packageJson.devDependencies,
|
|
12
|
+
}).includes("typescript")
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
env: {
|
|
16
|
+
browser: true,
|
|
17
|
+
es6: true,
|
|
18
|
+
},
|
|
19
|
+
extends: ["airbnb", "airbnb/hooks", "prettier"],
|
|
20
|
+
globals: { chayns: true },
|
|
21
|
+
rules: { ...sharedRules, ...javascriptRules },
|
|
22
|
+
parser: "@babel/eslint-parser",
|
|
23
|
+
parserOptions: {
|
|
24
|
+
requireConfigFile: false,
|
|
25
|
+
},
|
|
26
|
+
settings: {
|
|
27
|
+
"import/resolver": {
|
|
28
|
+
typescript: { project: "@(jsconfig|tsconfig).json" },
|
|
29
|
+
},
|
|
30
|
+
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
|
|
31
|
+
},
|
|
32
|
+
overrides: [
|
|
33
|
+
usesTypeScript && {
|
|
34
|
+
files: ["**/*.ts?(x)"],
|
|
35
|
+
extends: [
|
|
36
|
+
"airbnb-typescript",
|
|
37
|
+
"airbnb/hooks",
|
|
38
|
+
"plugin:@typescript-eslint/recommended",
|
|
39
|
+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
|
|
40
|
+
"prettier",
|
|
41
|
+
"plugin:import/typescript",
|
|
42
|
+
],
|
|
43
|
+
rules: {
|
|
44
|
+
...sharedRules,
|
|
45
|
+
...typescriptRules,
|
|
46
|
+
},
|
|
47
|
+
parserOptions: {
|
|
48
|
+
project: "./tsconfig.json",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
files: ["**/*.@(test|spec).@(js|jsx|ts|tsx)"],
|
|
53
|
+
env: { "jest/globals": true },
|
|
54
|
+
plugins: ["jest"],
|
|
55
|
+
rules: {
|
|
56
|
+
...sharedRules,
|
|
57
|
+
"jest/no-disabled-tests": "warn",
|
|
58
|
+
"jest/no-focused-tests": "error",
|
|
59
|
+
"jest/no-identical-title": "error",
|
|
60
|
+
"jest/prefer-to-have-length": "warn",
|
|
61
|
+
"jest/valid-expect": "error",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
].filter(Boolean),
|
|
65
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const sharedRules = {
|
|
2
|
+
"import/extensions": [
|
|
3
|
+
"error",
|
|
4
|
+
"always",
|
|
5
|
+
{ js: "never", jsx: "never", ts: "never", tsx: "never" },
|
|
6
|
+
],
|
|
7
|
+
"import/no-unresolved": ["error", { ignore: ["chayns-components"] }],
|
|
8
|
+
"import/prefer-default-export": "off",
|
|
9
|
+
"jsx-a11y/anchor-has-content": "off",
|
|
10
|
+
"jsx-a11y/anchor-is-valid": "off",
|
|
11
|
+
"jsx-a11y/click-events-have-key-events": "off",
|
|
12
|
+
"jsx-a11y/heading-has-content": "off",
|
|
13
|
+
"jsx-a11y/href-no-hash": "off",
|
|
14
|
+
"jsx-a11y/no-noninteractive-element-interactions": "off",
|
|
15
|
+
"jsx-a11y/no-static-element-interactions": "off",
|
|
16
|
+
"no-console": ["warn", { allow: ["warn", "error"] }],
|
|
17
|
+
"no-param-reassign": [
|
|
18
|
+
"error",
|
|
19
|
+
{ ignorePropertyModificationsFor: ["draft"], props: true },
|
|
20
|
+
],
|
|
21
|
+
"no-plusplus": "off",
|
|
22
|
+
"no-restricted-imports": [
|
|
23
|
+
"error",
|
|
24
|
+
{
|
|
25
|
+
message: "Use 'chayns-components' instead to enable tree-shaking.",
|
|
26
|
+
name: "chayns-components/lib",
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
"react/no-danger": "off",
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
module.exports = sharedRules
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const typescriptRules = {
|
|
2
|
+
"react/prop-types": "off",
|
|
3
|
+
"react/require-default-props": "off",
|
|
4
|
+
"@typescript-eslint/no-use-before-define": [
|
|
5
|
+
"error",
|
|
6
|
+
{ functions: false, classes: false, variables: false, enums: false },
|
|
7
|
+
],
|
|
8
|
+
"@typescript-eslint/ban-ts-comment": [
|
|
9
|
+
"error",
|
|
10
|
+
{
|
|
11
|
+
"ts-expect-error": "allow-with-description",
|
|
12
|
+
"ts-ignore": true,
|
|
13
|
+
"ts-nocheck": true,
|
|
14
|
+
"ts-check": true,
|
|
15
|
+
minimumDescriptionLength: 4,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = typescriptRules
|