@reasonabletech/eslint-config 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +89 -0
- package/dist/src/base-configs.d.ts +53 -0
- package/dist/src/base-configs.js +105 -0
- package/dist/src/custom-rules/architecture-patterns.d.ts +193 -0
- package/dist/src/custom-rules/architecture-patterns.js +344 -0
- package/dist/src/custom-rules/code-quality.d.ts +201 -0
- package/dist/src/custom-rules/code-quality.js +388 -0
- package/dist/src/custom-rules/error-handling.d.ts +103 -0
- package/dist/src/custom-rules/error-handling.js +349 -0
- package/dist/src/custom-rules/index.d.ts +79 -0
- package/dist/src/custom-rules/index.js +119 -0
- package/dist/src/custom-rules/null-undefined-checks.d.ts +20 -0
- package/dist/src/custom-rules/null-undefined-checks.js +153 -0
- package/dist/src/custom-rules/platform-conventions.d.ts +115 -0
- package/dist/src/custom-rules/platform-conventions.js +249 -0
- package/dist/src/custom-rules/test-quality.d.ts +38 -0
- package/dist/src/custom-rules/test-quality.js +68 -0
- package/dist/src/custom-rules/type-safety.d.ts +71 -0
- package/dist/src/custom-rules/type-safety.js +121 -0
- package/dist/src/custom-rules/ui-library-imports.d.ts +21 -0
- package/dist/src/custom-rules/ui-library-imports.js +31 -0
- package/dist/src/custom-rules/utils.d.ts +95 -0
- package/dist/src/custom-rules/utils.js +146 -0
- package/dist/src/index.d.ts +73 -0
- package/dist/src/index.js +80 -0
- package/dist/src/next/config.d.ts +26 -0
- package/dist/src/next/config.js +76 -0
- package/dist/src/next/ignores.d.ts +37 -0
- package/dist/src/next/ignores.js +69 -0
- package/dist/src/next/plugins.d.ts +44 -0
- package/dist/src/next/plugins.js +104 -0
- package/dist/src/next/rules.d.ts +39 -0
- package/dist/src/next/rules.js +48 -0
- package/dist/src/next/settings.d.ts +41 -0
- package/dist/src/next/settings.js +45 -0
- package/dist/src/next.d.ts +33 -0
- package/dist/src/next.js +74 -0
- package/dist/src/plugin.d.ts +48 -0
- package/dist/src/plugin.js +30 -0
- package/dist/src/react/config.d.ts +30 -0
- package/dist/src/react/config.js +40 -0
- package/dist/src/react/plugins.d.ts +24 -0
- package/dist/src/react/plugins.js +46 -0
- package/dist/src/react/rules.d.ts +30 -0
- package/dist/src/react/rules.js +35 -0
- package/dist/src/react.d.ts +27 -0
- package/dist/src/react.js +35 -0
- package/dist/src/shared/parser-options.d.ts +3 -0
- package/dist/src/shared/parser-options.js +19 -0
- package/dist/src/shared/plugin-utils.d.ts +8 -0
- package/dist/src/shared/plugin-utils.js +23 -0
- package/dist/src/shared/react-rules.d.ts +97 -0
- package/dist/src/shared/react-rules.js +126 -0
- package/dist/src/shared/strict-rules.d.ts +27 -0
- package/dist/src/shared/strict-rules.js +54 -0
- package/dist/src/shared-ignores.d.ts +15 -0
- package/dist/src/shared-ignores.js +68 -0
- package/dist/src/shared-rules.d.ts +29 -0
- package/dist/src/shared-rules.js +163 -0
- package/package.json +122 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* Next.js-specific ignore patterns for ESLint.
|
|
4
|
+
*
|
|
5
|
+
* These patterns exclude files and directories that should not be linted
|
|
6
|
+
* in Next.js projects, including generated files, build outputs, and
|
|
7
|
+
* configuration files that don't need linting.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Generated files and build outputs that Next.js creates.
|
|
11
|
+
*/
|
|
12
|
+
export declare const nextjsBuildIgnores: readonly [".next/**", "out/**", "dist/**", "build/**", "generated/**", "next-env.d.ts", "next.config.*"];
|
|
13
|
+
/**
|
|
14
|
+
* Test files and testing configuration.
|
|
15
|
+
*/
|
|
16
|
+
export declare const testFileIgnores: readonly ["tests/**/*", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx", "vitest.config.*", "playwright.config.*", "playwright.ci.config.*", "playwright-report/**", "test-results/**"];
|
|
17
|
+
/**
|
|
18
|
+
* Configuration files that don't need linting.
|
|
19
|
+
*/
|
|
20
|
+
export declare const configFileIgnores: readonly ["eslint.config.*", "postcss.config.*", "tailwind.config.*", "**/*.config.mts", "**/*.stories.ts", "**/*.stories.tsx"];
|
|
21
|
+
/**
|
|
22
|
+
* Next.js application-specific ignores.
|
|
23
|
+
*/
|
|
24
|
+
export declare const nextjsAppIgnores: readonly ["app/.well-known/**/*"];
|
|
25
|
+
/**
|
|
26
|
+
* Complete list of all ignore patterns for Next.js projects.
|
|
27
|
+
*/
|
|
28
|
+
export declare const allNextjsIgnores: readonly [".next/**", "out/**", "dist/**", "build/**", "generated/**", "next-env.d.ts", "next.config.*", "tests/**/*", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx", "vitest.config.*", "playwright.config.*", "playwright.ci.config.*", "playwright-report/**", "test-results/**", "eslint.config.*", "postcss.config.*", "tailwind.config.*", "**/*.config.mts", "**/*.stories.ts", "**/*.stories.tsx", "app/.well-known/**/*"];
|
|
29
|
+
/**
|
|
30
|
+
* Creates the ignore configuration for Next.js projects.
|
|
31
|
+
*
|
|
32
|
+
* This configuration must be first in the ESLint config array
|
|
33
|
+
* and should only contain ignore patterns.
|
|
34
|
+
* @returns ESLint configuration object with ignore patterns for Next.js
|
|
35
|
+
*/
|
|
36
|
+
export declare const createNextjsIgnoreConfig: () => Linter.Config;
|
|
37
|
+
//# sourceMappingURL=ignores.d.ts.map
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Next.js-specific ignore patterns for ESLint.
|
|
3
|
+
*
|
|
4
|
+
* These patterns exclude files and directories that should not be linted
|
|
5
|
+
* in Next.js projects, including generated files, build outputs, and
|
|
6
|
+
* configuration files that don't need linting.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Generated files and build outputs that Next.js creates.
|
|
10
|
+
*/
|
|
11
|
+
export const nextjsBuildIgnores = [
|
|
12
|
+
".next/**",
|
|
13
|
+
"out/**",
|
|
14
|
+
"dist/**",
|
|
15
|
+
"build/**",
|
|
16
|
+
"generated/**",
|
|
17
|
+
"next-env.d.ts",
|
|
18
|
+
"next.config.*",
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Test files and testing configuration.
|
|
22
|
+
*/
|
|
23
|
+
export const testFileIgnores = [
|
|
24
|
+
"tests/**/*",
|
|
25
|
+
"**/*.test.ts",
|
|
26
|
+
"**/*.test.tsx",
|
|
27
|
+
"**/*.spec.ts",
|
|
28
|
+
"**/*.spec.tsx",
|
|
29
|
+
"vitest.config.*",
|
|
30
|
+
"playwright.config.*",
|
|
31
|
+
"playwright.ci.config.*", // CI-specific playwright configs
|
|
32
|
+
"playwright-report/**",
|
|
33
|
+
"test-results/**",
|
|
34
|
+
];
|
|
35
|
+
/**
|
|
36
|
+
* Configuration files that don't need linting.
|
|
37
|
+
*/
|
|
38
|
+
export const configFileIgnores = [
|
|
39
|
+
"eslint.config.*", // ESLint configuration files
|
|
40
|
+
"postcss.config.*",
|
|
41
|
+
"tailwind.config.*",
|
|
42
|
+
"**/*.config.mts",
|
|
43
|
+
"**/*.stories.ts",
|
|
44
|
+
"**/*.stories.tsx",
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* Next.js application-specific ignores.
|
|
48
|
+
*/
|
|
49
|
+
export const nextjsAppIgnores = ["app/.well-known/**/*"];
|
|
50
|
+
/**
|
|
51
|
+
* Complete list of all ignore patterns for Next.js projects.
|
|
52
|
+
*/
|
|
53
|
+
export const allNextjsIgnores = [
|
|
54
|
+
...nextjsBuildIgnores,
|
|
55
|
+
...testFileIgnores,
|
|
56
|
+
...configFileIgnores,
|
|
57
|
+
...nextjsAppIgnores,
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* Creates the ignore configuration for Next.js projects.
|
|
61
|
+
*
|
|
62
|
+
* This configuration must be first in the ESLint config array
|
|
63
|
+
* and should only contain ignore patterns.
|
|
64
|
+
* @returns ESLint configuration object with ignore patterns for Next.js
|
|
65
|
+
*/
|
|
66
|
+
export const createNextjsIgnoreConfig = () => ({
|
|
67
|
+
ignores: [...allNextjsIgnores],
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=ignores.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* Next.js plugin configurations and integrations.
|
|
4
|
+
*
|
|
5
|
+
* This module handles the complex setup of Next.js ESLint plugins,
|
|
6
|
+
* including React integration and Next.js-specific configurations
|
|
7
|
+
* using FlatCompat for legacy plugin support.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Attempts to load Next.js ESLint configurations.
|
|
11
|
+
*
|
|
12
|
+
* Uses eslint-config-next flat configs directly to avoid legacy
|
|
13
|
+
* compatibility shims. Gracefully handles cases where Next.js
|
|
14
|
+
* ESLint configs are not available.
|
|
15
|
+
* @param projectDir - The project directory for FlatCompat context
|
|
16
|
+
* @returns Array of Next.js ESLint configurations, or empty array if unavailable
|
|
17
|
+
*/
|
|
18
|
+
export declare const loadNextjsConfigs: (projectDir: string) => Linter.Config[];
|
|
19
|
+
/**
|
|
20
|
+
* Creates React plugin configuration for Next.js projects.
|
|
21
|
+
*
|
|
22
|
+
* This is used as fallback when Next.js configs are not available,
|
|
23
|
+
* providing the necessary React setup for Next.js development.
|
|
24
|
+
*
|
|
25
|
+
* Note: We manually construct the config to avoid circular references
|
|
26
|
+
* that exist in reactPlugin.configs.flat.recommended (which contains
|
|
27
|
+
* plugins.react pointing back to itself, causing JSON serialization errors).
|
|
28
|
+
* @returns Array of ESLint configurations for React in Next.js projects
|
|
29
|
+
*/
|
|
30
|
+
export declare const createReactPluginForNextjs: () => Linter.Config[];
|
|
31
|
+
/**
|
|
32
|
+
* Creates the complete plugin configuration for Next.js projects.
|
|
33
|
+
*
|
|
34
|
+
* Attempts to load Next.js configs first, falling back to React
|
|
35
|
+
* configurations if Next.js plugins are unavailable.
|
|
36
|
+
* @param projectDir - The project directory for configuration context
|
|
37
|
+
* @returns Object containing Next.js configs and whether fallback is needed
|
|
38
|
+
*/
|
|
39
|
+
export declare const createNextjsPluginConfig: (projectDir: string) => {
|
|
40
|
+
nextConfigs: Linter.Config[];
|
|
41
|
+
fallbackConfigs: Linter.Config[];
|
|
42
|
+
usesFallback: boolean;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import reactPlugin from "eslint-plugin-react";
|
|
4
|
+
import globals from "globals";
|
|
5
|
+
import { removeProjectParserOption } from "../shared/parser-options.js";
|
|
6
|
+
import { stripPluginConfigs } from "../shared/plugin-utils.js";
|
|
7
|
+
/**
|
|
8
|
+
* Next.js plugin configurations and integrations.
|
|
9
|
+
*
|
|
10
|
+
* This module handles the complex setup of Next.js ESLint plugins,
|
|
11
|
+
* including React integration and Next.js-specific configurations
|
|
12
|
+
* using FlatCompat for legacy plugin support.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Attempts to load Next.js ESLint configurations.
|
|
16
|
+
*
|
|
17
|
+
* Uses eslint-config-next flat configs directly to avoid legacy
|
|
18
|
+
* compatibility shims. Gracefully handles cases where Next.js
|
|
19
|
+
* ESLint configs are not available.
|
|
20
|
+
* @param projectDir - The project directory for FlatCompat context
|
|
21
|
+
* @returns Array of Next.js ESLint configurations, or empty array if unavailable
|
|
22
|
+
*/
|
|
23
|
+
export const loadNextjsConfigs = (projectDir) => {
|
|
24
|
+
const baseDir = path.isAbsolute(projectDir)
|
|
25
|
+
? projectDir
|
|
26
|
+
: path.resolve(projectDir);
|
|
27
|
+
try {
|
|
28
|
+
const requireFromBase = createRequire(path.join(baseDir, "package.json"));
|
|
29
|
+
const nextCoreWebVitals = requireFromBase("eslint-config-next/core-web-vitals");
|
|
30
|
+
const nextTypescript = requireFromBase("eslint-config-next/typescript");
|
|
31
|
+
const nextCoreWebVitalsConfigs = assertConfigArray(nextCoreWebVitals, "core-web-vitals");
|
|
32
|
+
const nextTypescriptConfigs = assertConfigArray(nextTypescript, "typescript");
|
|
33
|
+
return [...nextCoreWebVitalsConfigs, ...nextTypescriptConfigs].map(removeProjectParserOption);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (process.env.NODE_ENV !== "test") {
|
|
37
|
+
console.warn("Next.js ESLint config not available, using base React setup", error instanceof Error ? error.message : error);
|
|
38
|
+
}
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const isConfigArray = (value) => Array.isArray(value) &&
|
|
43
|
+
value.every((entry) => typeof entry === "object" && entry !== null);
|
|
44
|
+
const assertConfigArray = (value, label) => {
|
|
45
|
+
if (!isConfigArray(value)) {
|
|
46
|
+
throw new Error(`eslint-config-next must provide flat config arrays (v16+). Missing ${label}.`);
|
|
47
|
+
}
|
|
48
|
+
return value;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Creates React plugin configuration for Next.js projects.
|
|
52
|
+
*
|
|
53
|
+
* This is used as fallback when Next.js configs are not available,
|
|
54
|
+
* providing the necessary React setup for Next.js development.
|
|
55
|
+
*
|
|
56
|
+
* Note: We manually construct the config to avoid circular references
|
|
57
|
+
* that exist in reactPlugin.configs.flat.recommended (which contains
|
|
58
|
+
* plugins.react pointing back to itself, causing JSON serialization errors).
|
|
59
|
+
* @returns Array of ESLint configurations for React in Next.js projects
|
|
60
|
+
*/
|
|
61
|
+
export const createReactPluginForNextjs = () => {
|
|
62
|
+
const recommendedConfig = reactPlugin.configs.flat
|
|
63
|
+
.recommended;
|
|
64
|
+
// Extract rules and settings without the circular plugin reference
|
|
65
|
+
// Only include settings if it exists and is an object (ESLint requirement)
|
|
66
|
+
const baseConfig = {
|
|
67
|
+
plugins: {
|
|
68
|
+
react: stripPluginConfigs(reactPlugin),
|
|
69
|
+
},
|
|
70
|
+
rules: recommendedConfig.rules,
|
|
71
|
+
languageOptions: {
|
|
72
|
+
...recommendedConfig.languageOptions,
|
|
73
|
+
globals: {
|
|
74
|
+
...globals.serviceworker,
|
|
75
|
+
...globals.browser,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
// Conditionally add settings only if present
|
|
80
|
+
if (recommendedConfig.settings !== undefined &&
|
|
81
|
+
typeof recommendedConfig.settings === "object") {
|
|
82
|
+
baseConfig.settings = recommendedConfig.settings;
|
|
83
|
+
}
|
|
84
|
+
return [baseConfig];
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Creates the complete plugin configuration for Next.js projects.
|
|
88
|
+
*
|
|
89
|
+
* Attempts to load Next.js configs first, falling back to React
|
|
90
|
+
* configurations if Next.js plugins are unavailable.
|
|
91
|
+
* @param projectDir - The project directory for configuration context
|
|
92
|
+
* @returns Object containing Next.js configs and whether fallback is needed
|
|
93
|
+
*/
|
|
94
|
+
export const createNextjsPluginConfig = (projectDir) => {
|
|
95
|
+
const nextConfigs = loadNextjsConfigs(projectDir);
|
|
96
|
+
const usesFallback = nextConfigs.length === 0;
|
|
97
|
+
const fallbackConfigs = usesFallback ? createReactPluginForNextjs() : [];
|
|
98
|
+
return {
|
|
99
|
+
nextConfigs,
|
|
100
|
+
fallbackConfigs,
|
|
101
|
+
usesFallback,
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=plugins.js.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* Rule configurations for Next.js projects.
|
|
4
|
+
*
|
|
5
|
+
* These rules leverage shared React rules while adding Next.js-specific
|
|
6
|
+
* configurations and handling conditional plugin setups.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Next.js React rules using shared configurations.
|
|
10
|
+
*
|
|
11
|
+
* Uses shared React rules configured specifically for Next.js,
|
|
12
|
+
* which includes built-in JSX transform support.
|
|
13
|
+
*/
|
|
14
|
+
export declare const nextjsReactRules: Record<string, Linter.RuleEntry<any[]>>;
|
|
15
|
+
/**
|
|
16
|
+
* Additional Next.js-specific rules that don't apply to standalone React.
|
|
17
|
+
*
|
|
18
|
+
* These rules are specific to Next.js applications and their
|
|
19
|
+
* particular patterns and optimizations.
|
|
20
|
+
*/
|
|
21
|
+
export declare const nextjsOnlyRules: {};
|
|
22
|
+
/**
|
|
23
|
+
* React Hooks rules removed - Next.js includes built-in hooks support
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Combined Next.js rules.
|
|
27
|
+
*
|
|
28
|
+
* Merges shared React rules with Next.js-specific rules.
|
|
29
|
+
*/
|
|
30
|
+
export declare const allNextjsRules: {};
|
|
31
|
+
/**
|
|
32
|
+
* Creates the main rules configuration for Next.js projects.
|
|
33
|
+
*
|
|
34
|
+
* Combines all rule categories. React Hooks rules are now provided
|
|
35
|
+
* by Next.js built-in configuration.
|
|
36
|
+
* @returns Combined rules configuration
|
|
37
|
+
*/
|
|
38
|
+
export declare const createNextjsRulesConfig: () => Linter.Config;
|
|
39
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createSharedReactRules } from "../shared/react-rules.js";
|
|
2
|
+
/**
|
|
3
|
+
* Rule configurations for Next.js projects.
|
|
4
|
+
*
|
|
5
|
+
* These rules leverage shared React rules while adding Next.js-specific
|
|
6
|
+
* configurations and handling conditional plugin setups.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Next.js React rules using shared configurations.
|
|
10
|
+
*
|
|
11
|
+
* Uses shared React rules configured specifically for Next.js,
|
|
12
|
+
* which includes built-in JSX transform support.
|
|
13
|
+
*/
|
|
14
|
+
export const nextjsReactRules = createSharedReactRules("nextjs");
|
|
15
|
+
/**
|
|
16
|
+
* Additional Next.js-specific rules that don't apply to standalone React.
|
|
17
|
+
*
|
|
18
|
+
* These rules are specific to Next.js applications and their
|
|
19
|
+
* particular patterns and optimizations.
|
|
20
|
+
*/
|
|
21
|
+
export const nextjsOnlyRules = {
|
|
22
|
+
// Add any Next.js-only rules here if needed in the future
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* React Hooks rules removed - Next.js includes built-in hooks support
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* Combined Next.js rules.
|
|
29
|
+
*
|
|
30
|
+
* Merges shared React rules with Next.js-specific rules.
|
|
31
|
+
*/
|
|
32
|
+
export const allNextjsRules = {
|
|
33
|
+
...nextjsReactRules,
|
|
34
|
+
...nextjsOnlyRules,
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Creates the main rules configuration for Next.js projects.
|
|
38
|
+
*
|
|
39
|
+
* Combines all rule categories. React Hooks rules are now provided
|
|
40
|
+
* by Next.js built-in configuration.
|
|
41
|
+
* @returns Combined rules configuration
|
|
42
|
+
*/
|
|
43
|
+
export const createNextjsRulesConfig = () => ({
|
|
44
|
+
rules: {
|
|
45
|
+
...allNextjsRules,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=rules.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* Settings and configuration objects for Next.js projects.
|
|
4
|
+
*
|
|
5
|
+
* This module provides settings that configure how ESLint plugins
|
|
6
|
+
* and rules behave in Next.js project contexts.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* React-specific settings for Next.js projects.
|
|
10
|
+
*
|
|
11
|
+
* Configures the React ESLint plugin to automatically detect
|
|
12
|
+
* the React version being used.
|
|
13
|
+
*/
|
|
14
|
+
export declare const nextjsReactSettings: {
|
|
15
|
+
readonly react: {
|
|
16
|
+
readonly version: "detect";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Next.js-specific settings.
|
|
21
|
+
*
|
|
22
|
+
* Configures Next.js ESLint plugins with the project root directory
|
|
23
|
+
* for proper context resolution.
|
|
24
|
+
* @param projectDir - The root directory of the Next.js project
|
|
25
|
+
* @returns ESLint settings object configured for Next.js projects
|
|
26
|
+
*/
|
|
27
|
+
export declare const createNextjsSettings: (projectDir: string) => {
|
|
28
|
+
readonly next: {
|
|
29
|
+
readonly rootDir: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Creates the complete settings configuration for Next.js projects.
|
|
34
|
+
*
|
|
35
|
+
* Combines React and Next.js settings into a single configuration
|
|
36
|
+
* object for easy application.
|
|
37
|
+
* @param projectDir - The root directory of the Next.js project
|
|
38
|
+
* @returns Combined settings configuration
|
|
39
|
+
*/
|
|
40
|
+
export declare const createNextjsSettingsConfig: (projectDir: string) => Linter.Config;
|
|
41
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings and configuration objects for Next.js projects.
|
|
3
|
+
*
|
|
4
|
+
* This module provides settings that configure how ESLint plugins
|
|
5
|
+
* and rules behave in Next.js project contexts.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* React-specific settings for Next.js projects.
|
|
9
|
+
*
|
|
10
|
+
* Configures the React ESLint plugin to automatically detect
|
|
11
|
+
* the React version being used.
|
|
12
|
+
*/
|
|
13
|
+
export const nextjsReactSettings = {
|
|
14
|
+
react: {
|
|
15
|
+
version: "detect"
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Next.js-specific settings.
|
|
20
|
+
*
|
|
21
|
+
* Configures Next.js ESLint plugins with the project root directory
|
|
22
|
+
* for proper context resolution.
|
|
23
|
+
* @param projectDir - The root directory of the Next.js project
|
|
24
|
+
* @returns ESLint settings object configured for Next.js projects
|
|
25
|
+
*/
|
|
26
|
+
export const createNextjsSettings = (projectDir) => ({
|
|
27
|
+
next: {
|
|
28
|
+
rootDir: projectDir,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Creates the complete settings configuration for Next.js projects.
|
|
33
|
+
*
|
|
34
|
+
* Combines React and Next.js settings into a single configuration
|
|
35
|
+
* object for easy application.
|
|
36
|
+
* @param projectDir - The root directory of the Next.js project
|
|
37
|
+
* @returns Combined settings configuration
|
|
38
|
+
*/
|
|
39
|
+
export const createNextjsSettingsConfig = (projectDir) => ({
|
|
40
|
+
settings: {
|
|
41
|
+
...nextjsReactSettings,
|
|
42
|
+
...createNextjsSettings(projectDir),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a type-aware ESLint configuration for Next.js projects.
|
|
4
|
+
*
|
|
5
|
+
* This configuration extends the base TypeScript configuration with Next.js-specific
|
|
6
|
+
* rules, React integration, and Next.js plugin support. It provides a comprehensive
|
|
7
|
+
* setup for modern Next.js development with TypeScript.
|
|
8
|
+
*
|
|
9
|
+
* Key features:
|
|
10
|
+
* - Next.js core-web-vitals and TypeScript integration
|
|
11
|
+
* - Automatic React plugin setup with fallback support
|
|
12
|
+
* - Next.js-optimized ignore patterns for generated files
|
|
13
|
+
* - React Hooks validation with exhaustive dependencies
|
|
14
|
+
* - TypeScript rule overrides for Next.js patterns
|
|
15
|
+
* - JSDoc requirement exemptions for React components
|
|
16
|
+
* - Graceful degradation when Next.js plugins are unavailable
|
|
17
|
+
*
|
|
18
|
+
* The configuration automatically detects Next.js plugin availability and falls back
|
|
19
|
+
* to standalone React configuration when needed, making it robust across different
|
|
20
|
+
* development environments.
|
|
21
|
+
* @param projectDir - The directory containing the TypeScript project
|
|
22
|
+
* @returns A comprehensive type-aware ESLint configuration for Next.js
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // In your eslint.config.mjs
|
|
26
|
+
* import { createTypeAwareNextConfig } from "@reasonabletech/eslint-config/next";
|
|
27
|
+
*
|
|
28
|
+
* export default createTypeAwareNextConfig(import.meta.dirname);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function createTypeAwareNextConfig(projectDir: string): Linter.Config[];
|
|
32
|
+
export default createTypeAwareNextConfig;
|
|
33
|
+
//# sourceMappingURL=next.d.ts.map
|
package/dist/src/next.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createTypeAwareConfig } from "./index.js";
|
|
2
|
+
import { createNextjsConfigs } from "./next/config.js";
|
|
3
|
+
import { createNextjsPluginConfig } from "./next/plugins.js";
|
|
4
|
+
import { stripPluginConfigs } from "./shared/plugin-utils.js";
|
|
5
|
+
/**
|
|
6
|
+
* Creates a type-aware ESLint configuration for Next.js projects.
|
|
7
|
+
*
|
|
8
|
+
* This configuration extends the base TypeScript configuration with Next.js-specific
|
|
9
|
+
* rules, React integration, and Next.js plugin support. It provides a comprehensive
|
|
10
|
+
* setup for modern Next.js development with TypeScript.
|
|
11
|
+
*
|
|
12
|
+
* Key features:
|
|
13
|
+
* - Next.js core-web-vitals and TypeScript integration
|
|
14
|
+
* - Automatic React plugin setup with fallback support
|
|
15
|
+
* - Next.js-optimized ignore patterns for generated files
|
|
16
|
+
* - React Hooks validation with exhaustive dependencies
|
|
17
|
+
* - TypeScript rule overrides for Next.js patterns
|
|
18
|
+
* - JSDoc requirement exemptions for React components
|
|
19
|
+
* - Graceful degradation when Next.js plugins are unavailable
|
|
20
|
+
*
|
|
21
|
+
* The configuration automatically detects Next.js plugin availability and falls back
|
|
22
|
+
* to standalone React configuration when needed, making it robust across different
|
|
23
|
+
* development environments.
|
|
24
|
+
* @param projectDir - The directory containing the TypeScript project
|
|
25
|
+
* @returns A comprehensive type-aware ESLint configuration for Next.js
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // In your eslint.config.mjs
|
|
29
|
+
* import { createTypeAwareNextConfig } from "@reasonabletech/eslint-config/next";
|
|
30
|
+
*
|
|
31
|
+
* export default createTypeAwareNextConfig(import.meta.dirname);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export function createTypeAwareNextConfig(projectDir) {
|
|
35
|
+
const baseConfigs = createTypeAwareConfig(projectDir);
|
|
36
|
+
const pluginConfig = createNextjsPluginConfig(projectDir);
|
|
37
|
+
const pluginEntries = pluginConfig.usesFallback
|
|
38
|
+
? pluginConfig.fallbackConfigs
|
|
39
|
+
: pluginConfig.nextConfigs;
|
|
40
|
+
const combinedConfigs = [
|
|
41
|
+
...baseConfigs,
|
|
42
|
+
...pluginEntries,
|
|
43
|
+
// Next.js-specific configurations (includes strict TypeScript rules)
|
|
44
|
+
...createNextjsConfigs(projectDir),
|
|
45
|
+
];
|
|
46
|
+
return dedupePlugins(combinedConfigs);
|
|
47
|
+
}
|
|
48
|
+
// Export the function as the default export
|
|
49
|
+
export default createTypeAwareNextConfig;
|
|
50
|
+
function dedupePlugins(configs) {
|
|
51
|
+
const seen = new Set();
|
|
52
|
+
return configs.map((config) => {
|
|
53
|
+
if (config.plugins == null) {
|
|
54
|
+
return config;
|
|
55
|
+
}
|
|
56
|
+
const entries = Object.entries(config.plugins).filter(([name]) => {
|
|
57
|
+
if (seen.has(name)) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
seen.add(name);
|
|
61
|
+
return true;
|
|
62
|
+
});
|
|
63
|
+
if (entries.length === 0) {
|
|
64
|
+
const rest = { ...config };
|
|
65
|
+
delete rest.plugins;
|
|
66
|
+
return rest;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
...config,
|
|
70
|
+
plugins: Object.fromEntries(entries.map(([name, plugin]) => [name, stripPluginConfigs(plugin)])),
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=next.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReasonableTech ESLint plugin
|
|
3
|
+
*
|
|
4
|
+
* Aggregates all custom ESLint rules into a single plugin object for
|
|
5
|
+
* registration in flat config via `plugins: { "@reasonabletech": reasonableTechPlugin }`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const reasonableTechPlugin: {
|
|
8
|
+
meta: {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string;
|
|
11
|
+
};
|
|
12
|
+
rules: {
|
|
13
|
+
"no-as-any": import("@typescript-eslint/utils/ts-eslint").RuleModule<"asAny" | "angleAny" | "doubleCast", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
"no-barrel-exports": import("@typescript-eslint/utils/ts-eslint").RuleModule<"barrelExport", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
17
|
+
name: string;
|
|
18
|
+
};
|
|
19
|
+
"no-constructor-instantiation": import("@typescript-eslint/utils/ts-eslint").RuleModule<"constructorInstantiation", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
20
|
+
name: string;
|
|
21
|
+
};
|
|
22
|
+
"no-dependency-bundling": import("@typescript-eslint/utils/ts-eslint").RuleModule<"dependencyBundle", [{
|
|
23
|
+
docBaseUrl: string;
|
|
24
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
25
|
+
name: string;
|
|
26
|
+
};
|
|
27
|
+
"no-error-message-parsing": import("@typescript-eslint/utils/ts-eslint").RuleModule<"stringMethod" | "directComparison" | "regexTest", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
28
|
+
name: string;
|
|
29
|
+
};
|
|
30
|
+
"no-inline-error-unions": import("@typescript-eslint/utils/ts-eslint").RuleModule<"inlineUnion", [{
|
|
31
|
+
resultTypeName: string;
|
|
32
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
33
|
+
name: string;
|
|
34
|
+
};
|
|
35
|
+
"no-linter-disabling": import("@typescript-eslint/utils/ts-eslint").RuleModule<"noDisable" | "noJustification" | "specificRule", [import("./custom-rules/code-quality.js").NoLinterDisablingOptions], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
36
|
+
name: string;
|
|
37
|
+
};
|
|
38
|
+
"no-null-undefined-checks": import("@typescript-eslint/utils/ts-eslint").RuleModule<"checksBoth", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
39
|
+
name: string;
|
|
40
|
+
};
|
|
41
|
+
"use-result-helpers": import("@typescript-eslint/utils/ts-eslint").RuleModule<"useOkHelper" | "useErrHelper", [{
|
|
42
|
+
docBaseUrl: string;
|
|
43
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
44
|
+
name: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReasonableTech ESLint plugin
|
|
3
|
+
*
|
|
4
|
+
* Aggregates all custom ESLint rules into a single plugin object for
|
|
5
|
+
* registration in flat config via `plugins: { "@reasonabletech": reasonableTechPlugin }`.
|
|
6
|
+
*/
|
|
7
|
+
import { noDependencyBundlingRule, noConstructorInstantiationRule, } from "./custom-rules/architecture-patterns.js";
|
|
8
|
+
import { noLinterDisablingRule, noBarrelExportsRule, } from "./custom-rules/code-quality.js";
|
|
9
|
+
import { noErrorMessageParsingRule, noInlineErrorUnionsRule, } from "./custom-rules/error-handling.js";
|
|
10
|
+
import { noNullUndefinedChecksRule } from "./custom-rules/null-undefined-checks.js";
|
|
11
|
+
import { useResultHelpersRule } from "./custom-rules/platform-conventions.js";
|
|
12
|
+
import { noAsAnyRule } from "./custom-rules/type-safety.js";
|
|
13
|
+
export const reasonableTechPlugin = {
|
|
14
|
+
meta: {
|
|
15
|
+
name: "@reasonabletech/eslint-plugin",
|
|
16
|
+
version: "0.1.0",
|
|
17
|
+
},
|
|
18
|
+
rules: {
|
|
19
|
+
"no-as-any": noAsAnyRule,
|
|
20
|
+
"no-barrel-exports": noBarrelExportsRule,
|
|
21
|
+
"no-constructor-instantiation": noConstructorInstantiationRule,
|
|
22
|
+
"no-dependency-bundling": noDependencyBundlingRule,
|
|
23
|
+
"no-error-message-parsing": noErrorMessageParsingRule,
|
|
24
|
+
"no-inline-error-unions": noInlineErrorUnionsRule,
|
|
25
|
+
"no-linter-disabling": noLinterDisablingRule,
|
|
26
|
+
"no-null-undefined-checks": noNullUndefinedChecksRule,
|
|
27
|
+
"use-result-helpers": useResultHelpersRule,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration builders for React projects.
|
|
4
|
+
*
|
|
5
|
+
* This module combines React plugins, rules, and file-specific
|
|
6
|
+
* configurations into complete ESLint configurations.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Base React rules configuration.
|
|
10
|
+
*
|
|
11
|
+
* Applies all React rules (shared and React-specific) to the
|
|
12
|
+
* ESLint configuration.
|
|
13
|
+
* @returns ESLint configuration object with React rules
|
|
14
|
+
*/
|
|
15
|
+
export declare const createReactRulesConfig: () => Linter.Config;
|
|
16
|
+
/**
|
|
17
|
+
* Complete React configuration builder.
|
|
18
|
+
*
|
|
19
|
+
* Combines all React-specific configurations including plugins,
|
|
20
|
+
* rules, and file-specific overrides into a comprehensive
|
|
21
|
+
* configuration array.
|
|
22
|
+
*
|
|
23
|
+
* Configuration includes:
|
|
24
|
+
* - React and React Hooks plugins with browser globals
|
|
25
|
+
* - All React rules (core, hooks, TypeScript overrides)
|
|
26
|
+
* - JSDoc rule exemptions for React component files
|
|
27
|
+
* @returns Array of ESLint configurations for React projects
|
|
28
|
+
*/
|
|
29
|
+
export declare const createReactConfigs: () => Linter.Config[];
|
|
30
|
+
//# sourceMappingURL=config.d.ts.map
|