@yasainet/eslint 0.0.28 → 0.0.30
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/package.json +1 -1
- package/src/common/entry-points.mjs +20 -0
- package/src/common/index.mjs +2 -1
- package/src/common/naming.mjs +19 -0
- package/src/deno/index.mjs +7 -0
- package/src/next/index.mjs +6 -0
- package/src/node/index.mjs +6 -0
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Ban `import * as` at entry points. */
|
|
2
|
+
export function createEntryPointConfigs(entryPointFiles, entryPointIgnores = []) {
|
|
3
|
+
return [
|
|
4
|
+
{
|
|
5
|
+
name: "entry-points/no-namespace-import",
|
|
6
|
+
files: entryPointFiles,
|
|
7
|
+
ignores: entryPointIgnores,
|
|
8
|
+
rules: {
|
|
9
|
+
"no-restricted-syntax": [
|
|
10
|
+
"error",
|
|
11
|
+
{
|
|
12
|
+
selector: "ImportDeclaration:has(ImportNamespaceSpecifier)",
|
|
13
|
+
message:
|
|
14
|
+
"Entry points must use named imports instead of `import * as`. This makes dependencies explicit.",
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
}
|
package/src/common/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { generatePrefixLibMapping } from "./constants.mjs";
|
|
|
2
2
|
import { createImportsConfigs } from "./imports.mjs";
|
|
3
3
|
import { createJsdocConfigs } from "./jsdoc.mjs";
|
|
4
4
|
import { createLayersConfigs } from "./layers.mjs";
|
|
5
|
-
import { createNamingConfigs } from "./naming.mjs";
|
|
5
|
+
import { createLibNamingConfigs, createNamingConfigs } from "./naming.mjs";
|
|
6
6
|
import { rulesConfigs } from "./rules.mjs";
|
|
7
7
|
|
|
8
8
|
/** Build common configs scoped to the given feature root. */
|
|
@@ -14,6 +14,7 @@ export function createCommonConfigs(
|
|
|
14
14
|
return [
|
|
15
15
|
...rulesConfigs,
|
|
16
16
|
...createNamingConfigs(featureRoot, prefixLibMapping),
|
|
17
|
+
...createLibNamingConfigs(featureRoot),
|
|
17
18
|
...createLayersConfigs(featureRoot),
|
|
18
19
|
...createImportsConfigs(featureRoot, prefixLibMapping, { banAliasImports }),
|
|
19
20
|
...createJsdocConfigs(featureRoot),
|
package/src/common/naming.mjs
CHANGED
|
@@ -2,6 +2,25 @@ import { featuresGlob } from "./constants.mjs";
|
|
|
2
2
|
import { localPlugin } from "./local-plugins/index.mjs";
|
|
3
3
|
import { checkFile } from "./plugins.mjs";
|
|
4
4
|
|
|
5
|
+
/** Scope lib naming rules to the lib root derived from the given feature root. */
|
|
6
|
+
export function createLibNamingConfigs(featureRoot) {
|
|
7
|
+
const libRoot = featureRoot.replace(/features$/, "lib");
|
|
8
|
+
return [
|
|
9
|
+
{
|
|
10
|
+
name: "naming/lib",
|
|
11
|
+
files: [`${libRoot}/**/*.ts`],
|
|
12
|
+
ignores: [`${libRoot}/**/*.type.ts`],
|
|
13
|
+
plugins: { "check-file": checkFile },
|
|
14
|
+
rules: {
|
|
15
|
+
"check-file/filename-naming-convention": [
|
|
16
|
+
"error",
|
|
17
|
+
{ "**/*.ts": "*.lib" },
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
|
|
5
24
|
/** Scope naming rules to the given feature root. */
|
|
6
25
|
export function createNamingConfigs(featureRoot, prefixLibMapping) {
|
|
7
26
|
const prefixes = Object.keys(prefixLibMapping);
|
package/src/deno/index.mjs
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import { createEntryPointConfigs } from "../common/entry-points.mjs";
|
|
1
2
|
import { createCommonConfigs } from "../common/index.mjs";
|
|
2
3
|
import { denoImportsConfigs } from "./imports.mjs";
|
|
3
4
|
|
|
4
5
|
const FEATURE_ROOT = "supabase/functions/_features";
|
|
5
6
|
|
|
7
|
+
const denoEntryPointConfigs = createEntryPointConfigs(
|
|
8
|
+
["supabase/functions/**/*.ts"],
|
|
9
|
+
["supabase/functions/_*/**"],
|
|
10
|
+
);
|
|
11
|
+
|
|
6
12
|
/** Deno ESLint flat config entry point. */
|
|
7
13
|
export const eslintConfig = [
|
|
8
14
|
...createCommonConfigs(FEATURE_ROOT, { banAliasImports: true }),
|
|
9
15
|
...denoImportsConfigs,
|
|
16
|
+
...denoEntryPointConfigs,
|
|
10
17
|
];
|
package/src/next/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createEntryPointConfigs } from "../common/entry-points.mjs";
|
|
1
2
|
import { createCommonConfigs } from "../common/index.mjs";
|
|
2
3
|
import { libBoundaryConfigs } from "../common/imports.mjs";
|
|
3
4
|
|
|
@@ -5,6 +6,10 @@ import { directivesConfigs } from "./directives.mjs";
|
|
|
5
6
|
import { importPathStyleConfigs } from "./imports.mjs";
|
|
6
7
|
import { namingConfigs } from "./naming.mjs";
|
|
7
8
|
|
|
9
|
+
const nextEntryPointConfigs = createEntryPointConfigs(
|
|
10
|
+
["src/app/**/*.ts", "src/app/**/*.tsx"],
|
|
11
|
+
);
|
|
12
|
+
|
|
8
13
|
/** Next.js ESLint flat config entry point. */
|
|
9
14
|
export const eslintConfig = [
|
|
10
15
|
...createCommonConfigs("src/features"),
|
|
@@ -12,4 +17,5 @@ export const eslintConfig = [
|
|
|
12
17
|
...namingConfigs,
|
|
13
18
|
...directivesConfigs,
|
|
14
19
|
...importPathStyleConfigs,
|
|
20
|
+
...nextEntryPointConfigs,
|
|
15
21
|
];
|
package/src/node/index.mjs
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { createEntryPointConfigs } from "../common/entry-points.mjs";
|
|
1
2
|
import { createCommonConfigs } from "../common/index.mjs";
|
|
2
3
|
|
|
4
|
+
const nodeEntryPointConfigs = createEntryPointConfigs(
|
|
5
|
+
["scripts/commands/*.ts"],
|
|
6
|
+
);
|
|
7
|
+
|
|
3
8
|
/** Node.js ESLint flat config entry point. */
|
|
4
9
|
export const eslintConfig = [
|
|
5
10
|
...createCommonConfigs("scripts/features", { banAliasImports: true }),
|
|
11
|
+
...nodeEntryPointConfigs,
|
|
6
12
|
];
|