chayns-toolkit 2.0.0-beta.13 → 2.0.0-beta.16
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/babel.js +70 -70
- package/eslint/index.js +65 -65
- package/lib/cli.js +34 -39
- package/package.json +1 -1
package/babel.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
const { declare } = require("@babel/helper-plugin-utils")
|
|
2
|
-
|
|
3
|
-
module.exports = declare((api, options) => {
|
|
4
|
-
api.assertVersion(7)
|
|
5
|
-
|
|
6
|
-
const env = process.env.BABEL_ENV || process.env.NODE_ENV
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
typescriptSupport = false,
|
|
10
|
-
flowSupport = false,
|
|
11
|
-
transpileModules = false,
|
|
12
|
-
reactRefreshSupport = true,
|
|
13
|
-
} = options
|
|
14
|
-
|
|
15
|
-
if (env === "test") {
|
|
16
|
-
return { presets: [["@babel/env", { targets: { node: "current" } }]] }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
presets: [
|
|
21
|
-
[
|
|
22
|
-
"@babel/env",
|
|
23
|
-
{
|
|
24
|
-
loose: true,
|
|
25
|
-
bugfixes: true,
|
|
26
|
-
modules: transpileModules,
|
|
27
|
-
exclude: ["transform-typeof-symbol"],
|
|
28
|
-
useBuiltIns: "usage",
|
|
29
|
-
corejs: 3,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
[
|
|
33
|
-
"@babel/react",
|
|
34
|
-
{
|
|
35
|
-
runtime: "automatic",
|
|
36
|
-
development: env !== "production",
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
flowSupport && "@babel/flow",
|
|
40
|
-
typescriptSupport && "@babel/typescript",
|
|
41
|
-
].filter(Boolean),
|
|
42
|
-
plugins: [
|
|
43
|
-
"macros",
|
|
44
|
-
"optimize-clsx",
|
|
45
|
-
[
|
|
46
|
-
"@babel/transform-runtime",
|
|
47
|
-
{
|
|
48
|
-
// eslint-disable-next-line global-require
|
|
49
|
-
version: require("@babel/runtime/package.json").version,
|
|
50
|
-
corejs: false,
|
|
51
|
-
regenerator: true,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
typescriptSupport && [
|
|
55
|
-
"@babel/proposal-decorators",
|
|
56
|
-
{ legacy: true },
|
|
57
|
-
],
|
|
58
|
-
env === "production" && "transform-react-remove-prop-types",
|
|
59
|
-
reactRefreshSupport &&
|
|
60
|
-
env !== "production" &&
|
|
61
|
-
"react-refresh/babel",
|
|
62
|
-
[
|
|
63
|
-
"@babel/plugin-transform-spread",
|
|
64
|
-
{
|
|
65
|
-
loose: false,
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
].filter(Boolean),
|
|
69
|
-
}
|
|
70
|
-
})
|
|
1
|
+
const { declare } = require("@babel/helper-plugin-utils")
|
|
2
|
+
|
|
3
|
+
module.exports = declare((api, options) => {
|
|
4
|
+
api.assertVersion(7)
|
|
5
|
+
|
|
6
|
+
const env = process.env.BABEL_ENV || process.env.NODE_ENV
|
|
7
|
+
|
|
8
|
+
const {
|
|
9
|
+
typescriptSupport = false,
|
|
10
|
+
flowSupport = false,
|
|
11
|
+
transpileModules = false,
|
|
12
|
+
reactRefreshSupport = true,
|
|
13
|
+
} = options
|
|
14
|
+
|
|
15
|
+
if (env === "test") {
|
|
16
|
+
return { presets: [["@babel/env", { targets: { node: "current" } }]] }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
presets: [
|
|
21
|
+
[
|
|
22
|
+
"@babel/env",
|
|
23
|
+
{
|
|
24
|
+
loose: true,
|
|
25
|
+
bugfixes: true,
|
|
26
|
+
modules: transpileModules,
|
|
27
|
+
exclude: ["transform-typeof-symbol"],
|
|
28
|
+
useBuiltIns: "usage",
|
|
29
|
+
corejs: 3,
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
[
|
|
33
|
+
"@babel/react",
|
|
34
|
+
{
|
|
35
|
+
runtime: "automatic",
|
|
36
|
+
development: env !== "production",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
flowSupport && "@babel/flow",
|
|
40
|
+
typescriptSupport && "@babel/typescript",
|
|
41
|
+
].filter(Boolean),
|
|
42
|
+
plugins: [
|
|
43
|
+
"macros",
|
|
44
|
+
"optimize-clsx",
|
|
45
|
+
[
|
|
46
|
+
"@babel/transform-runtime",
|
|
47
|
+
{
|
|
48
|
+
// eslint-disable-next-line global-require
|
|
49
|
+
version: require("@babel/runtime/package.json").version,
|
|
50
|
+
corejs: false,
|
|
51
|
+
regenerator: true,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
typescriptSupport && [
|
|
55
|
+
"@babel/proposal-decorators",
|
|
56
|
+
{ legacy: true },
|
|
57
|
+
],
|
|
58
|
+
env === "production" && "transform-react-remove-prop-types",
|
|
59
|
+
reactRefreshSupport &&
|
|
60
|
+
env !== "production" &&
|
|
61
|
+
"react-refresh/babel",
|
|
62
|
+
[
|
|
63
|
+
"@babel/plugin-transform-spread",
|
|
64
|
+
{
|
|
65
|
+
loose: false,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
].filter(Boolean),
|
|
69
|
+
}
|
|
70
|
+
})
|
package/eslint/index.js
CHANGED
|
@@ -1,65 +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
|
-
}
|
|
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
|
+
}
|