@kirill.konshin/lint 0.2.0 → 0.3.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 +202 -51
- package/configs/base.js +98 -0
- package/configs/imports.js +162 -0
- package/configs/nx.js +48 -0
- package/configs/prettier.js +21 -0
- package/configs/promise.js +21 -0
- package/configs/react.js +262 -0
- package/configs/storybook.js +26 -0
- package/configs/tailwind.js +100 -0
- package/configs/testing.js +158 -0
- package/configs/turbo.js +29 -0
- package/configs/typescriptTypeAware.js +110 -0
- package/configs/unicorn.js +47 -0
- package/index.d.ts +271 -0
- package/index.js +119 -610
- package/lib.js +412 -15
- package/package.json +10 -4
- package/rules/tailwind.md +12 -14
- package/rules/testing.md +5 -4
- package/skills/lint-repo.md +2 -2
- package/findTailwindEntry.js +0 -46
- package/ruleTestColocation.js +0 -50
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { isAbsolute, relative } from 'node:path';
|
|
2
|
+
|
|
3
|
+
import { asOptions, findWorkspaceRoot } from '../lib.js';
|
|
4
|
+
|
|
5
|
+
/** @typedef {import('../index.js').TypeAwareOptions} TypeAwareOptions Defined in index.d.ts. */
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Type-aware rules. Off by default (FIXME: does not perform) - enable via
|
|
9
|
+
* `defineLintConfig({ typeAware: true })` or by composing this block manually; it is self-contained
|
|
10
|
+
* (wires typescript-eslint's projectService itself).
|
|
11
|
+
*
|
|
12
|
+
* Config files like vite.config.ts and .storybook/{main,preview}.ts sit at the package root or in
|
|
13
|
+
* a dotfolder, outside their tsconfig.json `include` - projectService has no tsconfig to attach
|
|
14
|
+
* them to. `allowDefaultProject` falls back to a synthetic single-file program for these instead
|
|
15
|
+
* of erroring; it has NO default (the layout is project-specific and its patterns may not contain
|
|
16
|
+
* `**` - see README "Type-aware rules" for how to generate the list).
|
|
17
|
+
* `maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING` defaults to the length of
|
|
18
|
+
* `allowDefaultProject` when that list is given (upstream default is 8), and `tsconfigRootDir`
|
|
19
|
+
* defaults to the detected workspace root.
|
|
20
|
+
*
|
|
21
|
+
* @param {boolean | TypeAwareOptions} [option] the defineLintConfig `typeAware` flag; there is
|
|
22
|
+
* nothing to auto-detect, so only an explicit `true` / options object enables the block
|
|
23
|
+
* @returns {import('eslint').Linter.Config[]}
|
|
24
|
+
*/
|
|
25
|
+
export function typeAwareConfig(option, strict = false) {
|
|
26
|
+
let {
|
|
27
|
+
enabled = false,
|
|
28
|
+
allowDefaultProject,
|
|
29
|
+
// matches the list when it's exact files (the scanWorkspace flow); with multi-match globs
|
|
30
|
+
// set the cap explicitly - typescript-eslint errors loudly when matches exceed it
|
|
31
|
+
maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING = allowDefaultProject?.length,
|
|
32
|
+
// strict detection avoids the workspace walk
|
|
33
|
+
tsconfigRootDir = strict ? process.cwd() : findWorkspaceRoot(),
|
|
34
|
+
} = asOptions(option);
|
|
35
|
+
if (!enabled) return [];
|
|
36
|
+
|
|
37
|
+
// typescript-eslint requires allowDefaultProject globs to be RELATIVE to tsconfigRootDir -
|
|
38
|
+
// absolute entries (e.g. produced by scanWorkspace, see README) are relativized automatically
|
|
39
|
+
allowDefaultProject = allowDefaultProject?.map((file) =>
|
|
40
|
+
isAbsolute(file) ? relative(tsconfigRootDir, file) : file,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
name: 'Type-aware rules (separate for performance)',
|
|
46
|
+
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts', '**/*.mdx'],
|
|
47
|
+
languageOptions: {
|
|
48
|
+
parserOptions: {
|
|
49
|
+
projectService: {
|
|
50
|
+
...(allowDefaultProject ? { allowDefaultProject } : {}),
|
|
51
|
+
...(maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING
|
|
52
|
+
? { maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING }
|
|
53
|
+
: {}),
|
|
54
|
+
},
|
|
55
|
+
tsconfigRootDir,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
rules: {
|
|
59
|
+
'@typescript-eslint/prefer-optional-chain': 'warn',
|
|
60
|
+
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* https://typescript-eslint.io/rules/naming-convention/
|
|
64
|
+
*
|
|
65
|
+
* Naming Conventions. Lives here (not 'Custom
|
|
66
|
+
* rules') because the `types: ['boolean']` filter below needs type info too, even
|
|
67
|
+
* though naming-convention as a whole isn't in the typed-linting rule set.
|
|
68
|
+
*/
|
|
69
|
+
'@typescript-eslint/naming-convention': [
|
|
70
|
+
'warn',
|
|
71
|
+
{ selector: 'default', format: null },
|
|
72
|
+
/*
|
|
73
|
+
* PascalCase allowed too: this codebase's actual
|
|
74
|
+
* convention is `const Cmp: FC<Props> = memo(...)` - components are PascalCase
|
|
75
|
+
* variables, not just PascalCase function declarations.
|
|
76
|
+
*/
|
|
77
|
+
{
|
|
78
|
+
selector: 'variable',
|
|
79
|
+
format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
|
|
80
|
+
leadingUnderscore: 'forbid',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
selector: 'variable',
|
|
84
|
+
types: ['boolean'],
|
|
85
|
+
/*
|
|
86
|
+
* The part AFTER the prefix is naturally capitalized (isLoading, hasError, ...),
|
|
87
|
+
* so it's validated as PascalCase, not camelCase - format here is for the suffix,
|
|
88
|
+
* not the identifier as a whole.
|
|
89
|
+
*/
|
|
90
|
+
format: ['PascalCase'],
|
|
91
|
+
prefix: ['is', 'has', 'had', 'can', 'should', 'will', 'did'],
|
|
92
|
+
},
|
|
93
|
+
/*
|
|
94
|
+
* Established exceptions to the boolean-prefix rule above - conventional enough on
|
|
95
|
+
* their own (React's own `loading`/`done` state names, DOM/library `enabled` flags)
|
|
96
|
+
* that requiring is/has/can/should here would just be noise.
|
|
97
|
+
*/
|
|
98
|
+
{
|
|
99
|
+
selector: 'variable',
|
|
100
|
+
types: ['boolean'],
|
|
101
|
+
filter: { regex: '^(done|loading|enabled)$', match: true },
|
|
102
|
+
format: ['camelCase'],
|
|
103
|
+
},
|
|
104
|
+
{ selector: 'function', format: ['camelCase', 'PascalCase'] },
|
|
105
|
+
{ selector: 'class', format: ['PascalCase'] },
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import unicornPlugin from 'eslint-plugin-unicorn';
|
|
2
|
+
|
|
3
|
+
import { tsExts } from '../lib.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Filename casing + node: protocol.
|
|
7
|
+
*
|
|
8
|
+
* Deliberately NOT using unicorn.configs['flat/recommended'] - it's 337 rules (it even folds in
|
|
9
|
+
* a few unprefixed core-ESLint rules), extremely opinionated, and far beyond what was asked for.
|
|
10
|
+
* Only the two rules below are actually wanted.
|
|
11
|
+
*
|
|
12
|
+
* @returns {import('eslint').Linter.Config[]}
|
|
13
|
+
*/
|
|
14
|
+
export function unicornConfig() {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
name: 'Unicorn rules',
|
|
18
|
+
files: [`**/*.${tsExts}`],
|
|
19
|
+
plugins: { unicorn: unicornPlugin },
|
|
20
|
+
rules: {
|
|
21
|
+
'unicorn/filename-case': [
|
|
22
|
+
'error',
|
|
23
|
+
{
|
|
24
|
+
case: 'camelCase',
|
|
25
|
+
/*
|
|
26
|
+
* code-style.md only mandates FILE names; this repo's own kebab-case package
|
|
27
|
+
* directories (e.g. electron-builder, react-native) are an established convention.
|
|
28
|
+
*/
|
|
29
|
+
checkDirectories: false,
|
|
30
|
+
// Next.js App Router mandates these exact hyphenated filenames - not a naming choice.
|
|
31
|
+
ignore: [
|
|
32
|
+
/^not-found\.[jt]sx?$/,
|
|
33
|
+
/^global-error\.[jt]sx?$/,
|
|
34
|
+
/^opengraph-image\.[jt]sx?$/,
|
|
35
|
+
/^twitter-image\.[jt]sx?$/,
|
|
36
|
+
/^apple-icon\.[jt]sx?$/,
|
|
37
|
+
/^mdx-components\.[jt]sx?$/,
|
|
38
|
+
/\.d\.tsx?$/,
|
|
39
|
+
/^electron-builder\..+$/,
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
'unicorn/prefer-node-protocol': 'error',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Hand-written declarations for the raw-JS package (see README "Why raw JS" - there is no build to
|
|
3
|
+
* emit them from). Keep in sync with index.js / configs/*.js and their JSDoc.
|
|
4
|
+
*
|
|
5
|
+
* Types are pulled from the real underlying packages wherever they export them (eslint's
|
|
6
|
+
* `Linter.Config`, eslint-plugin-tailwindcss's `PluginSettings`, prettier's `Config`,
|
|
7
|
+
* lint-staged's `Configuration`, the plugins' own default-export types), so the options here stay
|
|
8
|
+
* in sync with how the tools themselves define their configs. `@next/eslint-plugin-next` exports
|
|
9
|
+
* no settings type - `NextOptions.rootDir` mirrors its documented `settings.next.rootDir` schema.
|
|
10
|
+
*/
|
|
11
|
+
import type { ParserOptions as TsParserOptions } from '@typescript-eslint/parser';
|
|
12
|
+
import type { Linter } from 'eslint';
|
|
13
|
+
import type { PluginSettings as TailwindPluginSettings } from 'eslint-plugin-tailwindcss';
|
|
14
|
+
import type { Configuration as LintStagedConfiguration } from 'lint-staged';
|
|
15
|
+
import type { Config as PrettierConfig } from 'prettier';
|
|
16
|
+
|
|
17
|
+
type ProjectServiceOptions = Exclude<NonNullable<TsParserOptions['projectService']>, boolean>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Base shape of every tool's options object. Using the object form implies the tool is ON -
|
|
21
|
+
* `enabled` defaults to `true`, so a partially configured tool doesn't also need a separate
|
|
22
|
+
* `true` anywhere; set `enabled: false` to force it off while keeping the other options in place.
|
|
23
|
+
*/
|
|
24
|
+
export type ToggleOptions = {
|
|
25
|
+
enabled?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Detection behavior ({@link defineLintConfig} `detection`) - the same toggle notation as the
|
|
30
|
+
* tool flags:
|
|
31
|
+
* - `undefined` / `true` / `{}` - tools default ON via full auto-detection
|
|
32
|
+
* - `false` / `{ enabled: false }` - tools default OFF; explicitly enabled tools still
|
|
33
|
+
* auto-detect their settings
|
|
34
|
+
* - `strict: true` - same-scope package probes only (exactly what the `has*` checks are): no
|
|
35
|
+
* workspace walks, no evidence scans, no symlink bridges; mandatory settings like
|
|
36
|
+
* `cssConfigPath` must be explicit, and `nx.json` is checked at cwd instead of the workspace
|
|
37
|
+
* root. `{ enabled: false, strict: true }` is ideal for per-package monorepo configs.
|
|
38
|
+
*/
|
|
39
|
+
export type DetectionOptions = ToggleOptions & {
|
|
40
|
+
/** same-scope package probes only - no workspace walks/scans/bridges */
|
|
41
|
+
strict?: boolean;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** Options for the Next.js blocks ({@link nextBaseConfig}). */
|
|
45
|
+
export type NextOptions = ToggleOptions & {
|
|
46
|
+
/**
|
|
47
|
+
* Root of the Next.js app(s) for `@next/eslint-plugin-next` (`settings.next.rootDir`) - needed
|
|
48
|
+
* when the apps don't live at the workspace root, e.g. `path/to/next-app` (globs are supported
|
|
49
|
+
* by the plugin; pass the package root, not `src` - the plugin resolves both the `pages`/`app`
|
|
50
|
+
* and `src/pages`/`src/app` layouts from it). When omitted, auto-detected via
|
|
51
|
+
* {@link findNextRoots}: no evidence found → no settings (the setting is optional), several
|
|
52
|
+
* apps → all of them as an array.
|
|
53
|
+
*
|
|
54
|
+
* @see https://nextjs.org/docs/app/api-reference/config/eslint
|
|
55
|
+
*/
|
|
56
|
+
rootDir?: string | string[];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** Options for the Tailwind block ({@link tailwindConfig}). */
|
|
60
|
+
export type TailwindOptions = ToggleOptions & {
|
|
61
|
+
/**
|
|
62
|
+
* Tailwind v4 entry CSS for `eslint-plugin-tailwindcss` (`settings.tailwindcss.cssConfigPath`),
|
|
63
|
+
* absolute or relative to the lint working directory. When omitted, auto-detected via
|
|
64
|
+
* {@link findTailwindEntry}.
|
|
65
|
+
*/
|
|
66
|
+
cssConfigPath?: TailwindPluginSettings['cssConfigPath'];
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Options for the type-aware block ({@link typeAwareConfig}). `allowDefaultProject` and
|
|
71
|
+
* `maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING` are typescript-eslint's own
|
|
72
|
+
* `projectService` options (real types). `allowDefaultProject` has NO default - generate the file
|
|
73
|
+
* list with {@link scanWorkspace} (absolute entries are relativized against `tsconfigRootDir`
|
|
74
|
+
* automatically); the match cap defaults to that list's length when it is given (set it explicitly
|
|
75
|
+
* when using multi-match globs); `tsconfigRootDir` defaults to the detected workspace root.
|
|
76
|
+
*/
|
|
77
|
+
export type TypeAwareOptions = ToggleOptions &
|
|
78
|
+
Pick<
|
|
79
|
+
ProjectServiceOptions,
|
|
80
|
+
'allowDefaultProject' | 'maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING'
|
|
81
|
+
> & {
|
|
82
|
+
/** Defaults to {@link findWorkspaceRoot}. */
|
|
83
|
+
tsconfigRootDir?: TsParserOptions['tsconfigRootDir'];
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/** Options for the default-ignore block ({@link defaultIgnoreConfig}). */
|
|
87
|
+
export type DefaultIgnoreOptions = ToggleOptions & {
|
|
88
|
+
/**
|
|
89
|
+
* `import.meta.url` of the consumer's `eslint.config.mjs` - the `.gitignore` and
|
|
90
|
+
* `.prettierignore` files are resolved next to it. Required: the config file location cannot
|
|
91
|
+
* be auto-detected.
|
|
92
|
+
*/
|
|
93
|
+
importMetaUrl: string;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Per-tool toggles for {@link defineLintConfig}. Every flag is optional:
|
|
98
|
+
* - `undefined` (default) - auto-detect via the corresponding `has*` export
|
|
99
|
+
* - `true` or an options object - force the tool's blocks ON (use when detection misses a tool
|
|
100
|
+
* that lives only in leaf packages of a monorepo); in the object form `enabled` defaults to
|
|
101
|
+
* `true` and can be set to `false` to force OFF while keeping the other options in place
|
|
102
|
+
* - `false` - force OFF
|
|
103
|
+
*
|
|
104
|
+
* The gated `*Config()` block functions accept the same flag value directly.
|
|
105
|
+
*/
|
|
106
|
+
export type LintOptions = {
|
|
107
|
+
/** Detection behavior: default tool state + strict mode; see {@link DetectionOptions} */
|
|
108
|
+
detection?: boolean | DetectionOptions;
|
|
109
|
+
/** Next.js (`eslint-config-next`); when off, generic React/JSX rules apply instead */
|
|
110
|
+
next?: boolean | NextOptions;
|
|
111
|
+
/** Storybook (`eslint-plugin-storybook`) */
|
|
112
|
+
storybook?: boolean | ToggleOptions;
|
|
113
|
+
/** Turborepo (`eslint-plugin-turbo`) */
|
|
114
|
+
turbo?: boolean | ToggleOptions;
|
|
115
|
+
/** Nx (`@nx/eslint-plugin` base + `@nx/dependency-checks`) */
|
|
116
|
+
nx?: boolean | ToggleOptions;
|
|
117
|
+
/** Jest recommended rules for `*.{test,spec}.*` */
|
|
118
|
+
jest?: boolean | ToggleOptions;
|
|
119
|
+
/** Vitest recommended rules for `*.{test,spec}.*` */
|
|
120
|
+
vitest?: boolean | ToggleOptions;
|
|
121
|
+
/** Tailwind (`eslint-plugin-tailwindcss`); forcing ON without a resolvable entry CSS is a hard error, several entry CSS candidates always are */
|
|
122
|
+
tailwind?: boolean | TailwindOptions;
|
|
123
|
+
/** Type-aware TypeScript rules; off by default (slow), nothing to auto-detect */
|
|
124
|
+
typeAware?: boolean | TypeAwareOptions;
|
|
125
|
+
/** `.gitignore` + `.prettierignore` as ESLint ignores; off by default, `true` without `importMetaUrl` is a hard error */
|
|
126
|
+
defaultIgnore?: boolean | DefaultIgnoreOptions;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Build the shared flat ESLint config. By default every tool integration is auto-detected (see the
|
|
131
|
+
* `has*` exports); pass {@link LintOptions} to force any of them on/off or to supply tool-specific
|
|
132
|
+
* settings. ESLint natively awaits a Promise default export, so a plain
|
|
133
|
+
* `export default defineLintConfig({...})` works; `await` it only when composing with extra blocks.
|
|
134
|
+
*/
|
|
135
|
+
export function defineLintConfig(
|
|
136
|
+
options?: LintOptions | Promise<LintOptions> | (() => LintOptions | Promise<LintOptions>),
|
|
137
|
+
): Promise<Linter.Config[]>;
|
|
138
|
+
|
|
139
|
+
// ----- Blocks (in the order defineLintConfig applies them; from configs/*.js) -----
|
|
140
|
+
// Gated blocks take their LintOptions flag and return [] when resolved off.
|
|
141
|
+
|
|
142
|
+
/** Core JS recommended rules, global ignores, browser + Node globals, and core-rule overrides. */
|
|
143
|
+
export function baseConfig(): Linter.Config[];
|
|
144
|
+
/**
|
|
145
|
+
* `.gitignore` + `.prettierignore` (next to the consumer's config file, both must exist) as
|
|
146
|
+
* ESLint ignores. Off by default; enabling without `importMetaUrl` is a hard error.
|
|
147
|
+
*/
|
|
148
|
+
export function defaultIgnoreConfig(option?: boolean | DefaultIgnoreOptions): Linter.Config[];
|
|
149
|
+
/** The whole `eslint-config-next` flat config, plus `settings.next.rootDir` when given. Next-only, ungated. */
|
|
150
|
+
export function nextBaseConfig(options?: NextOptions): Promise<Linter.Config[]>;
|
|
151
|
+
/** React/React Hooks/jsx-a11y rules for non-Next (e.g. Vite) React projects. Ungated. */
|
|
152
|
+
export function reactBaseConfig(): Linter.Config[];
|
|
153
|
+
/** Chooser: {@link nextBaseConfig} when Next is enabled, the {@link reactBaseConfig} fallback otherwise. */
|
|
154
|
+
export function nextConfig(option?: boolean | NextOptions, strict?: boolean): Promise<Linter.Config[]>;
|
|
155
|
+
/**
|
|
156
|
+
* The whole React family in its load-bearing order - {@link nextConfig} (Next is just a shortcut
|
|
157
|
+
* to an opinionated React/TypeScript setup), then {@link typescriptOverridesConfig},
|
|
158
|
+
* {@link nextOverridesConfig} and {@link reactSettingsConfig}, which apply no matter whether Next
|
|
159
|
+
* or plain React won. Used by {@link defineLintConfig}; `option` is the `next` flag.
|
|
160
|
+
*/
|
|
161
|
+
export function reactConfig(option?: boolean | NextOptions, strict?: boolean): Promise<Linter.Config[]>;
|
|
162
|
+
/** `eslint-config-next/typescript` (typescript-eslint wiring, which stems from Next) + deliberate rule overrides. */
|
|
163
|
+
export function typescriptOverridesConfig(): Linter.Config[];
|
|
164
|
+
/** Overrides of rules set by `eslint-config-next` (always applied, harmless without Next). */
|
|
165
|
+
export function nextOverridesConfig(): Linter.Config[];
|
|
166
|
+
/** React version settings workaround (ESLint 10 + Next). Always applied. */
|
|
167
|
+
export function reactSettingsConfig(): Linter.Config[];
|
|
168
|
+
/** Prettier compatibility (`eslint-config-prettier/flat`). */
|
|
169
|
+
export function prettierConfig(): Linter.Config[];
|
|
170
|
+
/** Storybook recommended rules. */
|
|
171
|
+
export function storybookConfig(option?: boolean | ToggleOptions, strict?: boolean): Promise<Linter.Config[]>;
|
|
172
|
+
/** eslint-plugin-import-x recommended rules + overrides + the default-export relaxation for conventional files. */
|
|
173
|
+
export function importXConfig(): Linter.Config[];
|
|
174
|
+
/** Deterministic import ordering (eslint-plugin-simple-import-sort). */
|
|
175
|
+
export function importSortConfig(): Linter.Config[];
|
|
176
|
+
/** Autofixable removal of unused imports. */
|
|
177
|
+
export function unusedImportsConfig(): Linter.Config[];
|
|
178
|
+
/** eslint-plugin-promise recommended rules + overrides. */
|
|
179
|
+
export function promiseConfig(): Linter.Config[];
|
|
180
|
+
/** Filename casing + node: protocol (two hand-picked unicorn rules). */
|
|
181
|
+
export function unicornConfig(): Linter.Config[];
|
|
182
|
+
/** Type-aware rules via typescript-eslint's projectService; off unless the flag is set (nothing to auto-detect). */
|
|
183
|
+
export function typeAwareConfig(option?: boolean | TypeAwareOptions, strict?: boolean): Linter.Config[];
|
|
184
|
+
/** Turborepo rules. */
|
|
185
|
+
export function turboConfig(option?: boolean | ToggleOptions): Promise<Linter.Config[]>;
|
|
186
|
+
/**
|
|
187
|
+
* Tailwind recommended rules. Explicit `cssConfigPath` wins; otherwise auto-found via
|
|
188
|
+
* {@link findTailwindEntry}. Zero entries: inert when auto-detected, throws when forced on
|
|
189
|
+
* (`true`/options). Several entries ALWAYS throw - pass `cssConfigPath` to pick one.
|
|
190
|
+
*/
|
|
191
|
+
export function tailwindConfig(option?: boolean | TailwindOptions, strict?: boolean): Promise<Linter.Config[]>;
|
|
192
|
+
/** Nx plugin registration + `@nx/dependency-checks`. */
|
|
193
|
+
export function nxConfig(option?: boolean | ToggleOptions, strict?: boolean): Promise<Linter.Config[]>;
|
|
194
|
+
/** Jest recommended rules, scoped to test files. */
|
|
195
|
+
export function jestConfig(option?: boolean | ToggleOptions, strict?: boolean): Linter.Config[];
|
|
196
|
+
/** Vitest recommended rules + globals, scoped to test files. */
|
|
197
|
+
export function vitestConfig(option?: boolean | ToggleOptions, strict?: boolean): Linter.Config[];
|
|
198
|
+
/** Runner-agnostic test rules (consistent-test-it, test colocation). Always applied. */
|
|
199
|
+
export function testConfig(): Linter.Config[];
|
|
200
|
+
|
|
201
|
+
// ----- Detection (module-load time capability probes, exported for debugging; from lib.js) -----
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Workspace root of the consumer project - the anchor for every config-file scan and for `nx.json`
|
|
205
|
+
* detection. Resolved from the package manager (env: Yarn Berry `PROJECT_CWD` / npm
|
|
206
|
+
* `npm_config_local_prefix`; CLIs: `pnpm root -w`, Yarn Berry via `yarn node`, `npm prefix`),
|
|
207
|
+
* falling back to a lockfile walk bounded by `.git`; every candidate must contain `cwd`.
|
|
208
|
+
* Cached per `cwd`.
|
|
209
|
+
*/
|
|
210
|
+
export function findWorkspaceRoot(cwd?: string): string;
|
|
211
|
+
|
|
212
|
+
export const hasNext: boolean;
|
|
213
|
+
export const hasStorybook: boolean;
|
|
214
|
+
export const hasVite: boolean;
|
|
215
|
+
export const hasJest: boolean;
|
|
216
|
+
export const hasVitest: boolean;
|
|
217
|
+
export const hasTurbo: boolean;
|
|
218
|
+
export const hasNx: boolean;
|
|
219
|
+
export const hasTailwind: boolean;
|
|
220
|
+
|
|
221
|
+
// ----- Extension lists (from lib.js) -----
|
|
222
|
+
|
|
223
|
+
export const tsExtsRaw: string;
|
|
224
|
+
export const eslintExtsRaw: string;
|
|
225
|
+
export const prettierExtsRaw: string;
|
|
226
|
+
export const tsExts: string;
|
|
227
|
+
export const eslintExts: string;
|
|
228
|
+
export const prettierExts: string;
|
|
229
|
+
|
|
230
|
+
// ----- Plugin re-exports (detection-gated at module load; null when the tool wasn't detected) -----
|
|
231
|
+
|
|
232
|
+
export const nextPlugin: typeof import('@next/eslint-plugin-next').default | null;
|
|
233
|
+
export const nxPlugin: typeof import('@nx/eslint-plugin').default | null;
|
|
234
|
+
export const turboPlugin: typeof import('eslint-plugin-turbo').default | null;
|
|
235
|
+
export const jestPlugin: typeof import('eslint-plugin-jest');
|
|
236
|
+
export const vitestPlugin: typeof import('@vitest/eslint-plugin').default;
|
|
237
|
+
|
|
238
|
+
// ----- Helpers & companion configs -----
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Auto-find the Tailwind v4 entry CSS: the single `*.css` (scanned up to 5 directory levels below
|
|
242
|
+
* the workspace root, skipping `.gitignore`d files and build outputs) containing
|
|
243
|
+
* `@import "tailwindcss"`; null when zero or several match.
|
|
244
|
+
*/
|
|
245
|
+
export function findTailwindEntry(ignores: string[]): string | null;
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Auto-find Next.js app roots below the workspace root (scanned up to 5 levels, skipping
|
|
249
|
+
* `.gitignore`d files and build outputs). `next.config.*` is optional in Next.js, so any of three
|
|
250
|
+
* signals marks an app root: a `next.config.*`, a `package.json` depending on `next`
|
|
251
|
+
* (dependencies/devDependencies - peer declarations mark libraries, not apps), or a
|
|
252
|
+
* `src/app`/`src/pages` directory (the reported root is the directory containing `src`);
|
|
253
|
+
* deduplicated and sorted.
|
|
254
|
+
*/
|
|
255
|
+
export function findNextRoots(ignores: string[]): string[];
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Glob for config-file candidates below the workspace root (up to 5 directory levels, skipping
|
|
259
|
+
* dot dirs unless `dot`, build outputs, extra `ignores` and everything in the root `.gitignore`).
|
|
260
|
+
* Returns absolute paths - useful for building file lists like `typeAware.allowDefaultProject`.
|
|
261
|
+
*/
|
|
262
|
+
export function scanWorkspace(fileGlob: string, ignores?: string[], options?: { dot?: boolean }): string[];
|
|
263
|
+
|
|
264
|
+
/** Convert an ignore file (`.gitignore`, `.prettierignore`) into an ESLint ignores block. */
|
|
265
|
+
export function includeIgnoreFile(importMetaUrl: string, ignoreFile: string): Linter.Config;
|
|
266
|
+
|
|
267
|
+
/** Shared Prettier configuration (`.prettierrc.mjs`: `export default prettier`). */
|
|
268
|
+
export const prettier: PrettierConfig;
|
|
269
|
+
|
|
270
|
+
/** Shared lint-staged configuration (`.lintstagedrc.mjs`: `export default listStaged`). */
|
|
271
|
+
export const listStaged: LintStagedConfiguration;
|