@ota-meshi/eslint-plugin 0.15.3 → 0.17.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/lib/config-builder/+astro-with-ts.d.ts +2 -0
- package/lib/config-builder/+astro-with-ts.js +38 -0
- package/lib/config-builder/+astro.d.ts +2 -0
- package/lib/config-builder/+astro.js +30 -0
- package/lib/config-builder/+eslint-plugin.d.ts +2 -0
- package/lib/config-builder/+eslint-plugin.js +26 -0
- package/lib/config-builder/+json.d.ts +2 -0
- package/lib/config-builder/+json.js +32 -0
- package/lib/config-builder/+md.d.ts +2 -0
- package/lib/config-builder/+md.js +44 -0
- package/lib/config-builder/+node.d.ts +2 -0
- package/lib/config-builder/+node.js +29 -0
- package/lib/config-builder/+package-json.d.ts +2 -0
- package/lib/config-builder/+package-json.js +29 -0
- package/lib/config-builder/+prettier.d.ts +2 -0
- package/lib/config-builder/+prettier.js +28 -0
- package/lib/config-builder/+svelte-with-ts.d.ts +2 -0
- package/lib/config-builder/+svelte-with-ts.js +42 -0
- package/lib/config-builder/+svelte.d.ts +2 -0
- package/lib/config-builder/+svelte.js +30 -0
- package/lib/config-builder/+toml.d.ts +2 -0
- package/lib/config-builder/+toml.js +32 -0
- package/lib/config-builder/+typescript.d.ts +2 -0
- package/lib/config-builder/+typescript.js +17 -0
- package/lib/config-builder/+vue2-with-ts.d.ts +2 -0
- package/lib/config-builder/+vue2-with-ts.js +38 -0
- package/lib/config-builder/+vue2.d.ts +2 -0
- package/lib/config-builder/+vue2.js +30 -0
- package/lib/config-builder/+vue3-with-ts.d.ts +2 -0
- package/lib/config-builder/+vue3-with-ts.js +38 -0
- package/lib/config-builder/+vue3.d.ts +2 -0
- package/lib/config-builder/+vue3.js +30 -0
- package/lib/config-builder/+yaml.d.ts +2 -0
- package/lib/config-builder/+yaml.js +32 -0
- package/lib/config-builder/base-plugins/eslint-comments.d.ts +2 -0
- package/lib/config-builder/base-plugins/eslint-comments.js +20 -0
- package/lib/config-builder/base-plugins/jsdoc.d.ts +2 -0
- package/lib/config-builder/base-plugins/jsdoc.js +20 -0
- package/lib/config-builder/base-plugins/regexp.d.ts +2 -0
- package/lib/config-builder/base-plugins/regexp.js +20 -0
- package/lib/config-builder/fallback.d.ts +5 -0
- package/lib/config-builder/fallback.js +22 -0
- package/lib/config-builder/index.d.ts +20 -0
- package/lib/config-builder/index.js +50 -0
- package/lib/config-builder/plugins/json-schema.d.ts +2 -0
- package/lib/config-builder/plugins/json-schema.js +30 -0
- package/lib/config-builder/plugins/ts/base-config.d.ts +2 -0
- package/lib/config-builder/plugins/ts/base-config.js +48 -0
- package/lib/config-builder/plugins/ts/index.d.ts +1 -0
- package/lib/config-builder/plugins/ts/index.js +5 -0
- package/lib/config-builder/recommended.d.ts +5 -0
- package/lib/config-builder/recommended.js +40 -0
- package/lib/config-helpers/+astro.d.ts +3 -0
- package/lib/config-helpers/+astro.js +5 -0
- package/lib/config-helpers/+eslint-plugin.d.ts +3 -0
- package/lib/config-helpers/+eslint-plugin.js +102 -0
- package/lib/config-helpers/+json.d.ts +3 -0
- package/lib/config-helpers/+json.js +10 -0
- package/lib/config-helpers/+md.d.ts +5 -0
- package/lib/config-helpers/+md.js +44 -0
- package/lib/config-helpers/+node.d.ts +11 -0
- package/lib/config-helpers/+node.js +25 -0
- package/lib/config-helpers/+package-json.d.ts +1 -0
- package/lib/config-helpers/+package-json.js +4 -0
- package/lib/config-helpers/+prettier.d.ts +3 -0
- package/lib/config-helpers/+prettier.js +44 -0
- package/lib/config-helpers/+svelte.d.ts +3 -0
- package/lib/config-helpers/+svelte.js +16 -0
- package/lib/config-helpers/+toml.d.ts +3 -0
- package/lib/config-helpers/+toml.js +5 -0
- package/lib/config-helpers/+typescript.d.ts +4 -0
- package/lib/config-helpers/+typescript.js +18 -0
- package/lib/config-helpers/+vue.d.ts +3 -0
- package/lib/config-helpers/+vue.js +5 -0
- package/lib/config-helpers/+yaml.d.ts +3 -0
- package/lib/config-helpers/+yaml.js +7 -0
- package/lib/config-helpers/base-plugins/eslint-comments.d.ts +2 -0
- package/lib/config-helpers/base-plugins/eslint-comments.js +7 -0
- package/lib/config-helpers/base-plugins/jsdoc.d.ts +2 -0
- package/lib/config-helpers/base-plugins/jsdoc.js +6 -0
- package/lib/config-helpers/base-plugins/regexp.d.ts +2 -0
- package/lib/config-helpers/base-plugins/regexp.js +10 -0
- package/lib/config-helpers/plugins/json-schema.d.ts +2 -0
- package/lib/config-helpers/plugins/json-schema.js +31 -0
- package/lib/config-helpers/plugins/ts/base-config.d.ts +2 -0
- package/lib/config-helpers/plugins/ts/base-config.js +116 -0
- package/lib/config-helpers/plugins/ts/index.d.ts +7 -0
- package/lib/config-helpers/plugins/ts/index.js +21 -0
- package/lib/config-helpers/recommended.d.ts +5 -0
- package/lib/config-helpers/recommended.js +240 -0
- package/lib/configs/+eslint-plugin.d.ts +3 -0
- package/lib/configs/+eslint-plugin.js +22 -95
- package/lib/configs/+json.d.ts +3 -0
- package/lib/configs/+json.js +22 -22
- package/lib/configs/+md.d.ts +3 -0
- package/lib/configs/+md.js +30 -29
- package/lib/configs/+node.d.ts +3 -0
- package/lib/configs/+node.js +23 -29
- package/lib/configs/+package-json.d.ts +3 -0
- package/lib/configs/+package-json.js +20 -20
- package/lib/configs/+prettier.d.ts +3 -0
- package/lib/configs/+prettier.js +23 -70
- package/lib/configs/+svelte-with-ts.d.ts +3 -0
- package/lib/configs/+svelte-with-ts.js +47 -25
- package/lib/configs/+svelte.d.ts +3 -0
- package/lib/configs/+svelte.js +23 -32
- package/lib/configs/+toml.d.ts +3 -0
- package/lib/configs/+toml.js +20 -18
- package/lib/configs/+typescript.d.ts +3 -0
- package/lib/configs/+typescript.js +53 -32
- package/lib/configs/+vue2-with-ts.d.ts +3 -0
- package/lib/configs/+vue2-with-ts.js +48 -25
- package/lib/configs/+vue2.d.ts +3 -0
- package/lib/configs/+vue2.js +24 -25
- package/lib/configs/+vue3-with-ts.d.ts +3 -0
- package/lib/configs/+vue3-with-ts.js +48 -25
- package/lib/configs/+vue3.d.ts +3 -0
- package/lib/configs/+vue3.js +24 -25
- package/lib/configs/+yaml.d.ts +3 -0
- package/lib/configs/+yaml.js +22 -22
- package/lib/configs/base-plugins/eslint-comments.d.ts +3 -0
- package/lib/configs/base-plugins/eslint-comments.js +7 -9
- package/lib/configs/base-plugins/jsdoc.d.ts +3 -0
- package/lib/configs/base-plugins/jsdoc.js +10 -0
- package/lib/configs/base-plugins/regexp.d.ts +3 -0
- package/lib/configs/base-plugins/regexp.js +6 -11
- package/lib/configs/fallback.d.ts +5 -0
- package/lib/configs/fallback.js +15 -0
- package/lib/configs/json-schema/config.d.ts +3 -0
- package/lib/configs/json-schema/config.js +14 -31
- package/lib/configs/recommended.d.ts +26 -0
- package/lib/configs/recommended.js +26 -255
- package/lib/configs/ts/base-config.d.ts +10 -0
- package/lib/configs/ts/base-config.js +10 -118
- package/lib/configs/ts/index.d.ts +2 -0
- package/lib/configs/ts/index.js +4 -16
- package/lib/index.d.ts +48 -0
- package/lib/index.js +15 -23
- package/lib/parsers/any-parser.d.ts +5 -0
- package/lib/parsers/any-parser.js +29 -0
- package/lib/rules/missing-module-for-config.d.ts +16 -0
- package/lib/rules/missing-module-for-config.js +35 -53
- package/lib/utils/find-root-dir.d.ts +1 -0
- package/lib/utils/find-root-dir.js +21 -18
- package/lib/utils/get-linters.d.ts +1 -0
- package/lib/utils/get-linters.js +27 -27
- package/lib/utils/module.d.ts +19 -0
- package/lib/utils/module.js +81 -59
- package/package.json +23 -14
|
@@ -1,70 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create = exports.meta = void 0;
|
|
4
|
+
const get_linters_js_1 = require("../utils/get-linters.js");
|
|
5
|
+
const module_js_1 = require("../utils/module.js");
|
|
7
6
|
let shouldFix = false;
|
|
8
|
-
const fixedModules = new Set();
|
|
9
7
|
patch();
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
meta: {
|
|
8
|
+
exports.meta = {
|
|
13
9
|
type: "problem",
|
|
14
10
|
docs: {
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
description: "report missing modules",
|
|
12
|
+
url: "https://github.com/ota-meshi/eslint-plugin",
|
|
17
13
|
},
|
|
18
14
|
fixable: "code", // or "code" or "whitespace"
|
|
19
15
|
schema: [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
{
|
|
17
|
+
type: "array",
|
|
18
|
+
items: { type: "string" },
|
|
19
|
+
},
|
|
24
20
|
],
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
};
|
|
22
|
+
function create(context) {
|
|
27
23
|
const modules = context.options[0];
|
|
28
24
|
for (const moduleName of modules) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (cwd) {
|
|
34
|
-
const result = spawnSync("npm", ["install", "-D", moduleName], {
|
|
35
|
-
cwd,
|
|
36
|
-
windowsHide: true,
|
|
37
|
-
maxBuffer: Infinity,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
if (result.error) {
|
|
41
|
-
throw result.error;
|
|
42
|
-
}
|
|
43
|
-
consoleOutput = `\n${result.output}`;
|
|
25
|
+
let consoleOutput = "";
|
|
26
|
+
if (shouldFix) {
|
|
27
|
+
const result = (0, module_js_1.tryInstall)(moduleName, context.filename || context.getFilename());
|
|
28
|
+
consoleOutput = result ? `\n${result}` : "";
|
|
44
29
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
30
|
+
context.report({
|
|
31
|
+
loc: { line: 1, column: 0 },
|
|
32
|
+
message: `Missing module of ${moduleName}. run: \`npm i -D ${moduleName}\`${consoleOutput}`,
|
|
33
|
+
});
|
|
50
34
|
}
|
|
51
35
|
return {};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
}
|
|
37
|
+
exports.create = create;
|
|
55
38
|
/** Patch */
|
|
56
39
|
function patch() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
}
|
|
40
|
+
for (const Linter of (0, get_linters_js_1.getLinters)()) {
|
|
41
|
+
const verify0 = Linter.prototype.verify;
|
|
42
|
+
Object.defineProperty(Linter.prototype, "verify", {
|
|
43
|
+
// eslint-disable-next-line no-loop-func -- ignore
|
|
44
|
+
value(textOrSourceCode, config, options, ...args) {
|
|
45
|
+
shouldFix = Boolean(options && typeof options.fix !== "undefined" && options.fix);
|
|
46
|
+
return verify0.call(this, textOrSourceCode, config, options, ...args);
|
|
47
|
+
},
|
|
48
|
+
configurable: true,
|
|
49
|
+
writable: true,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
70
52
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findRootDir(startPath: string): string | null;
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.findRootDir = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
6
9
|
/** Check has package json */
|
|
7
10
|
function hasPackageJson(dir) {
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
const filePath = path_1.default.join(dir, "package.json");
|
|
12
|
+
return fs_1.default.existsSync(filePath);
|
|
10
13
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
function findRootDir(startPath) {
|
|
15
|
+
const startDir = startPath;
|
|
16
|
+
let dir = startDir;
|
|
17
|
+
while (!hasPackageJson(dir)) {
|
|
18
|
+
const nextDir = path_1.default.dirname(dir);
|
|
19
|
+
if (!nextDir || nextDir === dir) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
dir = nextDir;
|
|
19
23
|
}
|
|
20
|
-
dir
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
+
return dir;
|
|
25
|
+
}
|
|
26
|
+
exports.findRootDir = findRootDir;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getLinters(): any[];
|
package/lib/utils/get-linters.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const needle = `${path.sep}node_modules${path.sep}eslint${path.sep}`;
|
|
5
|
-
|
|
6
|
-
module.exports = () => {
|
|
7
|
-
const eslintPaths = new Set(
|
|
8
|
-
Object.keys(require.cache)
|
|
9
|
-
.filter((id) => id.includes(needle))
|
|
10
|
-
.map((id) => id.slice(0, id.indexOf(needle) + needle.length)),
|
|
11
|
-
);
|
|
12
|
-
const linters = [];
|
|
13
|
-
|
|
14
|
-
for (const eslintPath of eslintPaths) {
|
|
15
|
-
try {
|
|
16
|
-
const linter = require(eslintPath).Linter;
|
|
17
|
-
|
|
18
|
-
if (linter) {
|
|
19
|
-
linters.push(linter);
|
|
20
|
-
}
|
|
21
|
-
} catch (error) {
|
|
22
|
-
if (error.code !== "MODULE_NOT_FOUND") {
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return linters;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
4
|
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getLinters = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const needle = `${path_1.default.sep}node_modules${path_1.default.sep}eslint${path_1.default.sep}`;
|
|
9
|
+
function getLinters() {
|
|
10
|
+
const eslintPaths = new Set(Object.keys(require.cache)
|
|
11
|
+
.filter((id) => id.includes(needle))
|
|
12
|
+
.map((id) => id.slice(0, id.indexOf(needle) + needle.length)));
|
|
13
|
+
const linters = [];
|
|
14
|
+
for (const eslintPath of eslintPaths) {
|
|
15
|
+
try {
|
|
16
|
+
const linter = require(eslintPath).Linter;
|
|
17
|
+
if (linter) {
|
|
18
|
+
linters.push(linter);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
if (error.code !== "MODULE_NOT_FOUND") {
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return linters;
|
|
28
|
+
}
|
|
29
|
+
exports.getLinters = getLinters;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
export declare function requireFromCwd(modulePath: string): any;
|
|
3
|
+
export declare function resolveFromCwd(modulePath: string): string;
|
|
4
|
+
export declare function parseModule(name: string): {
|
|
5
|
+
moduleName: string;
|
|
6
|
+
version: string;
|
|
7
|
+
} | {
|
|
8
|
+
moduleName: string;
|
|
9
|
+
version: null;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Checks if exists module
|
|
13
|
+
*/
|
|
14
|
+
export declare function has(name: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Checks exists module and return config
|
|
17
|
+
*/
|
|
18
|
+
export declare function requireOf<C extends Linter.FlatConfig[] | Linter.Config>(names: string[], getConfig: () => C, fallback: (missingList: string[]) => C): C;
|
|
19
|
+
export declare function tryInstall(moduleName: string, targetFile?: string): string | null;
|
package/lib/utils/module.js
CHANGED
|
@@ -1,76 +1,98 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports = {
|
|
6
|
-
has,
|
|
7
|
-
requireOf,
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
4
|
};
|
|
9
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.tryInstall = exports.requireOf = exports.has = exports.parseModule = exports.resolveFromCwd = exports.requireFromCwd = void 0;
|
|
7
|
+
const semver_1 = __importDefault(require("semver"));
|
|
8
|
+
const find_root_dir_js_1 = require("./find-root-dir.js");
|
|
9
|
+
const module_1 = require("module");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const child_process_1 = require("child_process");
|
|
12
|
+
let requireFunction = null;
|
|
13
|
+
function requireFromCwd(modulePath) {
|
|
14
|
+
if (!requireFunction) {
|
|
15
|
+
requireFunction = (0, module_1.createRequire)(path_1.default.join(process.cwd(), "__placeholder__.js"));
|
|
16
|
+
}
|
|
17
|
+
return requireFunction(modulePath);
|
|
18
|
+
}
|
|
19
|
+
exports.requireFromCwd = requireFromCwd;
|
|
20
|
+
function resolveFromCwd(modulePath) {
|
|
21
|
+
if (!requireFunction) {
|
|
22
|
+
requireFunction = (0, module_1.createRequire)(path_1.default.join(process.cwd(), "__placeholder__.js"));
|
|
23
|
+
}
|
|
24
|
+
return requireFunction.resolve(modulePath);
|
|
25
|
+
}
|
|
26
|
+
exports.resolveFromCwd = resolveFromCwd;
|
|
27
|
+
function parseModule(name) {
|
|
28
|
+
const parts = name.split(/@/u);
|
|
29
|
+
if (parts.length > 1 && parts.slice(0, -1).join("@")) {
|
|
30
|
+
return {
|
|
31
|
+
moduleName: parts.slice(0, -1).join("@"),
|
|
32
|
+
version: parts[parts.length - 1],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return { moduleName: name, version: null };
|
|
36
|
+
}
|
|
37
|
+
exports.parseModule = parseModule;
|
|
10
38
|
/**
|
|
11
39
|
* Checks if exists module
|
|
12
|
-
* @param {string} name
|
|
13
40
|
*/
|
|
14
41
|
function has(name) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const v = parts[parts.length - 1];
|
|
42
|
+
const { moduleName, version } = parseModule(name);
|
|
43
|
+
let modulePath;
|
|
18
44
|
try {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
45
|
+
modulePath = resolveFromCwd(moduleName);
|
|
46
|
+
}
|
|
47
|
+
catch (_e) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (version) {
|
|
51
|
+
const moduleRootPath = (0, find_root_dir_js_1.findRootDir)(modulePath);
|
|
52
|
+
try {
|
|
53
|
+
const pkg = requireFromCwd(`${moduleRootPath}/package.json`);
|
|
54
|
+
return semver_1.default.lte(version, pkg.version);
|
|
55
|
+
}
|
|
56
|
+
catch (_e) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
23
59
|
}
|
|
24
|
-
}
|
|
25
|
-
try {
|
|
26
|
-
require.resolve(name);
|
|
27
60
|
return true;
|
|
28
|
-
} catch (_e) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
61
|
}
|
|
32
|
-
|
|
62
|
+
exports.has = has;
|
|
33
63
|
/**
|
|
34
64
|
* Checks exists module and return config
|
|
35
65
|
*/
|
|
36
66
|
function requireOf(names, getConfig, fallback) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const fb =
|
|
41
|
-
(typeof fallback === "function"
|
|
42
|
-
? {
|
|
43
|
-
fallback,
|
|
44
|
-
}
|
|
45
|
-
: fallback) || {};
|
|
46
|
-
if (fb.fallback) {
|
|
47
|
-
Object.assign(fb, fb.fallback());
|
|
48
|
-
delete fb.fallback;
|
|
67
|
+
const missingList = names.filter((n) => !has(n));
|
|
68
|
+
if (!missingList.length) {
|
|
69
|
+
return getConfig();
|
|
49
70
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
71
|
+
return fallback(missingList);
|
|
72
|
+
}
|
|
73
|
+
exports.requireOf = requireOf;
|
|
74
|
+
const installedModules = new Set();
|
|
75
|
+
function tryInstall(moduleName, targetFile = process.cwd()) {
|
|
76
|
+
if (installedModules.has(moduleName))
|
|
77
|
+
return null;
|
|
78
|
+
const cwd = (0, find_root_dir_js_1.findRootDir)(targetFile);
|
|
79
|
+
if (cwd) {
|
|
80
|
+
installedModules.add(moduleName);
|
|
81
|
+
const parsed = parseModule(moduleName);
|
|
82
|
+
const result = (0, child_process_1.spawnSync)("npm", [
|
|
83
|
+
"install",
|
|
84
|
+
"-D",
|
|
85
|
+
parsed.moduleName + (parsed.version ? `@^${parsed.version}` : ""),
|
|
86
|
+
], {
|
|
87
|
+
cwd,
|
|
88
|
+
windowsHide: true,
|
|
89
|
+
maxBuffer: Infinity,
|
|
90
|
+
});
|
|
91
|
+
if (result.error) {
|
|
92
|
+
throw result.error;
|
|
93
|
+
}
|
|
94
|
+
return `${result.output}`;
|
|
65
95
|
}
|
|
66
|
-
return
|
|
67
|
-
plugins: ["@ota-meshi"],
|
|
68
|
-
rules: {
|
|
69
|
-
"@ota-meshi/missing-module-for-config": ["error", missings],
|
|
70
|
-
},
|
|
71
|
-
...fb,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return getConfig();
|
|
96
|
+
return null;
|
|
76
97
|
}
|
|
98
|
+
exports.tryInstall = tryInstall;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ota-meshi/eslint-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "ESLint configuration plugin for me.",
|
|
5
5
|
"repository": "git+https://github.com/ota-meshi/eslint-plugin.git",
|
|
6
6
|
"homepage": "https://github.com/ota-meshi/eslint-plugin#readme",
|
|
@@ -11,41 +11,49 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"packageManager": "yarn@1.22.22",
|
|
13
13
|
"engines": {
|
|
14
|
-
"node": "^
|
|
14
|
+
"node": "^18.18.0||^20.9.0||>=21.1.0"
|
|
15
15
|
},
|
|
16
16
|
"main": "lib/index.js",
|
|
17
17
|
"files": [
|
|
18
18
|
"lib"
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
21
22
|
"lint": "eslint .",
|
|
22
23
|
"lint:fix": "eslint . --fix",
|
|
24
|
+
"pretest": "yarn build",
|
|
23
25
|
"test": "mocha \"tests/lib/**/*.js\" --reporter dot --timeout 60000"
|
|
24
26
|
},
|
|
25
27
|
"peerDependencies": {
|
|
26
|
-
"eslint": "^
|
|
27
|
-
"eslint
|
|
28
|
-
"eslint-plugin-regexp": "^
|
|
28
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
|
|
29
|
+
"eslint": "^7.0.0 || ^8.0.0 || ^9.0.0",
|
|
30
|
+
"eslint-plugin-regexp": "^2.5.0"
|
|
29
31
|
},
|
|
30
32
|
"dependencies": {
|
|
33
|
+
"@eslint/js": "^9.0.0",
|
|
31
34
|
"semver": "^7.3.4"
|
|
32
35
|
},
|
|
33
36
|
"devDependencies": {
|
|
37
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.3.0",
|
|
38
|
+
"@types/eslint": "^8.56.7",
|
|
39
|
+
"@types/eslint__js": "^8.42.3",
|
|
40
|
+
"@types/node": "^20.12.7",
|
|
34
41
|
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
35
42
|
"@typescript-eslint/parser": "^7.0.0",
|
|
36
43
|
"eslint": "^8.0.0",
|
|
37
44
|
"eslint-config-prettier": "^9.0.0",
|
|
38
|
-
"eslint-plugin-
|
|
39
|
-
"eslint-plugin-eslint-plugin": "^
|
|
45
|
+
"eslint-plugin-astro": "^0.34.0",
|
|
46
|
+
"eslint-plugin-eslint-plugin": "^6.0.0",
|
|
47
|
+
"eslint-plugin-jsdoc": "^48.2.3",
|
|
40
48
|
"eslint-plugin-json-schema-validator": "^5.0.0",
|
|
41
49
|
"eslint-plugin-jsonc": "^2.0.0",
|
|
42
|
-
"eslint-plugin-markdown": "^
|
|
43
|
-
"eslint-plugin-n": "^
|
|
44
|
-
"eslint-plugin-node-dependencies": "^0.
|
|
50
|
+
"eslint-plugin-markdown": "^4.0.0",
|
|
51
|
+
"eslint-plugin-n": "^17.0.0",
|
|
52
|
+
"eslint-plugin-node-dependencies": "^0.12.0",
|
|
45
53
|
"eslint-plugin-prettier": "^5.0.0",
|
|
46
|
-
"eslint-plugin-regexp": "^2.
|
|
47
|
-
"eslint-plugin-svelte": "^2.
|
|
48
|
-
"eslint-plugin-toml": "^0.
|
|
54
|
+
"eslint-plugin-regexp": "^2.5.0",
|
|
55
|
+
"eslint-plugin-svelte": "^2.36.0",
|
|
56
|
+
"eslint-plugin-toml": "^0.11.0",
|
|
49
57
|
"eslint-plugin-vue": "^9.0.0",
|
|
50
58
|
"eslint-plugin-yml": "^1.0.0",
|
|
51
59
|
"mocha": "^10.0.0",
|
|
@@ -53,7 +61,8 @@
|
|
|
53
61
|
"prettier-plugin-pkg": "^0.18.0",
|
|
54
62
|
"prettier-plugin-svelte": "^3.0.0",
|
|
55
63
|
"svelte": "^4.0.0",
|
|
56
|
-
"typescript": "^5.0.0"
|
|
64
|
+
"typescript": "^5.0.0",
|
|
65
|
+
"typescript-eslint": "^7.6.0"
|
|
57
66
|
},
|
|
58
67
|
"publishConfig": {
|
|
59
68
|
"access": "public"
|