@keeex/eslint-config 1.12.5 → 2.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.
@@ -1,103 +0,0 @@
1
- #!/usr/bin/env node
2
- /* eslint-disable no-console */
3
- const path = require("node:path");
4
- const fs = require("node:fs");
5
- const cp = require("node:child_process");
6
- const {dependencyReportKey} = require("../consts.js");
7
-
8
- /** List of previously used dependencies that could be removed */
9
- const removedDependencies = [
10
- "eslint-plugin-import",
11
- "eslint-import-resolver-typescript",
12
- "eslint-plugin-chai-friendly",
13
- ];
14
-
15
- /**
16
- * Check if a dependency is installed (and is a dev dependency).
17
- *
18
- * @returns
19
- * "ok" if it is installed and a dev dependency, "prod" if installed and prod dependency, "missing"
20
- * if not installed.
21
- */
22
- const haveDependency = (pkgJson, depName) => {
23
- if (pkgJson.devDependencies && depName in pkgJson.devDependencies) return "ok";
24
- if (pkgJson.dependencies && depName in pkgJson.dependencies) return "prod";
25
- return "missing";
26
- };
27
-
28
- /** Return the appropriate action for a required dependency */
29
- const getAction = status => {
30
- switch (status) {
31
- case "ok": return "none";
32
- case "prod": return "install-as-dev";
33
- case "missing": return "install";
34
- default:
35
- throw new Error(`Unknown dependency status: ${status}`);
36
- }
37
- };
38
-
39
- const runOn = (pkgJson, eslintConfigPath) => {
40
- console.log("Reading current configuration");
41
- // eslint-disable-next-line no-process-env
42
- process.env[dependencyReportKey] = "1";
43
- // eslint-disable-next-line global-require, i/no-dynamic-require
44
- const requiredDependencies = require(eslintConfigPath);
45
- requiredDependencies.add("@keeex/eslint-config");
46
- const report = {};
47
- console.log("Checking dependencies status");
48
- for (const dep of requiredDependencies) {
49
- const status = haveDependency(pkgJson, dep);
50
- const action = getAction(status);
51
- report[dep] = {status, action};
52
- console.log(`- ${dep}: ${status} (action: ${action})`);
53
- }
54
- for (const oldDep of removedDependencies) {
55
- const status = haveDependency(pkgJson, oldDep);
56
- if (status === "missing") continue;
57
- report[oldDep] = {status, action: "remove"};
58
- console.log(`- ${oldDep}: ${status} (action: remove)`);
59
- }
60
- const toInstall = [];
61
- const toRemove = [];
62
- for (const [dep, {action}] of Object.entries(report)) {
63
- if (action === "install") toInstall.push(dep);
64
- if (action === "install-as-dev") toInstall.push(dep);
65
- if (action === "remove") toRemove.push(dep);
66
- }
67
- if (toInstall.length === 0 && toRemove.length === 0) return;
68
- if (process.argv.indexOf("auto") === -1) {
69
- console.log("To automatically update dependencies, run this script with \"auto\"");
70
- return;
71
- }
72
- if (toInstall.length > 0) {
73
- console.log(`Installing dependencies: ${toInstall.join(", ")}`);
74
- cp.spawnSync("npm", ["install", "--save-dev", ...toInstall]);
75
- }
76
- if (toRemove.length > 0) {
77
- console.log(`Removing dependencies: ${toRemove.join(", ")}`);
78
- cp.spawnSync("npm", ["uninstall", ...toRemove]);
79
- }
80
- };
81
-
82
- const main = () => {
83
- const rootPath = path.resolve(".");
84
- const pkgJsonPath = path.resolve(rootPath, "package.json");
85
- if (!fs.existsSync(pkgJsonPath)) {
86
- console.log("Please run this tool in the root of your project");
87
- process.exitCode = 1;
88
- return;
89
- }
90
- const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
91
- const eslintConfigPath = path.resolve(rootPath, ".eslintrc.cjs");
92
- const eslintConfigAltPath = path.resolve(rootPath, ".eslintrc.js");
93
- if (fs.existsSync(eslintConfigPath)) {
94
- runOn(pkgJson, eslintConfigPath);
95
- } else if (fs.existsSync(eslintConfigAltPath)) {
96
- runOn(pkgJson, eslintConfigAltPath);
97
- } else {
98
- console.log("No eslint config found");
99
- process.exitCode = 1;
100
- }
101
- };
102
-
103
- main();
@@ -1,7 +0,0 @@
1
- module.exports = {
2
- indentDepth: 2,
3
- jsxIndent: 2,
4
- maxBlockDepth: 5,
5
- maxNestedCallbacks: 5,
6
- maxStatements: 50,
7
- };
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- plugins: (presetSettings, allOptions, dependencies) => {
3
- if (typeof allOptions.typescript !== "string") return undefined;
4
- if (dependencies) dependencies.add("eslint-plugin-deprecation");
5
- return ["deprecation"];
6
- },
7
- rules: {},
8
- };
@@ -1,63 +0,0 @@
1
- const base = {
2
- "i/no-unresolved": "error",
3
- "i/named": "error",
4
- "i/export": "error",
5
- "i/no-duplicates": "warn",
6
- "i/default": "off",
7
- "i/namespace": "off",
8
- "i/no-absolute-path": "error",
9
- "i/no-dynamic-require": "error",
10
- "i/no-webpack-loader-syntax": "error",
11
- "i/no-self-import": "error",
12
- "i/no-relative-packages": "error",
13
- "i/no-named-as-default": "off",
14
- "i/no-named-as-default-member": "off",
15
- "i/no-extraneous-dependencies": "warn",
16
- "i/no-unused-modules": "warn",
17
- "i/no-amd": "error",
18
- "i/no-import-module-exports": "error",
19
- "i/first": "error",
20
- "i/extensions": ["error", "always"],
21
- "i/order": "warn",
22
- "i/newline-after-import": "warn",
23
- "i/no-named-default": "error",
24
- "i/no-anonymous-default-export": [
25
- "warn",
26
- {"allowCallExpression": true},
27
- ],
28
- };
29
-
30
- const DEFAULT_CYCLE_DEPTH = 3;
31
-
32
- module.exports = {
33
- plugins: ["i"],
34
- dependencies: ["eslint-plugin-i"],
35
- rules: presetConfig => {
36
- let importDepth;
37
- if (
38
- presetConfig === true
39
- || presetConfig.detectImportCycle === true
40
- ) {
41
- importDepth = DEFAULT_CYCLE_DEPTH;
42
- } else if (typeof presetConfig.detectImportCycle === "number") {
43
- importDepth = presetConfig.detectImportCycle;
44
- }
45
- const importCycleRule = importDepth === undefined
46
- ? undefined
47
- : (
48
- {
49
- "i/no-cycle": [
50
- "error",
51
- {
52
- ignoreExternal: true,
53
- maxDepth: importDepth,
54
- },
55
- ],
56
- }
57
- );
58
- return {
59
- ...base,
60
- ...importCycleRule,
61
- };
62
- },
63
- };
package/src/config/jsx.js DELETED
@@ -1,128 +0,0 @@
1
- const {jsxIndent} = require("./common.js");
2
-
3
- module.exports = {
4
- dependencies: ["eslint-plugin-react"],
5
- settings: presetConfig => {
6
- const version = typeof presetConfig === "string"
7
- ? presetConfig
8
- : "detect";
9
- return {"react": {version}};
10
- },
11
- extendsBase: ["plugin:react/recommended"],
12
- parserOptions: {"ecmaFeatures": {jsx: true}},
13
- rules: {
14
- "react/button-has-type": ["error"],
15
- "react/default-props-match-prop-types": ["warn"],
16
- "react/destructuring-assignment": ["off"],
17
- "react/display-name": [
18
- "warn",
19
- {"ignoreTranspilerName": true},
20
- ],
21
- "react/function-component-definition": [
22
- "error",
23
- {
24
- "namedComponents": "arrow-function",
25
- "unnamedComponents": "arrow-function",
26
- },
27
- ],
28
- "react/no-access-state-in-setstate": ["error"],
29
- "react/no-adjacent-inline-elements": ["warn"],
30
- "react/no-array-index-key": ["error"],
31
- "react/no-danger": ["warn"],
32
- "react/no-did-mount-set-state": ["error"],
33
- "react/no-did-update-set-state": ["error"],
34
- "react/no-multi-comp": [
35
- "error",
36
- {"ignoreStateless": true},
37
- ],
38
- "react/no-redundant-should-component-update": ["error"],
39
- "react/no-this-in-sfc": ["error"],
40
- "react/no-typos": ["error"],
41
- "react/no-unescaped-entities": [
42
- "error",
43
- {
44
- forbid: [
45
- {
46
- char: ">",
47
- alternatives: [">"],
48
- },
49
- {
50
- char: "}",
51
- alternatives: ["}"],
52
- },
53
- ],
54
- },
55
- ],
56
- "react/no-unsafe": [
57
- "error",
58
- {"checkAliases": true},
59
- ],
60
- "react/no-unused-prop-types": ["warn"],
61
- "react/no-unused-state": ["warn"],
62
- "react/no-will-update-set-state": ["error"],
63
- "react/prefer-es6-class": ["warn"],
64
- "react/require-default-props": ["off"],
65
- "react/self-closing-comp": ["warn"],
66
- "react/sort-comp": [
67
- "warn",
68
- {
69
- "order": [
70
- "static-variables",
71
- "static-methods",
72
- "instance-variables",
73
- "constructor",
74
- "lifecycle",
75
- "rendering",
76
- "everything-else",
77
- "rendering",
78
- ],
79
- "groups": {
80
- "rendering": [
81
- "/^render.+$/",
82
- "render",
83
- ],
84
- },
85
- },
86
- ],
87
- "react/static-property-placement": ["off"],
88
- "react/style-prop-object": ["error"],
89
- "react/void-dom-elements-no-children": ["error"],
90
- "react/jsx-boolean-value": ["error"],
91
- "react/jsx-closing-bracket-location": [
92
- "warn",
93
- "line-aligned",
94
- ],
95
- "react/jsx-closing-tag-location": ["off"],
96
- "react/jsx-curly-newline": ["warn"],
97
- "react/jsx-curly-spacing": ["error"],
98
- "react/jsx-equals-spacing": ["error"],
99
- "react/jsx-first-prop-new-line": ["error"],
100
- "react/jsx-fragments": ["error"],
101
- "react/jsx-handler-names": ["warn"],
102
- "react/jsx-indent": [
103
- "error",
104
- jsxIndent,
105
- ],
106
- "react/jsx-indent-props": [
107
- "error",
108
- jsxIndent,
109
- ],
110
- "react/jsx-max-depth": [
111
- "warn",
112
- {"max": 8},
113
- ],
114
- "react/jsx-max-props-per-line": [
115
- "warn",
116
- {"when": "multiline"},
117
- ],
118
- "react/jsx-no-bind": ["warn"],
119
- "react/jsx-no-script-url": ["error"],
120
- "react/jsx-no-useless-fragment": ["warn"],
121
- "react/jsx-pascal-case": ["error"],
122
- "react/jsx-props-no-multi-spaces": ["error"],
123
- "react/jsx-tag-spacing": [
124
- "warn",
125
- {"beforeClosing": "never"},
126
- ],
127
- },
128
- };
@@ -1,9 +0,0 @@
1
- module.exports = {
2
- dependencies: ["eslint-plugin-promise"],
3
- plugins: ["promise"],
4
- extendsBase: ["plugin:promise/recommended"],
5
- rules: {
6
- "promise/always-return": ["off"],
7
- "promise/no-callback-in-promise": ["off"],
8
- },
9
- };
@@ -1,8 +0,0 @@
1
- module.exports = {
2
- dependencies: ["eslint-plugin-react-hooks"],
3
- plugins: ["react-hooks"],
4
- rules: {
5
- "react-hooks/rules-of-hooks": "error",
6
- "react-hooks/exhaustive-deps": "warn",
7
- },
8
- };
@@ -1,19 +0,0 @@
1
- module.exports = {
2
- dependencies: ["eslint-plugin-react-native"],
3
- plugins: [
4
- "react",
5
- "react-native",
6
- ],
7
- env: {"react-native/react-native": true},
8
- rules: {
9
- "react-native/no-unused-styles": ["warn"],
10
- "react-native/split-platform-components": ["warn"],
11
- "react-native/no-inline-styles": ["warn"],
12
- "react-native/no-color-literals": ["warn"],
13
- "react-native/no-raw-text": [
14
- "error",
15
- {"skip": ["Localize"]},
16
- ],
17
- "react-native/no-single-element-style-arrays": ["warn"],
18
- },
19
- };
@@ -1,27 +0,0 @@
1
- // This file is merged into typescript.js on use
2
- module.exports = {
3
- extendsBase:
4
- ["plugin:@typescript-eslint/recommended-requiring-type-checking"],
5
- rules: {
6
- "@typescript-eslint/naming-convention": ["warn"],
7
- "@typescript-eslint/no-floating-promises": ["error"],
8
- "no-implied-eval": "off",
9
- "@typescript-eslint/no-implied-eval": ["error"],
10
- "no-throw-literal": "off",
11
- "@typescript-eslint/no-throw-literal": ["error"],
12
- "@typescript-eslint/no-unnecessary-condition": ["error"],
13
- "@typescript-eslint/no-unnecessary-qualifier": ["error"],
14
- "@typescript-eslint/no-unnecessary-type-arguments": ["warn"],
15
- "@typescript-eslint/prefer-nullish-coalescing": ["warn"],
16
- "@typescript-eslint/restrict-plus-operands": ["error"],
17
- "@typescript-eslint/switch-exhaustiveness-check": ["warn"],
18
- "require-await": "off",
19
- "@typescript-eslint/require-await": ["warn"],
20
- "no-use-before-define": "off",
21
- "@typescript-eslint/no-use-before-define": ["error"],
22
- "@typescript-eslint/unbound-method": [
23
- "error",
24
- {ignoreStatic: true},
25
- ],
26
- },
27
- };
package/src/consts.js DELETED
@@ -1 +0,0 @@
1
- module.exports = {dependencyReportKey: "ESLINT_CONFIG_DEPENDENCIES_REPORT"};