@shibanet0/datamitsu-config 0.2.0 → 0.4.1
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/README.md +4 -106
- package/bin/tsc.js +4 -2
- package/bin/tsx.js +2 -1
- package/datamitsu.config.base.js +4733 -1795
- package/datamitsu.config.js +4733 -1795
- package/datamitsu.config.oci-dockerhub.js +4734 -1796
- package/datamitsu.config.oci-ghcr.js +4734 -1796
- package/dist/apps/cspell/ignore.d.ts +1 -0
- package/dist/apps/eslint/globs.d.ts +37 -1
- package/dist/apps/eslint/plugins/eslint-comments.d.ts +13 -0
- package/dist/apps/eslint/plugins/json-schema-validator.d.ts +19 -0
- package/dist/apps/eslint/plugins/jsonc.d.ts +31 -0
- package/dist/apps/eslint/plugins/n.d.ts +24 -0
- package/dist/apps/eslint/plugins/next.d.ts +13 -0
- package/dist/apps/eslint/plugins/oxlint.d.ts +20 -4
- package/dist/apps/eslint/plugins/playwright.d.ts +13 -0
- package/dist/apps/eslint/plugins/pnpm.d.ts +6 -0
- package/dist/apps/eslint/plugins/prettier.d.ts +14 -0
- package/dist/apps/eslint/plugins/svelte.d.ts +2 -0
- package/dist/apps/eslint/plugins/vitest.d.ts +7 -0
- package/dist/apps/eslint/types.d.ts +41 -17
- package/dist/apps/knip/index.d.ts +62 -2
- package/dist/apps/knip/index.js +206 -7
- package/dist/apps/lefthook-proxy/__tests__/env.d.ts +2 -0
- package/dist/apps/lefthook-proxy/__tests__/fixtures/fake-upstream.d.mts +2 -0
- package/dist/apps/lefthook-proxy/env.d.ts +15 -0
- package/dist/apps/lefthook-proxy/exit-codes.d.ts +20 -0
- package/dist/apps/lefthook-proxy/git.d.ts +16 -0
- package/dist/apps/lefthook-proxy/hooks.d.ts +1 -0
- package/dist/apps/lefthook-proxy/index.d.ts +2 -0
- package/dist/apps/lefthook-proxy/isolation-failure-error.d.ts +13 -0
- package/dist/apps/lefthook-proxy/isolation.d.ts +5 -0
- package/dist/apps/lefthook-proxy/messages.d.ts +5 -0
- package/dist/apps/lefthook-proxy/resolve.d.ts +3 -0
- package/dist/apps/lefthook-proxy/signals.d.ts +19 -0
- package/dist/apps/lefthook-sort/index.d.ts +1 -1
- package/dist/apps/markdownlint-cli2/index.d.ts +58 -0
- package/dist/apps/oxfmt/index.d.ts +11 -1
- package/dist/apps/oxlint/index.d.ts +88 -0
- package/dist/apps/oxlint/plugins.generated.d.ts +15 -0
- package/dist/apps/sort-keys/index.d.ts +2 -0
- package/dist/apps/sort-keys/properties.d.ts +19 -0
- package/dist/apps/sort-keys/yaml.d.ts +5 -0
- package/dist/apps/stylelint/index.d.ts +13 -0
- package/dist/apps/stylelint/merge.d.ts +21 -0
- package/dist/apps/test-support/env.d.ts +1 -0
- package/dist/apps/test-support/managed-bun.d.ts +6 -0
- package/dist/datamitsu-config/__tests__/agents-upgrade.test.d.ts +1 -0
- package/dist/datamitsu-config/__tests__/tool-config-paths.test.d.ts +1 -0
- package/dist/datamitsu-config/agents.md.d.ts +6 -6
- package/dist/datamitsu-config/alint-defaults.d.ts +22 -0
- package/dist/datamitsu-config/apps/eslint.deps.d.ts +18 -1
- package/dist/datamitsu-config/apps/lefthook-proxy.d.ts +1 -0
- package/dist/datamitsu-config/apps/sort-keys.d.ts +20 -0
- package/dist/datamitsu-config/apps/stylelint.d.ts +1 -0
- package/dist/datamitsu-config/apps/stylelint.deps.d.ts +16 -0
- package/dist/datamitsu-config/cmd-managed-configs.d.ts +2 -0
- package/dist/datamitsu-config/gitleaks-defaults.d.ts +1 -0
- package/dist/datamitsu-config/globs.d.ts +31 -1
- package/dist/datamitsu-config/inline-config/commitlint.d.ts +1 -1
- package/dist/datamitsu-config/inline-config/cspell.d.ts +1 -1
- package/dist/datamitsu-config/inline-config/eslint.d.ts +1 -1
- package/dist/datamitsu-config/inline-config/knip.d.ts +1 -1
- package/dist/datamitsu-config/inline-config/lefthook-proxy.d.ts +1 -0
- package/dist/datamitsu-config/inline-config/lefthook-sort.d.ts +1 -1
- package/dist/datamitsu-config/inline-config/markdownlint-cli2.d.ts +1 -0
- package/dist/datamitsu-config/inline-config/oxfmt.d.ts +1 -1
- package/dist/datamitsu-config/inline-config/oxlint.d.ts +1 -0
- package/dist/datamitsu-config/inline-config/prettier.d.ts +1 -1
- package/dist/datamitsu-config/inline-config/sort-keys.d.ts +1 -0
- package/dist/datamitsu-config/inline-config/stylelint.d.ts +1 -0
- package/dist/datamitsu-config/ls-lint-defaults.d.ts +20 -0
- package/dist/datamitsu-config/managed-configs/__tests__/alint_yml.test.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/__tests__/droast_toml.test.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/__tests__/editorconfig.test.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/__tests__/github_dependabot_yml.test.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/__tests__/lefthook_yaml.test.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/__tests__/ls_lint_yml.test.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/__tests__/package_json.test.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/__tests__/pnpm_workspace_yaml.test.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/__tests__/typos_toml.test.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/__tests__/yamlfmt_yaml.test.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_alint_yml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_datamitsu_scripts_check_empty_files_sh.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_datamitsu_scripts_format_terraform_spacing_sh.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_dclint_yaml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_dockerignore.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_editorconfig.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_editorconfig_checker_json.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_github_dependabot_yml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_github_zizmor_yml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_gitignore.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_gitleaks_toml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_golangci_yaml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_ls_lint_yml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_markdownlint_cli2_mjs.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_node_version.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_npmrc.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_pinact_yaml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_sqruff.d.ts +14 -0
- package/dist/datamitsu-config/managed-configs/_syncpackrc_json.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_tflint_hcl.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_tombi_toml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_trufflehog_exclude_paths_txt.d.ts +2 -0
- package/dist/datamitsu-config/managed-configs/_typos_toml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_vale_ini.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_vscode_extensions_json.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_vscode_settings_json.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_yamlfmt_yaml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/_yamllint_yaml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/ai-tools.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/commitlint_config_mjs.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/cspell_config_mjs.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/deny_toml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/deprecated_configs.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/droast_toml.d.ts +9 -0
- package/dist/datamitsu-config/managed-configs/eslint_config_mjs.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/hadolint_yaml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/knip_config_js.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/lefthook_yaml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/lychee_toml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/mdsf_json.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/oxfmt_config_ts.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/oxlint_config_mts.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/package_json.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/pnpm_workspace_yaml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/prettier_config_mjs.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/pyproject_toml.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/rustfmt_toml.d.ts +13 -0
- package/dist/datamitsu-config/managed-configs/stylelint_config_mjs.d.ts +1 -0
- package/dist/datamitsu-config/managed-configs/turbo_json.d.ts +1 -0
- package/dist/datamitsu-config/oci.d.ts +3 -3
- package/dist/datamitsu-config/parsers.d.ts +11 -13
- package/dist/datamitsu-config/skills.d.ts +2 -2
- package/dist/globs/globs.d.ts +30 -1
- package/dist/ignore/__tests__/catalog.test.d.ts +1 -0
- package/dist/ignore/__tests__/eslint-traversal.test.d.ts +1 -0
- package/dist/ignore/__tests__/ls-lint.test.d.ts +1 -0
- package/dist/ignore/__tests__/pins.test.d.ts +1 -0
- package/dist/ignore/__tests__/profiles.test.d.ts +1 -0
- package/dist/ignore/catalog.d.ts +1555 -0
- package/dist/ignore/profile.d.ts +24 -0
- package/dist/ignore/profiles/cspell.d.ts +2 -0
- package/dist/ignore/profiles/eslint.d.ts +2 -0
- package/dist/ignore/profiles/gitignore.d.ts +2 -0
- package/dist/ignore/profiles/json-exclude.d.ts +2 -0
- package/dist/ignore/profiles/ls-lint.d.ts +2 -0
- package/dist/ignore/profiles/trufflehog.d.ts +2 -0
- package/dist/ignore/profiles/yaml-exclude.d.ts +2 -0
- package/dist/ignore/profiles/yaml.d.ts +2 -0
- package/dist/ignore/types.d.ts +18 -0
- package/dist/lib/datamitsu.d.ts +1 -1
- package/dist/lint-rules/__tests__/index.test.d.ts +1 -0
- package/dist/lint-rules/index.d.ts +46 -0
- package/dist/lint-rules/oxlint-known-rules.generated.d.ts +1 -0
- package/dist/lint-rules/permanent-disabled.d.ts +19 -0
- package/dist/lint-rules/permanent-enabled.d.ts +49 -0
- package/dist/lint-rules/rule-names.generated.d.ts +5 -0
- package/dist/lint-rules/temporary.d.ts +25 -0
- package/dist/s0/cmd/pulumi/__tests__/cleanup-state.test.d.ts +1 -0
- package/dist/s0/cmd/pulumi/__tests__/decrypt-state.test.d.ts +1 -0
- package/dist/s0/cmd/pulumi/__tests__/encrypt-editor.test.d.ts +1 -0
- package/dist/s0/cmd/pulumi/__tests__/encrypt-state.test.d.ts +1 -0
- package/dist/s0/cmd/pulumi/__tests__/state-content.test.d.ts +1 -0
- package/dist/s0/cmd/pulumi/__tests__/state-files.test.d.ts +1 -0
- package/dist/s0/cmd/pulumi/__tests__/state-guard.test.d.ts +1 -0
- package/dist/s0/cmd/pulumi/constants.d.ts +5 -0
- package/dist/s0/cmd/pulumi/decrypt-state.d.ts +8 -0
- package/dist/s0/cmd/pulumi/encrypt-state.d.ts +14 -0
- package/dist/s0/cmd/pulumi/index.d.ts +3 -1
- package/dist/s0/cmd/pulumi/state-content.d.ts +21 -0
- package/dist/s0/cmd/pulumi/state-files.d.ts +13 -0
- package/dist/s0/cmd/pulumi/state-guard.d.ts +15 -0
- package/dist/s0/index.js +7010 -183
- package/dist/s0/utils/datamitsu.d.ts +1 -1
- package/dist/utils/{typeGuards.d.ts → type-guards.d.ts} +1 -1
- package/package.json +7 -7
- package/dist/apps/eslint/plugins/arrow-return-style.d.ts +0 -2
- package/dist/apps/eslint/plugins/json.d.ts +0 -2
- package/dist/datamitsu-config/cmdSetup.d.ts +0 -3
- package/dist/datamitsu-config/env.d.ts +0 -5
- package/dist/datamitsu-config/gitleaksDefaults.d.ts +0 -4
- package/dist/datamitsu-config/inline-config/oxlint_configuration_schema.d.ts +0 -1
- package/dist/datamitsu-config/setup/_alint_yml.d.ts +0 -1
- package/dist/datamitsu-config/setup/_datamitsu_scripts_check_empty_files_sh.d.ts +0 -1
- package/dist/datamitsu-config/setup/_datamitsu_scripts_format_terraform_spacing_sh.d.ts +0 -1
- package/dist/datamitsu-config/setup/_dclint_yaml.d.ts +0 -1
- package/dist/datamitsu-config/setup/_dockerignore.d.ts +0 -1
- package/dist/datamitsu-config/setup/_editorconfig.d.ts +0 -1
- package/dist/datamitsu-config/setup/_editorconfig_checker_json.d.ts +0 -1
- package/dist/datamitsu-config/setup/_github_dependabot_yml.d.ts +0 -1
- package/dist/datamitsu-config/setup/_github_zizmor_yml.d.ts +0 -1
- package/dist/datamitsu-config/setup/_gitignore.d.ts +0 -1
- package/dist/datamitsu-config/setup/_gitleaks_toml.d.ts +0 -1
- package/dist/datamitsu-config/setup/_golangci_yaml.d.ts +0 -1
- package/dist/datamitsu-config/setup/_ls_lint_yml.d.ts +0 -1
- package/dist/datamitsu-config/setup/_node_version.d.ts +0 -1
- package/dist/datamitsu-config/setup/_npmrc.d.ts +0 -1
- package/dist/datamitsu-config/setup/_oxlintrc_json.d.ts +0 -1
- package/dist/datamitsu-config/setup/_pinact_yaml.d.ts +0 -1
- package/dist/datamitsu-config/setup/_sqruff.d.ts +0 -1
- package/dist/datamitsu-config/setup/_syncpackrc_json.d.ts +0 -1
- package/dist/datamitsu-config/setup/_tflint_hcl.d.ts +0 -1
- package/dist/datamitsu-config/setup/_tombi_toml.d.ts +0 -1
- package/dist/datamitsu-config/setup/_trufflehog_exclude_paths_txt.d.ts +0 -2
- package/dist/datamitsu-config/setup/_vale_ini.d.ts +0 -1
- package/dist/datamitsu-config/setup/_vscode_extensions_json.d.ts +0 -1
- package/dist/datamitsu-config/setup/_vscode_settings_json.d.ts +0 -1
- package/dist/datamitsu-config/setup/_yamlfmt_yaml.d.ts +0 -1
- package/dist/datamitsu-config/setup/_yamllint_yaml.d.ts +0 -1
- package/dist/datamitsu-config/setup/aiTools.d.ts +0 -1
- package/dist/datamitsu-config/setup/commitlint_config_mjs.d.ts +0 -1
- package/dist/datamitsu-config/setup/cspell_config_mjs.d.ts +0 -1
- package/dist/datamitsu-config/setup/deny_toml.d.ts +0 -1
- package/dist/datamitsu-config/setup/deprecated_configs.d.ts +0 -1
- package/dist/datamitsu-config/setup/eslint_config_mjs.d.ts +0 -1
- package/dist/datamitsu-config/setup/hadolint_yaml.d.ts +0 -1
- package/dist/datamitsu-config/setup/knip_config_js.d.ts +0 -1
- package/dist/datamitsu-config/setup/lefthook_yaml.d.ts +0 -1
- package/dist/datamitsu-config/setup/mdsf_json.d.ts +0 -1
- package/dist/datamitsu-config/setup/oxfmt_config_ts.d.ts +0 -1
- package/dist/datamitsu-config/setup/package_json.d.ts +0 -1
- package/dist/datamitsu-config/setup/pnpm_workspace_yaml.d.ts +0 -1
- package/dist/datamitsu-config/setup/prettier_config_mjs.d.ts +0 -1
- package/dist/datamitsu-config/setup/pyproject_toml.d.ts +0 -1
- package/dist/datamitsu-config/setup/rustfmt_toml.d.ts +0 -1
- package/dist/datamitsu-config/setup/turbo_json.d.ts +0 -1
- package/dist/datamitsu-config/setup/ty_toml.d.ts +0 -1
- package/dist/s0/__tests__/helpers/mockCrypto.d.ts +0 -22
- package/dist/s0/__tests__/helpers/mockExeca.d.ts +0 -47
- package/dist/s0/__tests__/helpers/mockFs.d.ts +0 -44
- package/dist/s0/__tests__/helpers/mockGlob.d.ts +0 -21
- package/dist/s0/cmd/pulumi/decryptState.d.ts +0 -1
- package/dist/s0/cmd/pulumi/encryptState.d.ts +0 -1
- /package/dist/apps/eslint/plugins/{arrayFunc.d.ts → array-func.d.ts} +0 -0
- /package/dist/apps/eslint/plugins/{deMorgan.d.ts → de-morgan.d.ts} +0 -0
- /package/dist/{datamitsu-config/__tests__/agentsUpgrade.test.d.ts → apps/knip/__tests__/index.test.d.ts} +0 -0
- /package/dist/{datamitsu-config/setup/__tests__/github_dependabot_yml.test.d.ts → apps/lefthook-proxy/__tests__/proxy.test.d.ts} +0 -0
- /package/dist/{datamitsu-config/setup/__tests__/lefthook_yaml.test.d.ts → apps/lefthook-proxy/__tests__/real-lefthook.test.d.ts} +0 -0
- /package/dist/{datamitsu-config/setup/__tests__/package_json.test.d.ts → apps/lefthook-sort/__tests__/cli.test.d.ts} +0 -0
- /package/dist/{datamitsu-config/setup/__tests__/pnpm_workspace_yaml.test.d.ts → apps/oxfmt/__tests__/index.test.d.ts} +0 -0
- /package/dist/{s0/cmd/pulumi/__tests__/cleanupState.test.d.ts → apps/oxlint/__tests__/index.test.d.ts} +0 -0
- /package/dist/{s0/cmd/pulumi/__tests__/decryptState.test.d.ts → apps/sort-keys/__tests__/sort.test.d.ts} +0 -0
- /package/dist/{s0/cmd/pulumi/__tests__/encryptState.test.d.ts → apps/stylelint/__tests__/merge.test.d.ts} +0 -0
- /package/dist/datamitsu-config/{agentsUpgrade.d.ts → agents-upgrade.d.ts} +0 -0
- /package/dist/datamitsu-config/{setup → managed-configs}/shared.d.ts +0 -0
- /package/dist/datamitsu-config/utils/{cleanDependencies.d.ts → clean-dependencies.d.ts} +0 -0
- /package/dist/datamitsu-config/utils/{detectPackageType.d.ts → detect-package-type.d.ts} +0 -0
- /package/dist/s0/cmd/pulumi/{cleanupState.d.ts → cleanup-state.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ignorePaths: string[];
|
|
@@ -9,8 +9,44 @@ export declare const GLOB_CSS = "**/*.css";
|
|
|
9
9
|
export declare const GLOB_POSTCSS = "**/*.{p,post}css";
|
|
10
10
|
export declare const GLOB_LESS = "**/*.less";
|
|
11
11
|
export declare const GLOB_SCSS = "**/*.scss";
|
|
12
|
+
/**
|
|
13
|
+
* Where test files live, for the plugins whose rules only make sense inside one.
|
|
14
|
+
*
|
|
15
|
+
* Both of the plugins that need this were mis-scoped. The vitest block asked for `tests/**`, which
|
|
16
|
+
* matches nothing in a repository whose tests are in `__tests__/` — so its rules had never run at
|
|
17
|
+
* all. eslint-plugin-playwright's `flat/recommended` carries no `files` of its own, so its 38 rules
|
|
18
|
+
* applied to every file in any project that has playwright installed.
|
|
19
|
+
*
|
|
20
|
+
* One list rather than two per plugin, because "is this a test file" is one question. The e2e set
|
|
21
|
+
* is separate only because playwright's default `testDir` is a directory rather than a filename
|
|
22
|
+
* convention.
|
|
23
|
+
*/
|
|
24
|
+
export declare const GLOB_TESTS: string[];
|
|
25
|
+
/**
|
|
26
|
+
* Where playwright specs live. Directory-shaped, because playwright scopes by `testDir` rather than
|
|
27
|
+
* by filename — which is also why this is a separate list from {@link GLOB_TESTS}.
|
|
28
|
+
*
|
|
29
|
+
* `**\/tests/**` is deliberately not here. It is the conventional home of _unit_ tests in plenty of
|
|
30
|
+
* projects, and matching it applied all 38 playwright rules to them: `no-conditional-in-test`,
|
|
31
|
+
* `no-conditional-expect`, `no-focused-test`, `prefer-to-have-length` on a vitest file, two of them
|
|
32
|
+
* duplicating a sonarjs finding on the same line. A project that keeps e2e specs somewhere else
|
|
33
|
+
* names the directory itself; that is a smaller cost than arming the rules everywhere.
|
|
34
|
+
*/
|
|
35
|
+
export declare const GLOB_E2E: string[];
|
|
36
|
+
export declare const GLOB_HTML = "**/*.html";
|
|
37
|
+
export declare const GLOB_SVELTE = "**/*.svelte";
|
|
38
|
+
/**
|
|
39
|
+
* Svelte 5's rune modules — plain JS/TS that may use `$state` and friends, which
|
|
40
|
+
* `svelte-eslint-parser` has to see to resolve them.
|
|
41
|
+
*
|
|
42
|
+
* Kept separate from {@link GLOB_SVELTE} because these files are also matched by `GLOB_SRC`: the
|
|
43
|
+
* TypeScript block reaches them too, and the svelte parser is attached on top rather than instead.
|
|
44
|
+
*/
|
|
45
|
+
export declare const GLOB_SVELTE_SCRIPT: string[];
|
|
12
46
|
export declare const GLOB_JSON = "**/*.json";
|
|
13
47
|
export declare const GLOB_JSON5 = "**/*.json5";
|
|
14
48
|
export declare const GLOB_JSONC = "**/*.jsonc";
|
|
49
|
+
export declare const GLOB_TOML = "**/*.toml";
|
|
50
|
+
export declare const GLOB_YAML = "**/*.{yaml,yml}";
|
|
15
51
|
export declare const GLOB_ALL_SRC: string[];
|
|
16
|
-
export
|
|
52
|
+
export { GLOB_EXCLUDE } from "../../globs/globs";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TypedFlatConfigItem } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Rules about the suppression comments themselves — the other half of
|
|
4
|
+
* `reportUnusedDisableDirectives`.
|
|
5
|
+
*
|
|
6
|
+
* That option catches a directive that suppresses nothing. These catch the shapes that suppress too
|
|
7
|
+
* much or never end: `no-unlimited-disable` (a bare `/* eslint-disable *\/` that silences every
|
|
8
|
+
* rule for the rest of the file), `disable-enable-pair`, `no-aggregating-enable`,
|
|
9
|
+
* `no-duplicate-disable`, `no-unused-enable`.
|
|
10
|
+
*
|
|
11
|
+
* The plugin was a dependency every consumer downloaded and no config ever loaded.
|
|
12
|
+
*/
|
|
13
|
+
export declare function eslintComments(): Promise<TypedFlatConfigItem[]>;
|
|
@@ -1,2 +1,21 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Validates a file against whatever schema schemastore maps its name to.
|
|
4
|
+
*
|
|
5
|
+
* The preset installs parsers for JSON, YAML and TOML in `files`-scoped blocks, and then puts the
|
|
6
|
+
* rule itself in an unscoped one — so `setDefaultIgnores` took it off every JSON file and left it
|
|
7
|
+
* running on TypeScript, where it has nothing to validate. 852 of the catalogue's 1364 entries
|
|
8
|
+
* match `.json`/`.jsonc`/`.json5`, which means `package.json` with `"version": 123` and
|
|
9
|
+
* `tsconfig.json` with `"strict": "yes"` were never checked.
|
|
10
|
+
*
|
|
11
|
+
* JSON only, though the preset parses YAML and TOML as well. YAML 1.1 reads a bare `on:` as the
|
|
12
|
+
* boolean `true`, so a GitHub workflow arrives at the validator with its trigger key renamed and
|
|
13
|
+
* the schema rejects the whole document — 22 findings on one release workflow here, every one an
|
|
14
|
+
* artefact of the parse rather than a fact about the file. The rule is right about JSON, where 852
|
|
15
|
+
* of the catalogue's 1364 entries apply, and wrong about YAML for a reason nothing in this config
|
|
16
|
+
* can fix.
|
|
17
|
+
*
|
|
18
|
+
* This also forecloses the plugin's other mode — validating a JS module's default export against a
|
|
19
|
+
* schema — which nothing here uses.
|
|
20
|
+
*/
|
|
2
21
|
export declare function jsonSchemaValidator(): Promise<TypedFlatConfigItem[]>;
|
|
@@ -1,2 +1,33 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* The JSON linter, scoped so its rules reach the files they exist for.
|
|
4
|
+
*
|
|
5
|
+
* Both upstream presets are three blocks: a plugin registration, a `files`-scoped block that
|
|
6
|
+
* installs the `jsonc/x` language, and a third that carries all the actual rules with **no `files`
|
|
7
|
+
* at all**. That third shape is exactly what `composer.setDefaultIgnores` targets, so it was being
|
|
8
|
+
* stamped with `ignores: ["**\/*.json", "**\/*.json5", "**\/*.jsonc", …]` — the four globs it
|
|
9
|
+
* exists for. The language block scoped itself and survived; the rule block did not, and 28 rules
|
|
10
|
+
* were off on JSON and on everywhere else.
|
|
11
|
+
*
|
|
12
|
+
* Measured before the fix: `{"a": 1, "a": +3}` in a `.json` file reported nothing, while the preset
|
|
13
|
+
* alone reports `no-dupe-keys`, `no-plus-sign` and `valid-json-number`. Inverted, those same rules
|
|
14
|
+
* resolved _on_ for `.ts` files, where they can never match.
|
|
15
|
+
*
|
|
16
|
+
* Scoping every rule-bearing block here rather than opting out of the default ignores: the rules
|
|
17
|
+
* are for these three extensions and nothing else, so saying so is both the fix and the
|
|
18
|
+
* documentation.
|
|
19
|
+
*
|
|
20
|
+
* **Each dialect gets its own preset, and only its own extension.** Scoping all of them to all
|
|
21
|
+
* three extensions was the same bug one level up: JSON5's preset deliberately leaves
|
|
22
|
+
* `jsonc/quote-props`, `jsonc/quotes` and `jsonc/no-hexadecimal-numeric-literals` unset, because
|
|
23
|
+
* JSON5 is the dialect where an unquoted key, a single-quoted string and `0xff` are legal — and
|
|
24
|
+
* JSONC's preset, applied to the same files, set all three at error. `{ a: "hello" }` in a `.json5`
|
|
25
|
+
* therefore failed `jsonc/quote-props` while both formatters wrote exactly that (measured: oxfmt
|
|
26
|
+
* rewrites `{ "a": "hello" }` back to `{ a: "hello" }`), so ESLint and the formatter each undid the
|
|
27
|
+
* other and `dm check` could not pass. A single `0xff` reported twice, under
|
|
28
|
+
* `no-hexadecimal-numeric-literals` and `valid-json-number`, for the same reason.
|
|
29
|
+
*
|
|
30
|
+
* `recommended-with-json` is now included as well, scoped to `.json`, where comments really are an
|
|
31
|
+
* error — the previous arrangement linted plain JSON with the dialect that permits them.
|
|
32
|
+
*/
|
|
2
33
|
export declare function jsonc(): Promise<TypedFlatConfigItem[]>;
|
|
@@ -1,2 +1,26 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Eslint-plugin-n, split along the line the upstream presets confuse: which files are modules, and
|
|
4
|
+
* which rules run.
|
|
5
|
+
*
|
|
6
|
+
* `configs["flat/recommended"]` picks between `recommended-module` and `recommended-script` by
|
|
7
|
+
* reading the nearest `package.json` at plugin-import time, and returns a single **unscoped** block
|
|
8
|
+
* carrying both the 14 rules and a `languageOptions.sourceType`. That last part is the bug: an
|
|
9
|
+
* unscoped `sourceType` applies to every file in the project, decided by one field in one
|
|
10
|
+
* manifest.
|
|
11
|
+
*
|
|
12
|
+
* In a project without `"type": "module"` it resolves to `commonjs`, and every `.js`, `.jsx` and
|
|
13
|
+
* `.mjs` file fails with `Parsing error: 'import' and 'export' may appear only with 'sourceType:
|
|
14
|
+
* module'` — including the `eslint.config.mjs` this package generates. `.ts` and `.tsx` are
|
|
15
|
+
* unaffected, which is what makes it read as random. And datamitsu deliberately omits `type` for
|
|
16
|
+
* next, expo, gatsby, electron, react-native and docusaurus, so the config manufactures the failing
|
|
17
|
+
* shape itself. The mirror case is live here: with `"type": "module"` the unscoped `sourceType` is
|
|
18
|
+
* `module`, which is wrong for any `.cjs` file in the repository.
|
|
19
|
+
*
|
|
20
|
+
* `flat/mixed-esm-and-cjs` already answers the question per extension — `.js`/`.mjs` module, `.cjs`
|
|
21
|
+
* commonjs — so its blocks provide the language settings. It also scopes its _rules_ to those three
|
|
22
|
+
* extensions, which would quietly stop all 14 from running on `.ts`, so the rules are re-emitted
|
|
23
|
+
* once, unscoped, exactly as before. Nothing changes about which rules run anywhere; only which
|
|
24
|
+
* files are parsed as what.
|
|
25
|
+
*/
|
|
2
26
|
export declare function n(): Promise<TypedFlatConfigItem[]>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TypedFlatConfigItem } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Next.js rules — 22 of them, and a dependency every consumer downloaded while no config loaded it.
|
|
4
|
+
*
|
|
5
|
+
* `core-web-vitals` rather than `recommended`: it is the same set with three rules raised from warn
|
|
6
|
+
* to error (`no-sync-scripts`, `no-html-link-for-pages`, `no-img-element`), which is the severity
|
|
7
|
+
* this config uses anyway — `raiseWarningsToErrors` would raise them a moment later.
|
|
8
|
+
*
|
|
9
|
+
* Gated on the `next` dependency. The oxlint half has its `nextjs` plugin on unconditionally, since
|
|
10
|
+
* a static JSON config cannot look at package.json; closing that gap is what moving oxlint to a
|
|
11
|
+
* config module was for.
|
|
12
|
+
*/
|
|
13
|
+
export declare function next(): Promise<TypedFlatConfigItem[]>;
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
+
import type { OxlintDefineConfigOptions, OxlintPackageJson } from "../../oxlint";
|
|
1
2
|
import type { TypedFlatConfigItem } from "../types";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Built from the shared config object, never from a file on disk.
|
|
5
|
+
*
|
|
6
|
+
* There used to be a `configFilePath` option, and every generated `eslint.config.mjs` passed it,
|
|
7
|
+
* pointing at the project's own `.oxlintrc.json`. That file only ever said `extends`, and
|
|
8
|
+
* `buildFromOxlintConfigFile` does not follow `extends` — so it read an empty rule set and
|
|
9
|
+
* suppressed 76 ESLint rules where the config object suppresses 304. The other 228 were rules both
|
|
10
|
+
* tools reported, on the same line, under two names.
|
|
11
|
+
*
|
|
12
|
+
* The option is also unimplementable now: the oxlint config is a TypeScript module, and
|
|
13
|
+
* `buildFromOxlintConfigFile` reads JSON.
|
|
14
|
+
*
|
|
15
|
+
* Built for the _project_, not from the package's own defaults. A suppression here is a claim that
|
|
16
|
+
* oxlint reports the rule instead — so it has to be made against the plugin set the project's
|
|
17
|
+
* oxlint run actually enables. Without the manifest, a package with no Next.js would have its
|
|
18
|
+
* `@next/next/*` rules turned off in ESLint on the strength of a `nextjs` plugin that no longer
|
|
19
|
+
* runs there, and nothing would report them.
|
|
20
|
+
*/
|
|
21
|
+
export declare function oxlint(packageJSON?: OxlintPackageJson, options?: OxlintDefineConfigOptions, projectConfig?: unknown): Promise<TypedFlatConfigItem[]>;
|
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Scoped to {@link GLOB_E2E}.
|
|
4
|
+
*
|
|
5
|
+
* `flat/recommended` ships with no `files` of its own, so all 38 rules applied to every file in any
|
|
6
|
+
* project that has playwright installed — `no-standalone-expect` on a unit test,
|
|
7
|
+
* `no-conditional-in-test` on application code. `playwright/no-standalone-expect` is already in the
|
|
8
|
+
* shared backlog because of it.
|
|
9
|
+
*
|
|
10
|
+
* The globs follow playwright's own conventions for `testDir` rather than a filename convention,
|
|
11
|
+
* which is why they are a separate list from {@link GLOB_TESTS}. A project that keeps its e2e specs
|
|
12
|
+
* somewhere else gets no playwright rules — that is a case for detection, not for going back to
|
|
13
|
+
* linting every file with them.
|
|
14
|
+
*/
|
|
2
15
|
export declare function playwright(): Promise<TypedFlatConfigItem[]>;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* The preset only. `pnpm/json-enforce-catalog` used to be turned off here, in an unscoped block —
|
|
4
|
+
* which AGENTS.md says not to do, and which broke the moment the composer started ignoring JSON in
|
|
5
|
+
* unscoped blocks: the preset scopes itself to `package.json`, the turn-off did not, so the rule
|
|
6
|
+
* came back on for exactly the file it targets. It lives in `src/lint-rules` now.
|
|
7
|
+
*/
|
|
2
8
|
export declare function pnpm(): Promise<TypedFlatConfigItem[]>;
|
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* `eslint-config-prettier` is a config, not a plugin.
|
|
4
|
+
*
|
|
5
|
+
* Its `rules` map is rule name → `"off"`, not rule name → rule module, so registering it under
|
|
6
|
+
* `plugins.prettier` never gave anything a `prettier/` prefix to resolve. At lint time it was
|
|
7
|
+
* inert. Everything that walks `config.plugins` was not: the rule inventory read those 358 `"off"`
|
|
8
|
+
* strings as if they were rules and wrote `prettier/@babel/semi`,
|
|
9
|
+
* `prettier/@stylistic/array-bracket-newline` and 356 more into `rule-inventory.json` and
|
|
10
|
+
* `KnownRuleName` — names that do not exist, that ESLint would reject if anything ever enabled
|
|
11
|
+
* them, and that made every plugin bump's inventory diff noisier for no signal.
|
|
12
|
+
*
|
|
13
|
+
* Spreading the rules is the whole job: turn off the formatting rules prettier and oxfmt own, so
|
|
14
|
+
* two tools do not fight over the same line.
|
|
15
|
+
*/
|
|
2
16
|
export declare function prettier(): Promise<TypedFlatConfigItem[]>;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import type { TypedFlatConfigItem } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Scoped to {@link GLOB_TESTS}, which is the point.
|
|
4
|
+
*
|
|
5
|
+
* It used to say `files: ["tests/**"]` — a directory this repository does not have, and one most
|
|
6
|
+
* projects do not either, since the convention here is `__tests__/`. The block therefore matched
|
|
7
|
+
* nothing and none of its rules had ever run.
|
|
8
|
+
*/
|
|
2
9
|
export declare function vitest(): Promise<TypedFlatConfigItem[]>;
|
|
@@ -1,23 +1,30 @@
|
|
|
1
1
|
import type { ConfigWithExtendsArray } from "@eslint/config-helpers";
|
|
2
2
|
import type { Linter } from "eslint";
|
|
3
3
|
import type { PackageJson } from "type-fest";
|
|
4
|
-
export type
|
|
4
|
+
export type { ConfigNames } from "../../lint-rules/rule-names.generated";
|
|
5
|
+
export type DefineConfigFn = (packageJSON: PackageJson, config?: ConfigWithExtendsArray, options?: DefineConfigOptions) => Promise<ConfigWithExtendsArray>;
|
|
6
|
+
export interface DefineConfigOptions {
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
7
|
-
* specified, these plugins are only available to the matching files.
|
|
8
|
+
* The project's own resolved oxlint config, when it differs from this package's.
|
|
8
9
|
*
|
|
9
|
-
*
|
|
10
|
+
* `eslint-plugin-oxlint` turns an ESLint rule off on the premise that oxlint reports the
|
|
11
|
+
* equivalent, so that decision has to be made against the config oxlint is actually running. By
|
|
12
|
+
* default it is made against this package's, which is right until the project customizes
|
|
13
|
+
* `oxlint.config.mts` — and then a rule the project turned off there is reported by **neither**
|
|
14
|
+
* tool: oxlint stops, and the ESLint suppression built from the untouched base keeps it off. That
|
|
15
|
+
* is the exact failure the shared list exists to prevent, relocated to the consumer's config
|
|
16
|
+
* where it is harder to see.
|
|
17
|
+
*
|
|
18
|
+
* A project that overrides anything in `oxlint.config.mts` should pass the same object here:
|
|
19
|
+
*
|
|
20
|
+
* ```js
|
|
21
|
+
* import oxlintConfig from "./oxlint.config.mts";
|
|
22
|
+
*
|
|
23
|
+
* export default await defineConfig(packageJSON, undefined, { oxlintConfig });
|
|
24
|
+
* ```
|
|
10
25
|
*/
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
export type ConfigNames = "antfu/astro/rules" | "antfu/astro/setup" | "antfu/command/rules" | "antfu/disables/bin" | "antfu/disables/cjs" | "antfu/disables/cli" | "antfu/disables/config-files" | "antfu/disables/dts" | "antfu/disables/scripts" | "antfu/eslint-comments/rules" | "antfu/formatter/astro" | "antfu/formatter/astro/disables" | "antfu/formatter/css" | "antfu/formatter/graphql" | "antfu/formatter/html" | "antfu/formatter/less" | "antfu/formatter/markdown" | "antfu/formatter/scss" | "antfu/formatter/setup" | "antfu/formatter/svg" | "antfu/formatter/xml" | "antfu/gitignore" | "antfu/ignores" | "antfu/imports/rules" | "antfu/javascript/rules" | "antfu/javascript/setup" | "antfu/jsdoc/rules" | "antfu/jsonc/rules" | "antfu/jsonc/setup" | "antfu/jsx/setup" | "antfu/markdown/disables" | "antfu/markdown/parser" | "antfu/markdown/processor" | "antfu/markdown/setup" | "antfu/nextjs/rules" | "antfu/nextjs/setup" | "antfu/node/rules" | "antfu/perfectionist/setup" | "antfu/pnpm/package-json" | "antfu/pnpm/pnpm-workspace-yaml" | "antfu/pnpm/pnpm-workspace-yaml-sort" | "antfu/react/rules" | "antfu/react/setup" | "antfu/react/type-aware-rules" | "antfu/regexp/rules" | "antfu/solid/rules" | "antfu/solid/setup" | "antfu/sort/package-json" | "antfu/sort/tsconfig-json" | "antfu/stylistic/rules" | "antfu/svelte/rules" | "antfu/svelte/setup" | "antfu/test/rules" | "antfu/test/setup" | "antfu/typescript/erasable-syntax-only" | "antfu/typescript/parser" | "antfu/typescript/rules" | "antfu/typescript/rules-type-aware" | "antfu/typescript/setup" | "antfu/typescript/type-aware-parser" | "antfu/unicorn/rules" | "antfu/unocss" | "antfu/vue/rules" | "antfu/vue/setup";
|
|
14
|
-
export type DefineConfigFn = (packageJSON: PackageJson, config?: ConfigWithExtendsArray, options?: DefineConfigOptions) => Promise<ConfigWithExtendsArray>;
|
|
15
|
-
export interface DefineConfigOptions {
|
|
16
|
-
globalIgnores?: string[];
|
|
26
|
+
oxlintConfig?: unknown;
|
|
17
27
|
plugins?: {
|
|
18
|
-
"arrow-return-style"?: {
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
};
|
|
21
28
|
boundaries?: {
|
|
22
29
|
disabled?: boolean;
|
|
23
30
|
};
|
|
@@ -42,6 +49,9 @@ export interface DefineConfigOptions {
|
|
|
42
49
|
escompat?: {
|
|
43
50
|
disabled?: boolean;
|
|
44
51
|
};
|
|
52
|
+
"eslint-comments"?: {
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
};
|
|
45
55
|
"eslint-plugin-array-func"?: {
|
|
46
56
|
disabled?: boolean;
|
|
47
57
|
};
|
|
@@ -60,9 +70,6 @@ export interface DefineConfigOptions {
|
|
|
60
70
|
jsdoc?: {
|
|
61
71
|
disabled?: boolean;
|
|
62
72
|
};
|
|
63
|
-
json?: {
|
|
64
|
-
disabled?: boolean;
|
|
65
|
-
};
|
|
66
73
|
"json-schema-validator"?: {
|
|
67
74
|
disabled?: boolean;
|
|
68
75
|
};
|
|
@@ -75,6 +82,9 @@ export interface DefineConfigOptions {
|
|
|
75
82
|
n?: {
|
|
76
83
|
disabled?: boolean;
|
|
77
84
|
};
|
|
85
|
+
next?: {
|
|
86
|
+
disabled?: boolean;
|
|
87
|
+
};
|
|
78
88
|
"no-unsanitized"?: {
|
|
79
89
|
disabled?: boolean;
|
|
80
90
|
};
|
|
@@ -82,7 +92,6 @@ export interface DefineConfigOptions {
|
|
|
82
92
|
disabled?: boolean;
|
|
83
93
|
};
|
|
84
94
|
oxlint?: {
|
|
85
|
-
configFilePath?: string;
|
|
86
95
|
disabled?: boolean;
|
|
87
96
|
};
|
|
88
97
|
perfectionist?: {
|
|
@@ -131,6 +140,9 @@ export interface DefineConfigOptions {
|
|
|
131
140
|
stylistic?: {
|
|
132
141
|
disabled?: boolean;
|
|
133
142
|
};
|
|
143
|
+
svelte?: {
|
|
144
|
+
disabled?: boolean;
|
|
145
|
+
};
|
|
134
146
|
turbo?: {
|
|
135
147
|
disabled?: boolean;
|
|
136
148
|
};
|
|
@@ -148,6 +160,18 @@ export interface DefineConfigOptions {
|
|
|
148
160
|
};
|
|
149
161
|
};
|
|
150
162
|
react?: boolean;
|
|
163
|
+
/**
|
|
164
|
+
* Apply the shared migration backlog — the rules in `src/lint-rules/temporary` that should be on
|
|
165
|
+
* and are off only until the code is ready for them. Defaults to `true`.
|
|
166
|
+
*
|
|
167
|
+
* Set to `false` to lint against the bar the backlog is deferring. The permanently disabled rules
|
|
168
|
+
* stay off either way; those are decisions, not deferrals.
|
|
169
|
+
*
|
|
170
|
+
* Passed straight through to the oxlint half as well, so both tools answer the same question. It
|
|
171
|
+
* did not use to be: the oxlint config had no such option, so opting out raised the bar in ESLint
|
|
172
|
+
* while oxlint kept the whole backlog off.
|
|
173
|
+
*/
|
|
174
|
+
temporaryRules?: boolean;
|
|
151
175
|
}
|
|
152
176
|
export type Rules = Record<string, Linter.RuleEntry<any> | undefined>;
|
|
153
177
|
/**
|
|
@@ -1,3 +1,63 @@
|
|
|
1
|
-
import type { KnipConfiguration } from "knip";
|
|
1
|
+
import type { IssueType, KnipConfiguration } from "knip";
|
|
2
2
|
export type * from "knip";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* What a finding says:
|
|
5
|
+
*
|
|
6
|
+
* - `correctness` — real defects: an import that does not resolve, a dependency used but never
|
|
7
|
+
* declared, a module exporting the same value twice.
|
|
8
|
+
* - `cycles` — circular imports. A real defect class, and one of the two groups off by default — not
|
|
9
|
+
* because the findings are weak but because reaching them is expensive. knip withholds this type
|
|
10
|
+
* from its own default set, and the only lever that brings it back, `include`, is merged with the
|
|
11
|
+
* command line's, so a config carrying one defeats `--files`, `--exports` and `--dependencies`
|
|
12
|
+
* for every later run. Adopt it where the trade is worth making.
|
|
13
|
+
* - `dependencies` — declared but never used. Needs `ignoreDependencies` for tools a config loads by
|
|
14
|
+
* name.
|
|
15
|
+
* - `exports` — unused exports and types. The largest group in a library monorepo.
|
|
16
|
+
* - `files` — unreachable files. Only as true as the entry graph, so it needs the plugins right.
|
|
17
|
+
* - `namespaces` — exports reachable only through an `import * as`. Off by default, and the one group
|
|
18
|
+
* that stays off: knip cannot tell whether these are used, so the finding is not "this is dead"
|
|
19
|
+
* but "restructure your imports so I can see". That is a style position, not a defect.
|
|
20
|
+
*
|
|
21
|
+
* This is also every value {@link DefineConfigOptions.adopted} accepts.
|
|
22
|
+
*/
|
|
23
|
+
export declare const ISSUE_GROUPS: readonly ["correctness", "cycles", "dependencies", "exports", "files", "namespaces"];
|
|
24
|
+
export type IssueGroup = (typeof ISSUE_GROUPS)[number];
|
|
25
|
+
export type DefineConfigOptions = {
|
|
26
|
+
/**
|
|
27
|
+
* Issue groups this project reports. Everything outside the list is emitted as `off`, unless the
|
|
28
|
+
* config names that issue type in `rules` — a per-type override still wins, and is the granular
|
|
29
|
+
* escape hatch. The one exception knip does not allow is guarded: see `rulesFor`.
|
|
30
|
+
*
|
|
31
|
+
* Defaults to every group knip reports on its own terms, and exists to be **narrowed**: this
|
|
32
|
+
* package already states the bar. A project adopting knip over an existing codebase writes `{
|
|
33
|
+
* adopted: ["correctness"] }` — the one group whose findings are defects rather than debt — and
|
|
34
|
+
* widens it back as each group is cleared, until the option can go altogether.
|
|
35
|
+
*
|
|
36
|
+
* Once most of the codebase passes a group, prefer knip's `ignoreIssues` (paths × issue types)
|
|
37
|
+
* over dropping the whole group again: it keeps new code covered.
|
|
38
|
+
*/
|
|
39
|
+
adopted?: readonly IssueGroup[];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Severities this config emits, and the only ones it accepts.
|
|
43
|
+
*
|
|
44
|
+
* Knip's own `warn` is deliberately absent. It is a real tier there — a `warn` finding is reported
|
|
45
|
+
* and excluded from the count that sets the exit code — but datamitsu reads knip through
|
|
46
|
+
* `--reporter json`, and that reporter carries no severity at all. A warned finding arrives
|
|
47
|
+
* indistinguishable from an errored one, the parser renders every finding as an error, and the run
|
|
48
|
+
* still exits zero: red diagnostics on a green tool. Better that the tier cannot be written at all
|
|
49
|
+
* than that it mean that.
|
|
50
|
+
*/
|
|
51
|
+
export type IssueSeverity = "error" | "off";
|
|
52
|
+
/**
|
|
53
|
+
* What {@link defineConfig} accepts, which is knip's own configuration with `rules` narrowed to
|
|
54
|
+
* {@link IssueSeverity}.
|
|
55
|
+
*
|
|
56
|
+
* The narrowing is advisory rather than enforcement: the canonical config file is a plain `.js`, so
|
|
57
|
+
* nothing type-checks it. `rulesFor` therefore still raises a `warn` at runtime — this only moves
|
|
58
|
+
* the discovery earlier for the projects that do get types.
|
|
59
|
+
*/
|
|
60
|
+
export type KnipOverrides = Omit<KnipConfiguration, "rules"> & {
|
|
61
|
+
rules?: Partial<Record<IssueType, IssueSeverity>>;
|
|
62
|
+
};
|
|
63
|
+
export declare const defineConfig: (overrides?: ((base: KnipOverrides) => KnipOverrides) | KnipOverrides, options?: DefineConfigOptions) => KnipConfiguration;
|
package/dist/apps/knip/index.js
CHANGED
|
@@ -1,11 +1,210 @@
|
|
|
1
1
|
//#region src/apps/knip/index.ts
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const KNIP_DEFAULT_ENTRY = ["{index,cli,main}.{js,mjs,cjs,jsx,ts,tsx,mts,cts}!", "src/{index,cli,main}.{js,mjs,cjs,jsx,ts,tsx,mts,cts}!"];
|
|
3
|
+
const PROJECT_SCOPED_CONFIGS = [
|
|
4
|
+
"eslint.config.mjs",
|
|
5
|
+
"oxlint.config.mts",
|
|
6
|
+
"prettier.config.mjs"
|
|
7
|
+
];
|
|
8
|
+
const GIT_ROOT_SCOPED_CONFIGS = [
|
|
9
|
+
".markdownlint-cli2.mjs",
|
|
10
|
+
"commitlint.config.mjs",
|
|
11
|
+
"cspell.config.mjs",
|
|
12
|
+
"datamitsu.config.{js,ts}",
|
|
13
|
+
"knip.config.js",
|
|
14
|
+
"oxfmt.config.ts"
|
|
15
|
+
];
|
|
16
|
+
const ROOT_WORKSPACE_NAME = ".";
|
|
17
|
+
const SHARED_WORKSPACE_KEY = "**";
|
|
18
|
+
/**
|
|
19
|
+
* Options knip reads _only_ from the workspace config, so the root loses them the moment
|
|
20
|
+
* `workspaces` exists — see {@link withRootWorkspace}.
|
|
21
|
+
*
|
|
22
|
+
* Deliberately shorter than the set of options that can appear in a workspace block. `ignore` and
|
|
23
|
+
* `ignoreFiles` are registered globally from the top-level config as well, and
|
|
24
|
+
* `ignoreExportsUsedInFile` and `includeEntryExports` are read as `workspaceConfig.x ?? topLevel.x`
|
|
25
|
+
* — moving either kind under `"."` would turn a global default into a root-only one.
|
|
26
|
+
*/
|
|
27
|
+
const WORKSPACE_SCOPED_OPTIONS = [
|
|
28
|
+
"entry",
|
|
29
|
+
"ignoreMembers",
|
|
30
|
+
"paths",
|
|
31
|
+
"project"
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* What a finding says:
|
|
35
|
+
*
|
|
36
|
+
* - `correctness` — real defects: an import that does not resolve, a dependency used but never
|
|
37
|
+
* declared, a module exporting the same value twice.
|
|
38
|
+
* - `cycles` — circular imports. A real defect class, and one of the two groups off by default — not
|
|
39
|
+
* because the findings are weak but because reaching them is expensive. knip withholds this type
|
|
40
|
+
* from its own default set, and the only lever that brings it back, `include`, is merged with the
|
|
41
|
+
* command line's, so a config carrying one defeats `--files`, `--exports` and `--dependencies`
|
|
42
|
+
* for every later run. Adopt it where the trade is worth making.
|
|
43
|
+
* - `dependencies` — declared but never used. Needs `ignoreDependencies` for tools a config loads by
|
|
44
|
+
* name.
|
|
45
|
+
* - `exports` — unused exports and types. The largest group in a library monorepo.
|
|
46
|
+
* - `files` — unreachable files. Only as true as the entry graph, so it needs the plugins right.
|
|
47
|
+
* - `namespaces` — exports reachable only through an `import * as`. Off by default, and the one group
|
|
48
|
+
* that stays off: knip cannot tell whether these are used, so the finding is not "this is dead"
|
|
49
|
+
* but "restructure your imports so I can see". That is a style position, not a defect.
|
|
50
|
+
*
|
|
51
|
+
* This is also every value {@link DefineConfigOptions.adopted} accepts.
|
|
52
|
+
*/
|
|
53
|
+
const ISSUE_GROUPS = [
|
|
54
|
+
"correctness",
|
|
55
|
+
"cycles",
|
|
56
|
+
"dependencies",
|
|
57
|
+
"exports",
|
|
58
|
+
"files",
|
|
59
|
+
"namespaces"
|
|
60
|
+
];
|
|
61
|
+
/**
|
|
62
|
+
* Every knip issue type, and the group that owns it.
|
|
63
|
+
*
|
|
64
|
+
* `satisfies Record<IssueType, IssueGroup>` is the point: a knip upgrade that adds an issue type
|
|
65
|
+
* stops this file compiling until somebody decides which group it belongs to. Without it the new
|
|
66
|
+
* type would simply be absent from the emitted `rules` and fall back to knip's own default — the
|
|
67
|
+
* kind of residual with no author behind it that `src/lint-rules` exists to prevent.
|
|
68
|
+
*/
|
|
69
|
+
const ISSUE_TYPE_GROUPS = {
|
|
70
|
+
binaries: "correctness",
|
|
71
|
+
catalog: "dependencies",
|
|
72
|
+
catalogReferences: "correctness",
|
|
73
|
+
cycles: "cycles",
|
|
74
|
+
dependencies: "dependencies",
|
|
75
|
+
devDependencies: "dependencies",
|
|
76
|
+
duplicates: "correctness",
|
|
77
|
+
enumMembers: "exports",
|
|
78
|
+
exports: "exports",
|
|
79
|
+
files: "files",
|
|
80
|
+
namespaceMembers: "exports",
|
|
81
|
+
nsExports: "namespaces",
|
|
82
|
+
nsTypes: "namespaces",
|
|
83
|
+
optionalPeerDependencies: "dependencies",
|
|
84
|
+
types: "exports",
|
|
85
|
+
unlisted: "correctness",
|
|
86
|
+
unresolved: "correctness"
|
|
5
87
|
};
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
88
|
+
const ISSUE_TYPES = Object.keys(ISSUE_TYPE_GROUPS);
|
|
89
|
+
const ADOPTED_BY_DEFAULT = [
|
|
90
|
+
"correctness",
|
|
91
|
+
"dependencies",
|
|
92
|
+
"exports",
|
|
93
|
+
"files"
|
|
94
|
+
];
|
|
95
|
+
const EXCLUDED_BY_KNIP = /* @__PURE__ */ new Set([
|
|
96
|
+
"cycles",
|
|
97
|
+
"nsExports",
|
|
98
|
+
"nsTypes"
|
|
99
|
+
]);
|
|
100
|
+
const DEPENDENCY_TYPES_COUPLED_TO_DEPENDENCIES = ["devDependencies", "optionalPeerDependencies"];
|
|
101
|
+
const createBaseConfig = () => ({
|
|
102
|
+
entry: [
|
|
103
|
+
...KNIP_DEFAULT_ENTRY,
|
|
104
|
+
...PROJECT_SCOPED_CONFIGS,
|
|
105
|
+
...GIT_ROOT_SCOPED_CONFIGS
|
|
106
|
+
],
|
|
107
|
+
ignoreBinaries: [
|
|
108
|
+
"datamitsu",
|
|
109
|
+
"dm",
|
|
110
|
+
"s0"
|
|
111
|
+
],
|
|
112
|
+
tags: ["-knipignore"],
|
|
113
|
+
workspaces: { [SHARED_WORKSPACE_KEY]: { entry: [...KNIP_DEFAULT_ENTRY, ...PROJECT_SCOPED_CONFIGS] } }
|
|
114
|
+
});
|
|
115
|
+
const rulesFor = (adopted, overrides, explicit) => {
|
|
116
|
+
const reported = new Set(adopted);
|
|
117
|
+
const rules = Object.fromEntries(ISSUE_TYPES.map((issueType) => {
|
|
118
|
+
const override = overrides?.[issueType];
|
|
119
|
+
if (override !== void 0) return [issueType, override === "off" ? "off" : "error"];
|
|
120
|
+
return [issueType, reported.has(ISSUE_TYPE_GROUPS[issueType]) ? "error" : "off"];
|
|
121
|
+
}));
|
|
122
|
+
if (rules.dependencies === "off") {
|
|
123
|
+
const demanded = DEPENDENCY_TYPES_COUPLED_TO_DEPENDENCIES.filter((issueType) => explicit?.[issueType] === "error");
|
|
124
|
+
if (demanded.length > 0) throw new Error(`knip cannot report ${demanded.join(" or ")} while \`dependencies\` is off: turning \`dependencies\` off excludes them too, and an exclusion cannot be undone by an include. Drop the \`dependencies: "off"\`, or drop these.`);
|
|
125
|
+
for (const issueType of DEPENDENCY_TYPES_COUPLED_TO_DEPENDENCIES) rules[issueType] = "off";
|
|
126
|
+
}
|
|
127
|
+
return rules;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* The `include` list knip needs, or `undefined` when its own default set already covers what is
|
|
131
|
+
* reported.
|
|
132
|
+
*
|
|
133
|
+
* Severities are not the lever for turning an issue type **on**: knip feeds the types set to `off`
|
|
134
|
+
* into its `exclude` and never reads severities into its `include`, so a type it leaves out of its
|
|
135
|
+
* default set stays out however loudly `rules` asks for it. Naming one in `include` then replaces
|
|
136
|
+
* that default set wholesale — listing only `cycles` reports _nothing but_ cycles — so the list has
|
|
137
|
+
* to be every reported type, not just the ones knip omits.
|
|
138
|
+
*
|
|
139
|
+
* Which is why nothing this emits is on by default. knip **unions** a config's `include` with the
|
|
140
|
+
* command line's, so a config carrying one makes `--files`, `--exports`, `--dependencies` and
|
|
141
|
+
* `--include <type>` stop narrowing anything: the union is still every reported type, and a run
|
|
142
|
+
* meant to look at one kind of finding fails on the other fourteen. That is the whole cost of
|
|
143
|
+
* adopting `cycles` or `namespaces`, and it lands on `datamitsu exec knip`, which is the only way
|
|
144
|
+
* these findings are read by a person. `--exclude` still narrows; it is applied last and wins.
|
|
145
|
+
*/
|
|
146
|
+
const includeFor = (rules) => {
|
|
147
|
+
const reported = ISSUE_TYPES.filter((issueType) => rules?.[issueType] === "error");
|
|
148
|
+
return reported.some((issueType) => EXCLUDED_BY_KNIP.has(issueType)) ? reported : void 0;
|
|
149
|
+
};
|
|
150
|
+
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
151
|
+
const mergeValue = (current, value) => {
|
|
152
|
+
if (value === void 0) return current;
|
|
153
|
+
if (Array.isArray(current) && Array.isArray(value)) return [...current, ...value];
|
|
154
|
+
if (isPlainObject(current) && isPlainObject(value)) {
|
|
155
|
+
const merged = { ...current };
|
|
156
|
+
for (const [key, nested] of Object.entries(value)) merged[key] = mergeValue(merged[key], nested);
|
|
157
|
+
return merged;
|
|
158
|
+
}
|
|
159
|
+
return value;
|
|
160
|
+
};
|
|
161
|
+
const mergeConfig = (base, overrides) => mergeValue(base, overrides);
|
|
162
|
+
const withSharedWorkspaceDefaults = (config) => {
|
|
163
|
+
const workspaces = config.workspaces;
|
|
164
|
+
const shared = workspaces?.[SHARED_WORKSPACE_KEY];
|
|
165
|
+
if (!workspaces || !shared) return config;
|
|
166
|
+
return {
|
|
167
|
+
...config,
|
|
168
|
+
workspaces: Object.fromEntries(Object.entries(workspaces).map(([key, value]) => key === SHARED_WORKSPACE_KEY || key === ROOT_WORKSPACE_NAME ? [key, value] : [key, mergeValue(shared, value)]))
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
const withRootWorkspace = (config) => {
|
|
172
|
+
const rest = { ...config };
|
|
173
|
+
const moved = {};
|
|
174
|
+
for (const option of WORKSPACE_SCOPED_OPTIONS) {
|
|
175
|
+
if (!(option in rest)) continue;
|
|
176
|
+
moved[option] = rest[option];
|
|
177
|
+
delete rest[option];
|
|
178
|
+
}
|
|
179
|
+
if (Object.keys(moved).length === 0) return config;
|
|
180
|
+
const workspaces = rest["workspaces"] ?? {};
|
|
181
|
+
return {
|
|
182
|
+
...rest,
|
|
183
|
+
workspaces: {
|
|
184
|
+
...workspaces,
|
|
185
|
+
[ROOT_WORKSPACE_NAME]: {
|
|
186
|
+
...moved,
|
|
187
|
+
...workspaces[ROOT_WORKSPACE_NAME]
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
};
|
|
192
|
+
const defineConfig = (overrides, options) => {
|
|
193
|
+
const adopted = options?.adopted ?? ADOPTED_BY_DEFAULT;
|
|
194
|
+
const baseRules = rulesFor(adopted);
|
|
195
|
+
const base = {
|
|
196
|
+
...createBaseConfig(),
|
|
197
|
+
rules: baseRules
|
|
198
|
+
};
|
|
199
|
+
const merged = typeof overrides === "function" ? overrides(base) : overrides ? mergeConfig(base, overrides) : base;
|
|
200
|
+
const explicitRules = typeof overrides === "function" || !overrides ? Object.fromEntries(Object.entries(merged.rules ?? {}).filter(([issueType, severity]) => severity !== baseRules[issueType])) : overrides.rules;
|
|
201
|
+
const rules = rulesFor(adopted, merged.rules, explicitRules);
|
|
202
|
+
const include = merged.include ?? includeFor(rules);
|
|
203
|
+
return withRootWorkspace(withSharedWorkspaceDefaults({
|
|
204
|
+
...merged,
|
|
205
|
+
...include && { include },
|
|
206
|
+
rules
|
|
207
|
+
}));
|
|
9
208
|
};
|
|
10
209
|
//#endregion
|
|
11
|
-
export { defineConfig };
|
|
210
|
+
export { ISSUE_GROUPS, defineConfig };
|