@shibanet0/datamitsu-config 0.0.1-alpha-22 → 0.0.1-alpha-23
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/.oxlintrc.json +5 -4
- package/datamitsu.js +106 -45
- package/dist/arrow-return-style-QXEK7JRB.js +8 -0
- package/dist/boundaries-7E4X4KF5.js +19 -0
- package/dist/clsx-M6OKU3PA.js +8 -0
- package/dist/clsx-S7LTRDUJ.js +8 -0
- package/dist/command-3BA63SHO.js +8 -0
- package/dist/command-DSHZBIFC.js +10 -0
- package/dist/compat-6O7XHMYR.js +8 -0
- package/dist/cspell-NJAMCYWA.js +8 -0
- package/dist/cspell-TO7G3MKP.js +10 -0
- package/dist/depend-4TLGRJ4A.js +8 -0
- package/dist/dist-HY4C5Z2A.js +145 -0
- package/dist/escompat-2HZB2VKK.js +8 -0
- package/dist/escompat-4SQ3LROQ.js +11 -0
- package/dist/escompat-LOSSJ2E4.js +11 -0
- package/dist/escompat-TAO52CFN.js +10 -0
- package/dist/eslint/index.js +59 -59
- package/dist/eslint/plugins/clsx.d.ts +2 -0
- package/dist/eslint/plugins/command.d.ts +2 -0
- package/dist/eslint/plugins/cspell.d.ts +2 -0
- package/dist/eslint/plugins/escompat.d.ts +2 -0
- package/dist/eslint/plugins/fsecond.d.ts +2 -0
- package/dist/eslint/plugins/html.d.ts +2 -0
- package/dist/eslint/plugins/i18next.d.ts +2 -0
- package/dist/eslint/plugins/jsonc.d.ts +2 -0
- package/dist/eslint/plugins/oxlint.d.ts +5 -0
- package/dist/eslint/plugins/pnpm.d.ts +2 -0
- package/dist/eslint/plugins/react.d.ts +4 -1
- package/dist/eslint/plugins/stylistic.d.ts +2 -0
- package/dist/eslint/plugins/vitest.d.ts +2 -0
- package/dist/eslint/types.d.ts +35 -0
- package/dist/fsecond-3RU4GC2P.js +8 -0
- package/dist/fsecond-L3WD5A5A.js +13 -0
- package/dist/fsecond-T4KZEO22.js +12 -0
- package/dist/fsecond-U7QFID4J.js +16 -0
- package/dist/html-Q7HLWKMH.js +17 -0
- package/dist/i18next-QAQGS665.js +10 -0
- package/dist/i18next-XPRQSLOK.js +8 -0
- package/dist/jsdoc-T3RUTVU2.js +8 -0
- package/dist/jsonc-4Q5WZVF3.js +12 -0
- package/dist/jsonc-5WI2LEKI.js +11 -0
- package/dist/jsonc-C4HCFU4B.js +10 -0
- package/dist/no-unsanitized-2CVGQCKY.js +8 -0
- package/dist/oxlint-5VSAV63M.js +58 -0
- package/dist/oxlint-ESXR6S2H.js +55 -0
- package/dist/oxlint-SQKVSEWV.js +58 -0
- package/dist/oxlint-UN6IGLH6.js +55 -0
- package/dist/pnpm-KEJEST6B.js +15 -0
- package/dist/pnpm-KXXRNMOS.js +10 -0
- package/dist/react-QYLHZO2Q.js +66 -0
- package/dist/react-ZSFMBR63.js +66 -0
- package/dist/react-you-might-not-need-an-effect-7LQCVBLO.js +8 -0
- package/dist/regexp-D6CKMCXH.js +8 -0
- package/dist/s0/__tests__/helpers/mockCrypto.d.ts +1 -1
- package/dist/s0/index.js +30 -51
- package/dist/s0/utils/encryption.d.ts +8 -6
- package/dist/stylistic-ID5P6T22.js +18 -0
- package/dist/stylistic-XPSWOXE5.js +18 -0
- package/dist/unused-imports-B24FSXNB.js +29 -0
- package/dist/vitest-OL2AMOGF.js +20 -0
- package/oxlint_configuration_schema.json +14 -2
- package/package.json +30 -14
package/.oxlintrc.json
CHANGED
|
@@ -13,23 +13,24 @@
|
|
|
13
13
|
"capitalized-comments": "off",
|
|
14
14
|
"func-style": "off",
|
|
15
15
|
"id-length": "off",
|
|
16
|
+
"init-declarations": "off",
|
|
16
17
|
"max-lines": "off",
|
|
17
18
|
"max-lines-per-function": "off",
|
|
19
|
+
"no-await-in-loop": "off",
|
|
18
20
|
"no-inline-comments": "off",
|
|
19
21
|
"no-magic-numbers": "off",
|
|
20
22
|
"no-ternary": "off",
|
|
21
23
|
"no-warning-comments": "off",
|
|
22
|
-
"init-declarations": "off",
|
|
23
24
|
"prefer-destructuring": "off",
|
|
24
|
-
"no-await-in-loop": "off",
|
|
25
|
-
"require-await":"off",
|
|
26
|
-
"unicorn/no-object-as-default-parameter":"off",
|
|
27
25
|
"prefer-template": "off",
|
|
26
|
+
"require-await": "off",
|
|
28
27
|
"sort-imports": "off",
|
|
28
|
+
"max-statements": "off",
|
|
29
29
|
"triple-slash-reference": "off",
|
|
30
30
|
"unicorn/filename-case": "off",
|
|
31
31
|
"unicorn/no-array-sort": "off",
|
|
32
32
|
"unicorn/no-null": "off",
|
|
33
|
+
"unicorn/no-object-as-default-parameter": "off",
|
|
33
34
|
"unicorn/require-module-specifiers": "off"
|
|
34
35
|
}
|
|
35
36
|
}
|
package/datamitsu.js
CHANGED
|
@@ -1793,72 +1793,88 @@ var version = "0.0.1-alpha-22";
|
|
|
1793
1793
|
var dependencies = {
|
|
1794
1794
|
"@antebudimir/eslint-plugin-vanilla-extract": "1.16.0",
|
|
1795
1795
|
"@commander-js/extra-typings": "14.0.0",
|
|
1796
|
-
"@commitlint/cli": "20.
|
|
1797
|
-
"@commitlint/config-conventional": "20.
|
|
1796
|
+
"@commitlint/cli": "20.3.0",
|
|
1797
|
+
"@commitlint/config-conventional": "20.3.0",
|
|
1798
1798
|
"@commitlint/format": "20.2.0",
|
|
1799
1799
|
"@commitlint/types": "20.2.0",
|
|
1800
1800
|
"@cspell/eslint-plugin": "9.4.0",
|
|
1801
|
-
"@datamitsu/datamitsu": "0.0.1-alpha-
|
|
1801
|
+
"@datamitsu/datamitsu": "0.0.1-alpha-60",
|
|
1802
1802
|
"@eslint/config-helpers": "0.5.0",
|
|
1803
1803
|
"@eslint/js": "9.39.2",
|
|
1804
|
+
"@next/eslint-plugin-next": "16.1.1",
|
|
1804
1805
|
"@prettier/plugin-xml": "3.4.2",
|
|
1805
1806
|
"@stylistic/eslint-plugin": "5.6.1",
|
|
1807
|
+
"@vitejs/plugin-react": "5.1.2",
|
|
1808
|
+
"@vitest/eslint-plugin": "1.6.5",
|
|
1806
1809
|
commander: "14.0.2",
|
|
1807
1810
|
"conventional-changelog-conventionalcommits": "9.1.0",
|
|
1808
1811
|
eslint: "9.39.2",
|
|
1809
1812
|
"eslint-config-prettier": "10.1.8",
|
|
1810
1813
|
"eslint-flat-config-utils": "2.1.4",
|
|
1814
|
+
"eslint-import-resolver-typescript": "4.4.4",
|
|
1811
1815
|
"eslint-plugin-array-func": "5.1.0",
|
|
1812
1816
|
"eslint-plugin-arrow-return-style": "1.3.1",
|
|
1817
|
+
"eslint-plugin-baseline-js": "0.4.2",
|
|
1813
1818
|
"eslint-plugin-boundaries": "5.3.1",
|
|
1819
|
+
"eslint-plugin-clsx": "0.0.12",
|
|
1820
|
+
"eslint-plugin-command": "3.4.0",
|
|
1814
1821
|
"eslint-plugin-compat": "6.0.2",
|
|
1815
1822
|
"eslint-plugin-de-morgan": "2.0.0",
|
|
1823
|
+
"eslint-plugin-decorator-position": "6.0.0",
|
|
1816
1824
|
"eslint-plugin-depend": "1.4.0",
|
|
1825
|
+
"eslint-plugin-es-x": "9.3.0",
|
|
1826
|
+
"eslint-plugin-escompat": "3.11.4",
|
|
1827
|
+
"eslint-plugin-eslint-comments": "3.2.0",
|
|
1828
|
+
"eslint-plugin-filenames": "1.3.2",
|
|
1817
1829
|
"eslint-plugin-fsecond": "1.4.0",
|
|
1818
1830
|
"eslint-plugin-functional": "9.0.2",
|
|
1831
|
+
"eslint-plugin-html": "8.1.3",
|
|
1832
|
+
"eslint-plugin-i18next": "6.1.3",
|
|
1819
1833
|
"eslint-plugin-import": "2.32.0",
|
|
1820
1834
|
"eslint-plugin-jsdoc": "61.5.0",
|
|
1821
1835
|
"eslint-plugin-json": "4.0.1",
|
|
1822
1836
|
"eslint-plugin-json-schema-validator": "5.5.0",
|
|
1837
|
+
"eslint-plugin-jsonc": "2.21.0",
|
|
1823
1838
|
"eslint-plugin-jsx-a11y": "6.10.2",
|
|
1824
1839
|
"eslint-plugin-n": "17.23.1",
|
|
1825
1840
|
"eslint-plugin-no-unsanitized": "4.1.4",
|
|
1826
1841
|
"eslint-plugin-no-use-extend-native": "0.7.2",
|
|
1827
|
-
"eslint-plugin-oxlint": "1.
|
|
1842
|
+
"eslint-plugin-oxlint": "1.36.0",
|
|
1828
1843
|
"eslint-plugin-perfectionist": "4.15.1",
|
|
1829
1844
|
"eslint-plugin-playwright": "2.4.0",
|
|
1845
|
+
"eslint-plugin-pnpm": "1.4.3",
|
|
1830
1846
|
"eslint-plugin-promise": "7.2.1",
|
|
1831
1847
|
"eslint-plugin-react": "7.37.5",
|
|
1832
1848
|
"eslint-plugin-react-hooks": "7.0.1",
|
|
1833
1849
|
"eslint-plugin-react-perf": "3.3.3",
|
|
1834
1850
|
"eslint-plugin-react-prefer-function-component": "5.0.0",
|
|
1835
1851
|
"eslint-plugin-react-refresh": "0.4.26",
|
|
1836
|
-
"eslint-plugin-react-you-might-not-need-an-effect": "0.8.
|
|
1852
|
+
"eslint-plugin-react-you-might-not-need-an-effect": "0.8.3",
|
|
1837
1853
|
"eslint-plugin-regexp": "2.10.0",
|
|
1838
1854
|
"eslint-plugin-security": "3.0.1",
|
|
1839
1855
|
"eslint-plugin-sonarjs": "3.0.5",
|
|
1840
|
-
"eslint-plugin-storybook": "10.1.
|
|
1856
|
+
"eslint-plugin-storybook": "10.1.11",
|
|
1841
1857
|
"eslint-plugin-toml": "0.12.0",
|
|
1842
|
-
"eslint-plugin-turbo": "2.
|
|
1858
|
+
"eslint-plugin-turbo": "2.7.2",
|
|
1843
1859
|
"eslint-plugin-unicorn": "62.0.0",
|
|
1844
1860
|
"eslint-plugin-yml": "1.19.1",
|
|
1845
1861
|
execa: "9.6.1",
|
|
1846
1862
|
"fast-glob": "3.3.3",
|
|
1847
|
-
globals: "
|
|
1848
|
-
knip: "5.
|
|
1849
|
-
oxlint: "1.
|
|
1863
|
+
globals: "17.0.0",
|
|
1864
|
+
knip: "5.79.0",
|
|
1865
|
+
oxlint: "1.36.0",
|
|
1850
1866
|
prettier: "3.7.4",
|
|
1851
|
-
"prettier-plugin-embed": "0.5.
|
|
1867
|
+
"prettier-plugin-embed": "0.5.1",
|
|
1852
1868
|
"prettier-plugin-jsdoc": "1.8.0",
|
|
1853
1869
|
"prettier-plugin-sql": "0.19.2",
|
|
1854
1870
|
publint: "0.3.16",
|
|
1855
1871
|
"sort-package-json": "3.6.0",
|
|
1856
|
-
syncpack: "14.0.0-alpha.
|
|
1872
|
+
syncpack: "14.0.0-alpha.34",
|
|
1857
1873
|
tsup: "8.5.1",
|
|
1858
1874
|
tsx: "4.21.0",
|
|
1859
1875
|
"type-fest": "5.3.1",
|
|
1860
1876
|
typescript: "5.9.3",
|
|
1861
|
-
"typescript-eslint": "8.
|
|
1877
|
+
"typescript-eslint": "8.51.0"
|
|
1862
1878
|
};
|
|
1863
1879
|
|
|
1864
1880
|
// src/oxlint/index.ts
|
|
@@ -2292,6 +2308,7 @@ var init = {
|
|
|
2292
2308
|
"jock.svg",
|
|
2293
2309
|
"johnsoncodehk.vscode-tsconfig-helper",
|
|
2294
2310
|
"kisstkondoros.typelens",
|
|
2311
|
+
"kvoon.vscode-eslint-codemod",
|
|
2295
2312
|
"MermaidChart.vscode-mermaid-chart",
|
|
2296
2313
|
"mikestead.dotenv",
|
|
2297
2314
|
"myriad-dreamin.tinymist",
|
|
@@ -2511,21 +2528,59 @@ var init = {
|
|
|
2511
2528
|
},
|
|
2512
2529
|
"eslint.config.js": {
|
|
2513
2530
|
content: () => {
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2531
|
+
if (env().DATAMITSU_DEV_MODE) {
|
|
2532
|
+
return `import { join } from "node:path";
|
|
2533
|
+
|
|
2534
|
+
import { defineConfig } from "./dist/eslint/index.js";
|
|
2535
|
+
import packageJSON from "./package.json" with { type: "json" };
|
|
2536
|
+
|
|
2537
|
+
const config = await defineConfig(
|
|
2538
|
+
/** @type {import("./dist/type-fest").PackageJson} */ (packageJSON),
|
|
2539
|
+
undefined,
|
|
2540
|
+
{
|
|
2541
|
+
plugins: {
|
|
2542
|
+
oxlint: {
|
|
2543
|
+
configFilePath: join(import.meta.dirname, ".oxlintrc.json"),
|
|
2544
|
+
},
|
|
2545
|
+
react: {
|
|
2546
|
+
version: "19.2.3",
|
|
2547
|
+
},
|
|
2548
|
+
},
|
|
2549
|
+
react: true,
|
|
2550
|
+
},
|
|
2551
|
+
);
|
|
2552
|
+
|
|
2553
|
+
export default [
|
|
2554
|
+
...config,
|
|
2555
|
+
{
|
|
2556
|
+
rules: {
|
|
2557
|
+
"playwright/no-standalone-expect": "off",
|
|
2558
|
+
"unicorn/no-object-as-default-parameter": "off",
|
|
2559
|
+
},
|
|
2560
|
+
},
|
|
2561
|
+
];
|
|
2562
|
+
`;
|
|
2563
|
+
}
|
|
2564
|
+
return `import { join } from "node:path";
|
|
2565
|
+
|
|
2566
|
+
import { defineConfig } from "${facts().env.DATAMITSU_PACKAGE_NAME}/eslint";
|
|
2567
|
+
|
|
2568
|
+
import packageJSON from "./package.json" with { type: "json" };
|
|
2569
|
+
|
|
2570
|
+
const config = await defineConfig(
|
|
2571
|
+
/** @type {import("${facts().env.DATAMITSU_PACKAGE_NAME}/type-fest").PackageJson} */ (packageJSON),
|
|
2572
|
+
undefined,
|
|
2573
|
+
{
|
|
2574
|
+
plugins: {
|
|
2575
|
+
oxlint: {
|
|
2576
|
+
configFilePath: join(import.meta.dirname, ".oxlintrc.json"),
|
|
2577
|
+
},
|
|
2578
|
+
},
|
|
2579
|
+
},
|
|
2580
|
+
);
|
|
2581
|
+
|
|
2582
|
+
export default config;
|
|
2583
|
+
`;
|
|
2529
2584
|
},
|
|
2530
2585
|
otherFileNameList: [
|
|
2531
2586
|
"eslint.config.js",
|
|
@@ -2913,7 +2968,23 @@ var indentSettings = {
|
|
|
2913
2968
|
};
|
|
2914
2969
|
|
|
2915
2970
|
// src/datamitsu-config/tools.ts
|
|
2971
|
+
var eslintGlobs = [
|
|
2972
|
+
"**/*.js",
|
|
2973
|
+
"**/*.mjs",
|
|
2974
|
+
"**/*.cjs",
|
|
2975
|
+
"**/*.ts",
|
|
2976
|
+
"**/*.mts",
|
|
2977
|
+
"**/*.cts",
|
|
2978
|
+
"**/*.tsx",
|
|
2979
|
+
"**/*.html",
|
|
2980
|
+
"**/*.json",
|
|
2981
|
+
"**/*.jsonc",
|
|
2982
|
+
"**/*.json5",
|
|
2983
|
+
"**/*.yaml",
|
|
2984
|
+
"**/*.yml"
|
|
2985
|
+
];
|
|
2916
2986
|
var prettierGlobs = [
|
|
2987
|
+
// ...eslintGlobs,
|
|
2917
2988
|
// "**/*.js",
|
|
2918
2989
|
// "**/*.mjs",
|
|
2919
2990
|
// "**/*.cjs",
|
|
@@ -2926,18 +2997,6 @@ var prettierGlobs = [
|
|
|
2926
2997
|
// "**/*.yaml",
|
|
2927
2998
|
// "**/*.md",
|
|
2928
2999
|
];
|
|
2929
|
-
var eslintGlobs = [
|
|
2930
|
-
"**/*.js",
|
|
2931
|
-
"**/*.mjs",
|
|
2932
|
-
"**/*.cjs",
|
|
2933
|
-
"**/*.ts",
|
|
2934
|
-
"**/*.mts",
|
|
2935
|
-
"**/*.cts",
|
|
2936
|
-
"**/*.tsx",
|
|
2937
|
-
"**/*.json",
|
|
2938
|
-
"**/*.yaml",
|
|
2939
|
-
"**/*.yml"
|
|
2940
|
-
];
|
|
2941
3000
|
var oxlintGlobs = [
|
|
2942
3001
|
"**/*.js",
|
|
2943
3002
|
"**/*.mjs",
|
|
@@ -3005,7 +3064,7 @@ var toolsConfig = {
|
|
|
3005
3064
|
workingDir: "project-root"
|
|
3006
3065
|
}
|
|
3007
3066
|
},
|
|
3008
|
-
projectTypes: ["npm-package"
|
|
3067
|
+
projectTypes: ["npm-package"]
|
|
3009
3068
|
},
|
|
3010
3069
|
// gitleaks: {
|
|
3011
3070
|
// name: "gitleaks",
|
|
@@ -3178,15 +3237,17 @@ var toolsConfig = {
|
|
|
3178
3237
|
args: ["fix", "--config", tools.Path.join(facts().gitRoot, ".syncpackrc.json")],
|
|
3179
3238
|
command: "syncpack",
|
|
3180
3239
|
globs: ["**/package.json"],
|
|
3181
|
-
mode: "
|
|
3182
|
-
priority: toolPriority.syncpack
|
|
3240
|
+
mode: "whole-project",
|
|
3241
|
+
priority: toolPriority.syncpack,
|
|
3242
|
+
rootOnly: true
|
|
3183
3243
|
},
|
|
3184
3244
|
lint: {
|
|
3185
3245
|
args: ["lint", "--config", tools.Path.join(facts().gitRoot, ".syncpackrc.json")],
|
|
3186
3246
|
command: "syncpack",
|
|
3187
3247
|
globs: ["**/package.json"],
|
|
3188
|
-
mode: "
|
|
3189
|
-
priority: toolPriority.syncpack
|
|
3248
|
+
mode: "whole-project",
|
|
3249
|
+
priority: toolPriority.syncpack,
|
|
3250
|
+
rootOnly: true
|
|
3190
3251
|
}
|
|
3191
3252
|
},
|
|
3192
3253
|
projectTypes: ["npm-package", "typescript-project"]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/eslint/plugins/boundaries.ts
|
|
2
|
+
async function boundaries() {
|
|
3
|
+
const plugin = await import("eslint-plugin-boundaries");
|
|
4
|
+
return [
|
|
5
|
+
{
|
|
6
|
+
plugins: { boundaries: plugin.default },
|
|
7
|
+
settings: {
|
|
8
|
+
// "boundaries/elements": [
|
|
9
|
+
// { type: "controllers", pattern: "controllers/*" },
|
|
10
|
+
// { type: "models", pattern: "models/*" },
|
|
11
|
+
// { type: "views", pattern: "views/*" }
|
|
12
|
+
// ]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
boundaries
|
|
19
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// ../../../../Library/pnpm/store/v10/links/eslint-plugin-unused-imports/4.3.0/08492a2d4b0cfc70a8a70ffbbea58f0c487ed96cb96d16ade1af899544cc1304/node_modules/eslint-plugin-unused-imports/dist/index.mjs
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
var commaFilter = { filter: (token) => token.value === "," };
|
|
4
|
+
var includeCommentsFilter = { includeComments: true };
|
|
5
|
+
function isUsedInJSDoc(identifierName, sourceCode) {
|
|
6
|
+
const comments = sourceCode.getAllComments();
|
|
7
|
+
const jsdocPattern = new RegExp(
|
|
8
|
+
// {@link Name} or @see Name
|
|
9
|
+
`(?:@(?:link|linkcode|linkplain|see)\\s+${identifierName}\\b)|(?:\\{@(?:link|linkcode|linkplain)\\s+${identifierName}\\b\\})|(?:[@{](?:type|typedef|param|returns?|template|augments|extends|implements)\\s+[^}]*\\b${identifierName}\\b)`
|
|
10
|
+
);
|
|
11
|
+
return comments.some((comment) => {
|
|
12
|
+
if (comment.type !== "Block") {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return jsdocPattern.test(comment.value);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function makePredicate(isImport, addFixer) {
|
|
19
|
+
return (problem, context) => {
|
|
20
|
+
const sourceCode = context.sourceCode || context.getSourceCode();
|
|
21
|
+
const node = problem.node ?? // typescript-eslint >= 7.8 sets a range instead of a node
|
|
22
|
+
sourceCode.getNodeByRangeIndex(sourceCode.getIndexFromLoc(problem.loc.start));
|
|
23
|
+
const { parent } = node;
|
|
24
|
+
if (parent && /^Import(|Default|Namespace)Specifier$/.test(parent.type) && isImport) {
|
|
25
|
+
const identifierName = node.name;
|
|
26
|
+
if (identifierName && isUsedInJSDoc(identifierName, sourceCode)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return parent ? /^Import(|Default|Namespace)Specifier$/.test(parent.type) == isImport ? Object.assign(problem, addFixer?.(parent, sourceCode)) : false : isImport ? false : problem;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
var unusedVarsPredicate = makePredicate(false);
|
|
34
|
+
var unusedImportsPredicate = makePredicate(true, (parent, sourceCode) => ({
|
|
35
|
+
fix(fixer) {
|
|
36
|
+
const grandParent = parent.parent;
|
|
37
|
+
if (!grandParent) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
if (grandParent.specifiers.length === 1) {
|
|
41
|
+
const nextToken = sourceCode.getTokenAfter(grandParent, includeCommentsFilter);
|
|
42
|
+
const newLinesBetween = nextToken ? nextToken.loc.start.line - grandParent.loc.start.line : 0;
|
|
43
|
+
const endOfReplaceRange = nextToken ? nextToken.range[0] : grandParent.range[1];
|
|
44
|
+
const count = Math.max(0, newLinesBetween - 1);
|
|
45
|
+
return [
|
|
46
|
+
fixer.remove(grandParent),
|
|
47
|
+
fixer.replaceTextRange(
|
|
48
|
+
[grandParent.range[1], endOfReplaceRange],
|
|
49
|
+
"\n".repeat(count)
|
|
50
|
+
)
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
if (parent !== grandParent.specifiers[grandParent.specifiers.length - 1]) {
|
|
54
|
+
const comma = sourceCode.getTokenAfter(parent, commaFilter);
|
|
55
|
+
const prevNode = sourceCode.getTokenBefore(parent);
|
|
56
|
+
return [
|
|
57
|
+
fixer.removeRange([prevNode.range[1], parent.range[0]]),
|
|
58
|
+
fixer.remove(parent),
|
|
59
|
+
fixer.remove(comma)
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
if (grandParent.specifiers.filter((specifier) => specifier.type === "ImportSpecifier").length === 1) {
|
|
63
|
+
const start = sourceCode.getTokenBefore(parent, commaFilter);
|
|
64
|
+
const end = sourceCode.getTokenAfter(parent, {
|
|
65
|
+
filter: (token) => token.value === "}"
|
|
66
|
+
});
|
|
67
|
+
return fixer.removeRange([start.range[0], end.range[1]]);
|
|
68
|
+
}
|
|
69
|
+
return fixer.removeRange([
|
|
70
|
+
sourceCode.getTokenBefore(parent, commaFilter).range[0],
|
|
71
|
+
parent.range[1]
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
function createRuleWithPredicate(name, baseRule, predicate) {
|
|
76
|
+
return {
|
|
77
|
+
...baseRule,
|
|
78
|
+
meta: {
|
|
79
|
+
...baseRule.meta,
|
|
80
|
+
fixable: "code",
|
|
81
|
+
docs: {
|
|
82
|
+
...baseRule.meta?.docs,
|
|
83
|
+
url: `https://github.com/sweepline/eslint-plugin-unused-imports/blob/master/docs/rules/${name}.md`
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
create(context) {
|
|
87
|
+
return baseRule.create(
|
|
88
|
+
Object.create(context, {
|
|
89
|
+
report: {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
value(problem) {
|
|
92
|
+
const result = predicate(problem, context);
|
|
93
|
+
if (result) {
|
|
94
|
+
context.report(result);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
var rule;
|
|
104
|
+
var require2 = createRequire(import.meta.url);
|
|
105
|
+
function getBaseRule() {
|
|
106
|
+
if (!rule) {
|
|
107
|
+
rule = getRuleFromTSLintPlugin() ?? getRuleFromTSLint() ?? getESLintBaseRule();
|
|
108
|
+
}
|
|
109
|
+
return rule;
|
|
110
|
+
}
|
|
111
|
+
function getRuleFromTSLintPlugin() {
|
|
112
|
+
try {
|
|
113
|
+
const tslintPlugin = require2("@typescript-eslint/eslint-plugin");
|
|
114
|
+
return tslintPlugin.rules["no-unused-vars"];
|
|
115
|
+
} catch (_) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function getRuleFromTSLint() {
|
|
120
|
+
try {
|
|
121
|
+
const tslint = require2("typescript-eslint");
|
|
122
|
+
return tslint.plugin.rules["no-unused-vars"];
|
|
123
|
+
} catch (_) {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function getESLintBaseRule() {
|
|
128
|
+
const eslint = require2("eslint");
|
|
129
|
+
return new eslint.Linter({ configType: "eslintrc" }).getRules().get("no-unused-vars");
|
|
130
|
+
}
|
|
131
|
+
var no_unused_vars_default = createRuleWithPredicate("no-unused-vars", getBaseRule(), unusedVarsPredicate);
|
|
132
|
+
var no_unused_imports_default = createRuleWithPredicate("no-unused-imports", getBaseRule(), unusedImportsPredicate);
|
|
133
|
+
var plugin = {
|
|
134
|
+
meta: {
|
|
135
|
+
name: "unused-imports"
|
|
136
|
+
},
|
|
137
|
+
rules: {
|
|
138
|
+
"no-unused-vars": no_unused_vars_default,
|
|
139
|
+
"no-unused-imports": no_unused_imports_default
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
var index_default = plugin;
|
|
143
|
+
export {
|
|
144
|
+
index_default as default
|
|
145
|
+
};
|