@plugjs/eslint-plugin 0.2.1 → 0.2.2
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/bundles/eslint-plugin-import-x.cjs +87 -25
- package/package.json +10 -9
|
@@ -180,7 +180,7 @@ var require_package = __commonJS({
|
|
|
180
180
|
"node_modules/eslint-plugin-import-x/package.json"(exports2, module2) {
|
|
181
181
|
module2.exports = {
|
|
182
182
|
name: "eslint-plugin-import-x",
|
|
183
|
-
version: "0.5.
|
|
183
|
+
version: "0.5.3",
|
|
184
184
|
description: "Import with sanity.",
|
|
185
185
|
repository: "git+https://github.com/un-ts/eslint-plugin-import-x",
|
|
186
186
|
author: "JounQin <admin@1stg.me> (https://www.1stG.me)",
|
|
@@ -236,6 +236,7 @@ var require_package = __commonJS({
|
|
|
236
236
|
"is-glob": "^4.0.3",
|
|
237
237
|
minimatch: "^9.0.3",
|
|
238
238
|
semver: "^7.6.0",
|
|
239
|
+
"stable-hash": "^0.0.4",
|
|
239
240
|
tslib: "^2.6.2"
|
|
240
241
|
},
|
|
241
242
|
devDependencies: {
|
|
@@ -964,6 +965,7 @@ var require_export_map = __commonJS({
|
|
|
964
965
|
var doctrine_1 = tslib_12.__importDefault(require("doctrine"));
|
|
965
966
|
var eslint_1 = require("eslint");
|
|
966
967
|
var get_tsconfig_1 = require("get-tsconfig");
|
|
968
|
+
var stable_hash_1 = tslib_12.__importDefault(require("stable-hash"));
|
|
967
969
|
var get_value_1 = require_get_value();
|
|
968
970
|
var hash_1 = require_hash();
|
|
969
971
|
var ignore_1 = require_ignore();
|
|
@@ -1621,29 +1623,28 @@ var require_export_map = __commonJS({
|
|
|
1621
1623
|
}
|
|
1622
1624
|
}
|
|
1623
1625
|
exports2.recursivePatternCapture = recursivePatternCapture;
|
|
1624
|
-
var parserOptionsHash = "";
|
|
1625
|
-
var prevParserOptions = "";
|
|
1626
|
-
var settingsHash = "";
|
|
1627
|
-
var prevSettings = "";
|
|
1628
1626
|
function childContext(path, context) {
|
|
1629
|
-
const { settings, parserOptions, parserPath } = context;
|
|
1630
|
-
if (JSON.stringify(settings) !== prevSettings) {
|
|
1631
|
-
settingsHash = (0, hash_1.hashObject)({ settings }).digest("hex");
|
|
1632
|
-
prevSettings = JSON.stringify(settings);
|
|
1633
|
-
}
|
|
1634
|
-
if (JSON.stringify(parserOptions) !== prevParserOptions) {
|
|
1635
|
-
parserOptionsHash = (0, hash_1.hashObject)({ parserOptions }).digest("hex");
|
|
1636
|
-
prevParserOptions = JSON.stringify(parserOptions);
|
|
1637
|
-
}
|
|
1627
|
+
const { settings, parserOptions, parserPath, languageOptions } = context;
|
|
1638
1628
|
return {
|
|
1639
|
-
cacheKey:
|
|
1629
|
+
cacheKey: makeContextCacheKey(context) + String(path),
|
|
1640
1630
|
settings,
|
|
1641
1631
|
parserOptions,
|
|
1642
1632
|
parserPath,
|
|
1633
|
+
languageOptions,
|
|
1643
1634
|
path,
|
|
1644
1635
|
filename: "physicalFilename" in context ? context.physicalFilename : context.filename
|
|
1645
1636
|
};
|
|
1646
1637
|
}
|
|
1638
|
+
function makeContextCacheKey(context) {
|
|
1639
|
+
var _a, _b, _c;
|
|
1640
|
+
const { settings, parserPath, parserOptions, languageOptions } = context;
|
|
1641
|
+
let hash = (0, stable_hash_1.default)(settings) + (0, stable_hash_1.default)((_a = languageOptions === null || languageOptions === void 0 ? void 0 : languageOptions.parserOptions) !== null && _a !== void 0 ? _a : parserOptions);
|
|
1642
|
+
if (languageOptions) {
|
|
1643
|
+
hash += String(languageOptions.ecmaVersion) + String(languageOptions.sourceType);
|
|
1644
|
+
}
|
|
1645
|
+
hash += (0, stable_hash_1.default)((_c = parserPath !== null && parserPath !== void 0 ? parserPath : (_b = languageOptions === null || languageOptions === void 0 ? void 0 : languageOptions.parser) === null || _b === void 0 ? void 0 : _b.meta) !== null && _c !== void 0 ? _c : languageOptions === null || languageOptions === void 0 ? void 0 : languageOptions.parser);
|
|
1646
|
+
return hash;
|
|
1647
|
+
}
|
|
1647
1648
|
function makeSourceCode(text, ast) {
|
|
1648
1649
|
if (eslint_1.SourceCode.length > 1) {
|
|
1649
1650
|
return new eslint_1.SourceCode(text, ast);
|
|
@@ -2295,6 +2296,7 @@ var require_dynamic_import_chunkname = __commonJS({
|
|
|
2295
2296
|
category: "Style guide",
|
|
2296
2297
|
description: "Enforce a leading comment with the webpackChunkName for dynamic imports."
|
|
2297
2298
|
},
|
|
2299
|
+
hasSuggestions: true,
|
|
2298
2300
|
schema: [
|
|
2299
2301
|
{
|
|
2300
2302
|
type: "object",
|
|
@@ -2320,16 +2322,21 @@ var require_dynamic_import_chunkname = __commonJS({
|
|
|
2320
2322
|
blockComment: "dynamic imports require a /* foo */ style comment, not a // foo comment",
|
|
2321
2323
|
paddedSpaces: "dynamic imports require a block comment padded with spaces - /* foo */",
|
|
2322
2324
|
webpackComment: 'dynamic imports require a "webpack" comment with valid syntax',
|
|
2323
|
-
chunknameFormat: "dynamic imports require a leading comment in the form /*{{format}}*/"
|
|
2325
|
+
chunknameFormat: "dynamic imports require a leading comment in the form /* {{format}} */",
|
|
2326
|
+
webpackEagerModeNoChunkName: "dynamic imports using eager mode do not need a webpackChunkName",
|
|
2327
|
+
webpackRemoveEagerMode: "Remove webpackMode",
|
|
2328
|
+
webpackRemoveChunkName: "Remove webpackChunkName"
|
|
2324
2329
|
}
|
|
2325
2330
|
},
|
|
2326
2331
|
defaultOptions: [],
|
|
2327
2332
|
create(context) {
|
|
2328
2333
|
const { importFunctions = [], allowEmpty = false, webpackChunknameFormat = "([0-9a-zA-Z-_/.]|\\[(request|index)\\])+" } = context.options[0] || {};
|
|
2329
2334
|
const paddedCommentRegex = /^ (\S[\S\s]+\S) $/;
|
|
2330
|
-
const commentStyleRegex = /^( ((webpackChunkName: .+)|((webpackPrefetch|webpackPreload): (true|false|-?\d+))|(webpackIgnore: (true|false))|((webpackInclude|webpackExclude):
|
|
2331
|
-
const chunkSubstrFormat = `
|
|
2335
|
+
const commentStyleRegex = /^( (((webpackChunkName|webpackFetchPriority): .+)|((webpackPrefetch|webpackPreload): (true|false|-?\d+))|(webpackIgnore: (true|false))|((webpackInclude|webpackExclude): \/.+\/)|(webpackMode: ["'](lazy|lazy-once|eager|weak)["'])|(webpackExports: (["']\w+["']|\[(["']\w+["'], *)+(["']\w+["']*)]))),?)+ $/;
|
|
2336
|
+
const chunkSubstrFormat = `webpackChunkName: ["']${webpackChunknameFormat}["'],?`;
|
|
2332
2337
|
const chunkSubstrRegex = new RegExp(chunkSubstrFormat);
|
|
2338
|
+
const eagerModeFormat = `webpackMode: ["']eager["'],?`;
|
|
2339
|
+
const eagerModeRegex = new RegExp(eagerModeFormat);
|
|
2333
2340
|
function run(node, arg) {
|
|
2334
2341
|
const { sourceCode } = context;
|
|
2335
2342
|
const leadingComments = sourceCode.getCommentsBefore(arg);
|
|
@@ -2341,6 +2348,7 @@ var require_dynamic_import_chunkname = __commonJS({
|
|
|
2341
2348
|
return;
|
|
2342
2349
|
}
|
|
2343
2350
|
let isChunknamePresent = false;
|
|
2351
|
+
let isEagerModePresent = false;
|
|
2344
2352
|
for (const comment of leadingComments) {
|
|
2345
2353
|
if (comment.type !== "Block") {
|
|
2346
2354
|
context.report({
|
|
@@ -2372,11 +2380,60 @@ var require_dynamic_import_chunkname = __commonJS({
|
|
|
2372
2380
|
});
|
|
2373
2381
|
return;
|
|
2374
2382
|
}
|
|
2383
|
+
if (eagerModeRegex.test(comment.value)) {
|
|
2384
|
+
isEagerModePresent = true;
|
|
2385
|
+
}
|
|
2375
2386
|
if (chunkSubstrRegex.test(comment.value)) {
|
|
2376
2387
|
isChunknamePresent = true;
|
|
2377
2388
|
}
|
|
2378
2389
|
}
|
|
2379
|
-
|
|
2390
|
+
const removeCommentsAndLeadingSpaces = (fixer, comment) => {
|
|
2391
|
+
const leftToken = sourceCode.getTokenBefore(comment);
|
|
2392
|
+
const leftComments = sourceCode.getCommentsBefore(comment);
|
|
2393
|
+
if (leftToken) {
|
|
2394
|
+
if (leftComments.length > 0) {
|
|
2395
|
+
return fixer.removeRange([
|
|
2396
|
+
Math.max(leftToken.range[1], leftComments[leftComments.length - 1].range[1]),
|
|
2397
|
+
comment.range[1]
|
|
2398
|
+
]);
|
|
2399
|
+
}
|
|
2400
|
+
return fixer.removeRange([leftToken.range[1], comment.range[1]]);
|
|
2401
|
+
}
|
|
2402
|
+
return fixer.remove(comment);
|
|
2403
|
+
};
|
|
2404
|
+
if (isChunknamePresent && isEagerModePresent) {
|
|
2405
|
+
context.report({
|
|
2406
|
+
node,
|
|
2407
|
+
messageId: "webpackEagerModeNoChunkName",
|
|
2408
|
+
suggest: [
|
|
2409
|
+
{
|
|
2410
|
+
messageId: "webpackRemoveChunkName",
|
|
2411
|
+
fix(fixer) {
|
|
2412
|
+
for (const comment of leadingComments) {
|
|
2413
|
+
if (chunkSubstrRegex.test(comment.value)) {
|
|
2414
|
+
const replacement = comment.value.replace(chunkSubstrRegex, "").trim().replace(/,$/, "");
|
|
2415
|
+
return replacement === "" ? removeCommentsAndLeadingSpaces(fixer, comment) : fixer.replaceText(comment, `/* ${replacement} */`);
|
|
2416
|
+
}
|
|
2417
|
+
}
|
|
2418
|
+
return null;
|
|
2419
|
+
}
|
|
2420
|
+
},
|
|
2421
|
+
{
|
|
2422
|
+
messageId: "webpackRemoveEagerMode",
|
|
2423
|
+
fix(fixer) {
|
|
2424
|
+
for (const comment of leadingComments) {
|
|
2425
|
+
if (eagerModeRegex.test(comment.value)) {
|
|
2426
|
+
const replacement = comment.value.replace(eagerModeRegex, "").trim().replace(/,$/, "");
|
|
2427
|
+
return replacement === "" ? removeCommentsAndLeadingSpaces(fixer, comment) : fixer.replaceText(comment, `/* ${replacement} */`);
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
return null;
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
]
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
2436
|
+
if (!isChunknamePresent && !allowEmpty && !isEagerModePresent) {
|
|
2380
2437
|
context.report({
|
|
2381
2438
|
node,
|
|
2382
2439
|
messageId: "chunknameFormat",
|
|
@@ -4863,8 +4920,11 @@ var require_no_extraneous_dependencies = __commonJS({
|
|
|
4863
4920
|
}
|
|
4864
4921
|
function getPackageDepFields(packageJsonPath, throwAtRead) {
|
|
4865
4922
|
if (!depFieldCache.has(packageJsonPath)) {
|
|
4866
|
-
const
|
|
4867
|
-
|
|
4923
|
+
const packageJson = readJSON(packageJsonPath, throwAtRead);
|
|
4924
|
+
if (packageJson) {
|
|
4925
|
+
const depFields = extractDepFields(packageJson);
|
|
4926
|
+
depFieldCache.set(packageJsonPath, depFields);
|
|
4927
|
+
}
|
|
4868
4928
|
}
|
|
4869
4929
|
return depFieldCache.get(packageJsonPath);
|
|
4870
4930
|
}
|
|
@@ -4884,10 +4944,12 @@ var require_no_extraneous_dependencies = __commonJS({
|
|
|
4884
4944
|
if (paths.length > 0) {
|
|
4885
4945
|
for (const dir of paths) {
|
|
4886
4946
|
const packageJsonPath = node_path_1.default.resolve(dir, "package.json");
|
|
4887
|
-
const packageContent_ = getPackageDepFields(packageJsonPath,
|
|
4888
|
-
|
|
4889
|
-
const
|
|
4890
|
-
|
|
4947
|
+
const packageContent_ = getPackageDepFields(packageJsonPath, paths.length === 1);
|
|
4948
|
+
if (packageContent_) {
|
|
4949
|
+
for (const depsKey of Object.keys(packageContent)) {
|
|
4950
|
+
const key = depsKey;
|
|
4951
|
+
Object.assign(packageContent[key], packageContent_[key]);
|
|
4952
|
+
}
|
|
4891
4953
|
}
|
|
4892
4954
|
}
|
|
4893
4955
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plugjs/eslint-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Shared ESLint configurations and extras",
|
|
5
5
|
"main": "./eslint.config.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"build": "eslint build.mjs eslint.config.mjs configs"
|
|
11
11
|
},
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"eslint": "^9.
|
|
13
|
+
"eslint": "^9.6.0"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"*.md",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"configs/"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@eslint/js": "9.
|
|
23
|
-
"@typescript-eslint/utils": "8.0.0-alpha.
|
|
22
|
+
"@eslint/js": "9.6.0",
|
|
23
|
+
"@typescript-eslint/utils": "8.0.0-alpha.40",
|
|
24
24
|
"debug": "4.3.5",
|
|
25
25
|
"doctrine": "2.1.0",
|
|
26
26
|
"enhanced-resolve": "5.17.0",
|
|
27
|
-
"eslint": "9.
|
|
27
|
+
"eslint": "9.6.0",
|
|
28
28
|
"eslint-module-utils": "2.8.1",
|
|
29
29
|
"eslint-plugin-unicorn": "54.0.0",
|
|
30
30
|
"eslint-visitor-keys": "4.0.0",
|
|
@@ -32,15 +32,16 @@
|
|
|
32
32
|
"estraverse": "5.3.0",
|
|
33
33
|
"fast-glob": "3.3.2",
|
|
34
34
|
"get-tsconfig": "4.7.5",
|
|
35
|
-
"globals": "15.
|
|
35
|
+
"globals": "15.8.0",
|
|
36
36
|
"is-core-module": "2.14.0",
|
|
37
37
|
"is-glob": "4.0.3",
|
|
38
|
-
"minimatch": "9.0.
|
|
38
|
+
"minimatch": "9.0.5",
|
|
39
39
|
"picomatch": "4.0.2",
|
|
40
40
|
"resolve": "1.22.8",
|
|
41
41
|
"semver": "7.6.2",
|
|
42
|
+
"stable-hash": "0.0.4",
|
|
42
43
|
"tslib": "2.6.3",
|
|
43
|
-
"typescript": "5.5.
|
|
44
|
-
"typescript-eslint": "8.0.0-alpha.
|
|
44
|
+
"typescript": "5.5.3",
|
|
45
|
+
"typescript-eslint": "8.0.0-alpha.39"
|
|
45
46
|
}
|
|
46
47
|
}
|