@rpcbase/cli 0.68.0 → 0.69.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/bin.js +1 -0
- package/package.json +1 -6
- package/eslint/config.js +0 -92
- package/eslint/index.js +0 -8
- package/eslint/src/mobile_overrides.js +0 -10
- package/eslint/src/rules/no-rb-restricted-imports/index.js +0 -31
- package/eslint/src/rules/no-unused-imports/index.js +0 -67
- package/eslint/src/rules/no-unused-imports/test.js +0 -54
package/bin.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpcbase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.69.0",
|
|
4
4
|
"license": "SSPL-1.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"rb": "./bin.js"
|
|
@@ -50,11 +50,6 @@
|
|
|
50
50
|
"debug": "4.3.6",
|
|
51
51
|
"dotenv": "16.4.5",
|
|
52
52
|
"eslint": "8.57.0",
|
|
53
|
-
"eslint-plugin-flowtype": "8.0.3",
|
|
54
|
-
"eslint-plugin-import": "2.29.1",
|
|
55
|
-
"eslint-plugin-lodash": "8.0.0",
|
|
56
|
-
"eslint-plugin-react": "7.35.0",
|
|
57
|
-
"eslint-plugin-react-hooks": "4.6.2",
|
|
58
53
|
"lint-staged": "15.2.7",
|
|
59
54
|
"octokit": "3.1.2",
|
|
60
55
|
"parse-dotenv": "2.1.0",
|
package/eslint/config.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
const mobile_overrides = require("./src/mobile_overrides")
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
parser: "@babel/eslint-parser",
|
|
7
|
-
parserOptions: {
|
|
8
|
-
requireConfigFile: false,
|
|
9
|
-
},
|
|
10
|
-
// workingDirectories:{mode: "auto"},
|
|
11
|
-
ignorePatterns: [
|
|
12
|
-
"**/*.{css,scss}",
|
|
13
|
-
"*.eslintrc.js",
|
|
14
|
-
"**/node_modules/**",
|
|
15
|
-
"**/.nyc_output/**",
|
|
16
|
-
"**/coverage/**",
|
|
17
|
-
"**/build/**",
|
|
18
|
-
"client/static/**",
|
|
19
|
-
],
|
|
20
|
-
env: {
|
|
21
|
-
browser: true,
|
|
22
|
-
es6: true,
|
|
23
|
-
node: true,
|
|
24
|
-
jest: true,
|
|
25
|
-
},
|
|
26
|
-
settings: {
|
|
27
|
-
react: {
|
|
28
|
-
version: "18"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
plugins: ["react", "react-hooks", "flowtype", "import", "lodash"],
|
|
32
|
-
extends: [
|
|
33
|
-
"eslint:recommended",
|
|
34
|
-
"plugin:react/recommended",
|
|
35
|
-
"plugin:react/jsx-runtime",
|
|
36
|
-
"plugin:flowtype/recommended",
|
|
37
|
-
],
|
|
38
|
-
globals: {
|
|
39
|
-
cx: "readonly",
|
|
40
|
-
monaco: "readonly",
|
|
41
|
-
// tests
|
|
42
|
-
page: "readonly",
|
|
43
|
-
browser: "readonly",
|
|
44
|
-
context: "readonly",
|
|
45
|
-
__DEV__: "readonly",
|
|
46
|
-
__DETOX__: "readonly",
|
|
47
|
-
},
|
|
48
|
-
rules: {
|
|
49
|
-
// "@rpcbase/lint/no-unused-imports": "warn",
|
|
50
|
-
"@rpcbase/lint/no-rb-restricted-imports": ["error", [
|
|
51
|
-
{"name": "mongodb", "message": "do not import the 'mongodb' module, this can cause issues, use mongoose.mongo"},
|
|
52
|
-
{"name": "mongoose", "message": "use @rpcbase/server/mongoose"},
|
|
53
|
-
]],
|
|
54
|
-
"array-callback-return": "error",
|
|
55
|
-
"comma-dangle": ["error", "always-multiline"],
|
|
56
|
-
"import/newline-after-import": ["error", {"count": 2}],
|
|
57
|
-
"import/extensions": ["error", "never", {"svg": "always", "scss": "always", "css": "always", "json": "always"}],
|
|
58
|
-
"import/no-relative-parent-imports": ["warn"],
|
|
59
|
-
"lodash/import-scope": ["error", "method"],
|
|
60
|
-
"max-len": "off",
|
|
61
|
-
"no-async-promise-executor": "warn",
|
|
62
|
-
"no-case-declarations": "warn",
|
|
63
|
-
"no-console": ["warn", {allow: ["warn", "error"]}],
|
|
64
|
-
"no-constant-condition": ["warn", {"checkLoops": false}],
|
|
65
|
-
"no-empty": ["error", { "allowEmptyCatch": true }],
|
|
66
|
-
"no-irregular-whitespace": ["error", {skipRegExps: false, skipStrings: false, skipComments: false}],
|
|
67
|
-
"no-misleading-character-class": ["error"],
|
|
68
|
-
"no-return-await": "error",
|
|
69
|
-
"no-shadow": ["error", {"allow": ["err", "error"]}],
|
|
70
|
-
"no-redeclare": ["error", {"builtinGlobals": true}],
|
|
71
|
-
"no-undefined": "warn",
|
|
72
|
-
"no-useless-escape": "warn",
|
|
73
|
-
"no-use-before-define": ["error", {variables: true, functions: true, classes: true}],
|
|
74
|
-
"no-var": "error",
|
|
75
|
-
"flowtype/boolean-style": ["error", "boolean"],
|
|
76
|
-
"prefer-template": ["error"],
|
|
77
|
-
"quotes": ["error", "double", {"allowTemplateLiterals": true}],
|
|
78
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
79
|
-
"react-hooks/rules-of-hooks": "error",
|
|
80
|
-
"react/display-name": "warn",
|
|
81
|
-
"react/no-access-state-in-setstate": "error",
|
|
82
|
-
"react/no-find-dom-node": "warn",
|
|
83
|
-
"react/no-unescaped-entities": "warn",
|
|
84
|
-
"react/no-unknown-property": "warn",
|
|
85
|
-
"react/react-in-jsx-scope": "off",
|
|
86
|
-
"spaced-comment": ["error", "always"],
|
|
87
|
-
"space-before-function-paren": ["error", "never"],
|
|
88
|
-
},
|
|
89
|
-
overrides: [
|
|
90
|
-
mobile_overrides,
|
|
91
|
-
]
|
|
92
|
-
}
|
package/eslint/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
create(context) {
|
|
5
|
-
const restrictedImports = context.options[0] || []
|
|
6
|
-
|
|
7
|
-
function checkNode(node, moduleName) {
|
|
8
|
-
const restrictedImport = restrictedImports.find(r => r.name === moduleName)
|
|
9
|
-
if (restrictedImport) {
|
|
10
|
-
context.report({
|
|
11
|
-
node,
|
|
12
|
-
message: restrictedImport.message,
|
|
13
|
-
data: {
|
|
14
|
-
name: moduleName,
|
|
15
|
-
},
|
|
16
|
-
})
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return {
|
|
21
|
-
"ImportDeclaration"(node) {
|
|
22
|
-
checkNode(node, node.source.value)
|
|
23
|
-
},
|
|
24
|
-
"CallExpression"(node) {
|
|
25
|
-
if (node.callee.name === "require" && node.arguments[0] && node.arguments[0].type === "Literal") {
|
|
26
|
-
checkNode(node, node.arguments[0].value)
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
|
|
3
|
-
const noUnusedImports = {
|
|
4
|
-
meta: {
|
|
5
|
-
fixable: "code",
|
|
6
|
-
},
|
|
7
|
-
create(context) {
|
|
8
|
-
const getRemovalRange = (importSpecifier, sourceCode) => {
|
|
9
|
-
|
|
10
|
-
const tokenBefore = sourceCode.getTokenBefore(importSpecifier)
|
|
11
|
-
const tokenAfter = sourceCode.getTokenAfter(importSpecifier)
|
|
12
|
-
|
|
13
|
-
// if there is a comma before the punctuator, remove the comma as well
|
|
14
|
-
if (tokenBefore.value === "{") {
|
|
15
|
-
const tokenBeforeBefore = sourceCode.getTokenBefore(tokenBefore)
|
|
16
|
-
if (tokenBeforeBefore.value === ",") {
|
|
17
|
-
return [
|
|
18
|
-
sourceCode.getTokenBefore(tokenBeforeBefore).range[1],
|
|
19
|
-
tokenAfter.range[1],
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (tokenBefore.value === ",") {
|
|
25
|
-
return [tokenBefore.range[0], importSpecifier.range[1]]
|
|
26
|
-
} else if (tokenAfter.value === ",") {
|
|
27
|
-
return [importSpecifier.range[0] - 1, tokenAfter.range[1]] // Include the space before the specifier
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// When there is no comma, remove the whole specifier including surrounding spaces
|
|
31
|
-
return [
|
|
32
|
-
sourceCode.getTokenBefore(tokenBefore).range[1],
|
|
33
|
-
sourceCode.getTokenAfter(tokenAfter).range[0],
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
"ImportDeclaration"(node) {
|
|
39
|
-
const sourceCode = context.getSourceCode()
|
|
40
|
-
const importSpecifiers = node.specifiers
|
|
41
|
-
|
|
42
|
-
importSpecifiers.forEach((importSpecifier) => {
|
|
43
|
-
const localName = importSpecifier.local.name
|
|
44
|
-
|
|
45
|
-
const variable = context.getScope().variables.find((v) => v.name === localName)
|
|
46
|
-
|
|
47
|
-
if (variable && variable.references.length === 0) {
|
|
48
|
-
context.report({
|
|
49
|
-
node: importSpecifier,
|
|
50
|
-
message: `'${localName}' is defined but never used.`,
|
|
51
|
-
fix(fixer) {
|
|
52
|
-
if (importSpecifiers.length === 1) {
|
|
53
|
-
return fixer.remove(node)
|
|
54
|
-
} else {
|
|
55
|
-
const removalRange = getRemovalRange(importSpecifier, sourceCode)
|
|
56
|
-
return fixer.removeRange(removalRange)
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
},
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
module.exports = noUnusedImports
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
const { RuleTester } = require("eslint")
|
|
3
|
-
|
|
4
|
-
const noUnusedImports = require("./index")
|
|
5
|
-
|
|
6
|
-
const ruleTester = new RuleTester({
|
|
7
|
-
parserOptions: {
|
|
8
|
-
ecmaVersion: 2021,
|
|
9
|
-
sourceType: "module",
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
ruleTester.run('no-unused-imports', noUnusedImports, {
|
|
15
|
-
valid: [
|
|
16
|
-
"import used from './module'; used();",
|
|
17
|
-
"import * as used from './module'; used.foo();",
|
|
18
|
-
"import { used } from './module'; used();",
|
|
19
|
-
"import { used as alias } from './module'; alias();",
|
|
20
|
-
],
|
|
21
|
-
|
|
22
|
-
invalid: [
|
|
23
|
-
{
|
|
24
|
-
code: "import unused from './module';",
|
|
25
|
-
errors: [{ message: "'unused' is defined but never used." }],
|
|
26
|
-
output: '',
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
code: "import * as unused from './module';",
|
|
30
|
-
errors: [{ message: "'unused' is defined but never used." }],
|
|
31
|
-
output: '',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
code: "import { unused } from './module';",
|
|
35
|
-
errors: [{ message: "'unused' is defined but never used." }],
|
|
36
|
-
output: '',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
code: "import { unused as alias } from './module';",
|
|
40
|
-
errors: [{ message: "'alias' is defined but never used." }],
|
|
41
|
-
output: '',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
code: "import used, { unused } from './module'; used();",
|
|
45
|
-
errors: [{ message: "'unused' is defined but never used." }],
|
|
46
|
-
output: "import used from './module'; used();",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
code: "import { used, unused } from './module'; used();",
|
|
50
|
-
errors: [{ message: "'unused' is defined but never used." }],
|
|
51
|
-
output: "import { used } from './module'; used();",
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
});
|