@yasainet/eslint 0.0.21 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -8
- package/package.json +1 -1
- package/src/common/constants.mjs +3 -3
- package/src/common/imports.mjs +2 -2
- package/src/common/index.mjs +1 -1
- package/src/common/jsdoc.mjs +1 -1
- package/src/common/layers.mjs +1 -1
- package/src/common/local-plugins/action-handle-service.mjs +1 -3
- package/src/common/local-plugins/import-path-style.mjs +3 -5
- package/src/common/local-plugins/index.mjs +1 -1
- package/src/common/naming.mjs +52 -3
- package/src/common/plugins.mjs +1 -1
- package/src/common/rules.mjs +1 -1
- package/src/deno/index.mjs +1 -1
- package/src/next/directives.mjs +1 -1
- package/src/next/imports.mjs +1 -1
- package/src/next/index.mjs +1 -1
- package/src/next/naming.mjs +1 -1
- package/src/node/index.mjs +1 -1
package/README.md
CHANGED
|
@@ -111,11 +111,3 @@ git push --tags
|
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
3. GitHub Actions will automatically publish to npm
|
|
114
|
-
|
|
115
|
-
### With lazygit
|
|
116
|
-
|
|
117
|
-
1. Stage and commit in lazygit
|
|
118
|
-
2. Select the commit, press `T` to create a tag (e.g. `v1.0.0`)
|
|
119
|
-
3. Press `P` to push the commit
|
|
120
|
-
4. Switch to the Tags panel (`]`), select the tag, and press `P` to push it
|
|
121
|
-
5. GitHub Actions will automatically publish to npm
|
package/package.json
CHANGED
package/src/common/constants.mjs
CHANGED
|
@@ -22,12 +22,12 @@ const PROJECT_ROOT = findProjectRoot();
|
|
|
22
22
|
|
|
23
23
|
const EXCLUDE_LIST = ["proxy.lib.ts"];
|
|
24
24
|
|
|
25
|
-
/**
|
|
25
|
+
/** Extract the base name from a .ts filename by stripping all extensions. */
|
|
26
26
|
function baseName(filename) {
|
|
27
27
|
return filename.replace(/\..*$/, "");
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/**
|
|
30
|
+
/** Scan lib directory derived from featureRoot and build prefix-to-lib-relative-path mapping. */
|
|
31
31
|
export function generatePrefixLibMapping(featureRoot) {
|
|
32
32
|
const libRoot = featureRoot.replace(/features$/, "lib");
|
|
33
33
|
const libDir = path.join(PROJECT_ROOT, libRoot);
|
|
@@ -67,7 +67,7 @@ export function generatePrefixLibMapping(featureRoot) {
|
|
|
67
67
|
return mapping;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
/**
|
|
70
|
+
/** Build glob patterns scoped to the given feature root. */
|
|
71
71
|
export const featuresGlob = (featureRoot, subpath) => [
|
|
72
72
|
`${featureRoot}/${subpath}`,
|
|
73
73
|
];
|
package/src/common/imports.mjs
CHANGED
|
@@ -110,7 +110,7 @@ function makeConfig(name, files, ...patternArrays) {
|
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
/**
|
|
113
|
+
/** Next.js-only: restrict @/lib imports to repositories. */
|
|
114
114
|
export const libBoundaryConfigs = [
|
|
115
115
|
{
|
|
116
116
|
name: "imports/lib-boundary",
|
|
@@ -128,7 +128,7 @@ export const libBoundaryConfigs = [
|
|
|
128
128
|
},
|
|
129
129
|
];
|
|
130
130
|
|
|
131
|
-
/**
|
|
131
|
+
/** Scope import restriction rules to the given feature root. */
|
|
132
132
|
export function createImportsConfigs(
|
|
133
133
|
featureRoot,
|
|
134
134
|
prefixLibMapping,
|
package/src/common/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { createLayersConfigs } from "./layers.mjs";
|
|
|
5
5
|
import { createNamingConfigs } from "./naming.mjs";
|
|
6
6
|
import { rulesConfigs } from "./rules.mjs";
|
|
7
7
|
|
|
8
|
-
/**
|
|
8
|
+
/** Build common configs scoped to the given feature root. */
|
|
9
9
|
export function createCommonConfigs(
|
|
10
10
|
featureRoot,
|
|
11
11
|
{ banAliasImports = false } = {},
|
package/src/common/jsdoc.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import jsdocPlugin from "eslint-plugin-jsdoc";
|
|
|
2
2
|
|
|
3
3
|
import { featuresGlob } from "./constants.mjs";
|
|
4
4
|
|
|
5
|
-
/**
|
|
5
|
+
/** Scope JSDoc rules to the given feature root. */
|
|
6
6
|
export function createJsdocConfigs(featureRoot) {
|
|
7
7
|
return [
|
|
8
8
|
{
|
package/src/common/layers.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Enforce import path style within features:
|
|
5
5
|
* - Same-feature imports must use relative paths
|
|
6
6
|
* - Cross-feature imports must use @/ alias
|
|
7
7
|
*/
|
|
@@ -37,11 +37,9 @@ export const importPathStyleRule = {
|
|
|
37
37
|
const featureName = afterRoot.split("/")[0];
|
|
38
38
|
if (!featureName) return {};
|
|
39
39
|
|
|
40
|
-
// Absolute path of the current feature directory
|
|
41
40
|
const featureDir =
|
|
42
41
|
filename.slice(0, rootIdx + rootSep.length) + featureName;
|
|
43
42
|
|
|
44
|
-
// Alias prefix for same-feature: @/features/{featureName}
|
|
45
43
|
const aliasBase = featureRoot.replace(/^src\//, "");
|
|
46
44
|
const sameFeaturePrefix = `@/${aliasBase}/${featureName}/`;
|
|
47
45
|
const sameFeatureExact = `@/${aliasBase}/${featureName}`;
|
|
@@ -50,7 +48,7 @@ export const importPathStyleRule = {
|
|
|
50
48
|
if (!source || typeof source.value !== "string") return;
|
|
51
49
|
const importPath = source.value;
|
|
52
50
|
|
|
53
|
-
//
|
|
51
|
+
// Same-feature alias should be a relative path for consistency.
|
|
54
52
|
if (
|
|
55
53
|
importPath.startsWith(sameFeaturePrefix) ||
|
|
56
54
|
importPath === sameFeatureExact
|
|
@@ -63,7 +61,7 @@ export const importPathStyleRule = {
|
|
|
63
61
|
return;
|
|
64
62
|
}
|
|
65
63
|
|
|
66
|
-
//
|
|
64
|
+
// Cross-feature relative path should use @/ alias for clarity.
|
|
67
65
|
if (importPath.startsWith(".")) {
|
|
68
66
|
const resolved = path.resolve(path.dirname(filename), importPath);
|
|
69
67
|
if (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { actionHandleServiceRule } from "./action-handle-service.mjs";
|
|
2
2
|
import { importPathStyleRule } from "./import-path-style.mjs";
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/** Single plugin object to avoid ESLint "Cannot redefine plugin" errors. */
|
|
5
5
|
export const localPlugin = {
|
|
6
6
|
rules: {
|
|
7
7
|
"action-handle-service": actionHandleServiceRule,
|
package/src/common/naming.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { featuresGlob } from "./constants.mjs";
|
|
|
2
2
|
import { localPlugin } from "./local-plugins/index.mjs";
|
|
3
3
|
import { checkFile } from "./plugins.mjs";
|
|
4
4
|
|
|
5
|
-
/**
|
|
5
|
+
/** Scope naming rules to the given feature root. */
|
|
6
6
|
export function createNamingConfigs(featureRoot, prefixLibMapping) {
|
|
7
7
|
const prefixPattern = `@(${Object.keys(prefixLibMapping).join("|")})`;
|
|
8
8
|
const sharedPrefixPattern = `@(shared|${Object.keys(prefixLibMapping).join("|")})`;
|
|
@@ -11,6 +11,7 @@ export function createNamingConfigs(featureRoot, prefixLibMapping) {
|
|
|
11
11
|
{
|
|
12
12
|
name: "naming/services",
|
|
13
13
|
files: featuresGlob(featureRoot, "**/services/*.ts"),
|
|
14
|
+
ignores: featuresGlob(featureRoot, "shared/services/*.ts"),
|
|
14
15
|
plugins: { "check-file": checkFile },
|
|
15
16
|
rules: {
|
|
16
17
|
"check-file/filename-naming-convention": [
|
|
@@ -19,9 +20,21 @@ export function createNamingConfigs(featureRoot, prefixLibMapping) {
|
|
|
19
20
|
],
|
|
20
21
|
},
|
|
21
22
|
},
|
|
23
|
+
{
|
|
24
|
+
name: "naming/services-shared",
|
|
25
|
+
files: featuresGlob(featureRoot, "shared/services/*.ts"),
|
|
26
|
+
plugins: { "check-file": checkFile },
|
|
27
|
+
rules: {
|
|
28
|
+
"check-file/filename-naming-convention": [
|
|
29
|
+
"error",
|
|
30
|
+
{ "**/*.ts": `${sharedPrefixPattern}.service` },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
22
34
|
{
|
|
23
35
|
name: "naming/repositories",
|
|
24
36
|
files: featuresGlob(featureRoot, "**/repositories/*.ts"),
|
|
37
|
+
ignores: featuresGlob(featureRoot, "shared/repositories/*.ts"),
|
|
25
38
|
plugins: { "check-file": checkFile },
|
|
26
39
|
rules: {
|
|
27
40
|
"check-file/filename-naming-convention": [
|
|
@@ -30,6 +43,17 @@ export function createNamingConfigs(featureRoot, prefixLibMapping) {
|
|
|
30
43
|
],
|
|
31
44
|
},
|
|
32
45
|
},
|
|
46
|
+
{
|
|
47
|
+
name: "naming/repositories-shared",
|
|
48
|
+
files: featuresGlob(featureRoot, "shared/repositories/*.ts"),
|
|
49
|
+
plugins: { "check-file": checkFile },
|
|
50
|
+
rules: {
|
|
51
|
+
"check-file/filename-naming-convention": [
|
|
52
|
+
"error",
|
|
53
|
+
{ "**/*.ts": `${sharedPrefixPattern}.repo` },
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
},
|
|
33
57
|
];
|
|
34
58
|
|
|
35
59
|
configs.push(
|
|
@@ -59,12 +83,25 @@ export function createNamingConfigs(featureRoot, prefixLibMapping) {
|
|
|
59
83
|
},
|
|
60
84
|
{
|
|
61
85
|
name: "naming/schemas",
|
|
62
|
-
files: featuresGlob(featureRoot, "
|
|
86
|
+
files: featuresGlob(featureRoot, "*/schemas/*.schema.ts"),
|
|
87
|
+
ignores: featuresGlob(featureRoot, "shared/schemas/*.ts"),
|
|
63
88
|
plugins: { "check-file": checkFile },
|
|
64
89
|
rules: {
|
|
65
90
|
"check-file/filename-naming-convention": [
|
|
66
91
|
"error",
|
|
67
|
-
{ "
|
|
92
|
+
{ "**/*/schemas/*.ts": "<1>" },
|
|
93
|
+
{ ignoreMiddleExtensions: true },
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "naming/schemas-shared",
|
|
99
|
+
files: featuresGlob(featureRoot, "shared/schemas/*.ts"),
|
|
100
|
+
plugins: { "check-file": checkFile },
|
|
101
|
+
rules: {
|
|
102
|
+
"check-file/filename-naming-convention": [
|
|
103
|
+
"error",
|
|
104
|
+
{ "**/*.ts": `${sharedPrefixPattern}.schema` },
|
|
68
105
|
],
|
|
69
106
|
},
|
|
70
107
|
},
|
|
@@ -119,6 +156,7 @@ export function createNamingConfigs(featureRoot, prefixLibMapping) {
|
|
|
119
156
|
{
|
|
120
157
|
name: "naming/actions",
|
|
121
158
|
files: featuresGlob(featureRoot, "**/actions/*.ts"),
|
|
159
|
+
ignores: featuresGlob(featureRoot, "shared/actions/*.ts"),
|
|
122
160
|
plugins: { "check-file": checkFile },
|
|
123
161
|
rules: {
|
|
124
162
|
"check-file/filename-naming-convention": [
|
|
@@ -127,6 +165,17 @@ export function createNamingConfigs(featureRoot, prefixLibMapping) {
|
|
|
127
165
|
],
|
|
128
166
|
},
|
|
129
167
|
},
|
|
168
|
+
{
|
|
169
|
+
name: "naming/actions-shared",
|
|
170
|
+
files: featuresGlob(featureRoot, "shared/actions/*.ts"),
|
|
171
|
+
plugins: { "check-file": checkFile },
|
|
172
|
+
rules: {
|
|
173
|
+
"check-file/filename-naming-convention": [
|
|
174
|
+
"error",
|
|
175
|
+
{ "**/*.ts": `${sharedPrefixPattern}.action` },
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
},
|
|
130
179
|
{
|
|
131
180
|
name: "naming/actions-export",
|
|
132
181
|
files: featuresGlob(featureRoot, "**/actions/*.ts"),
|
package/src/common/plugins.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import checkFile from "eslint-plugin-check-file";
|
|
|
3
3
|
import jsdocPlugin from "eslint-plugin-jsdoc";
|
|
4
4
|
import simpleImportSortPlugin from "eslint-plugin-simple-import-sort";
|
|
5
5
|
|
|
6
|
-
/**
|
|
6
|
+
/** Shared plugin instances used across ESLint configs. */
|
|
7
7
|
export const plugins = {
|
|
8
8
|
"@stylistic": stylistic,
|
|
9
9
|
"check-file": checkFile,
|
package/src/common/rules.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import tseslint from "typescript-eslint";
|
|
|
2
2
|
|
|
3
3
|
import { simpleImportSortPlugin, stylistic } from "./plugins.mjs";
|
|
4
4
|
|
|
5
|
-
/**
|
|
5
|
+
/** Base rule configs for code style and TypeScript checks. */
|
|
6
6
|
export const rulesConfigs = [
|
|
7
7
|
{
|
|
8
8
|
name: "rules/shared",
|
package/src/deno/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createCommonConfigs } from "../common/index.mjs";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/** Deno ESLint flat config entry point. */
|
|
4
4
|
export const eslintConfig = [
|
|
5
5
|
...createCommonConfigs("supabase/functions/features", {
|
|
6
6
|
banAliasImports: true,
|
package/src/next/directives.mjs
CHANGED
package/src/next/imports.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { localPlugin } from "../common/local-plugins/index.mjs";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/** Enforce relative paths within same feature, @/ for cross-feature in Next.js. */
|
|
4
4
|
export const importPathStyleConfigs = [
|
|
5
5
|
{
|
|
6
6
|
name: "imports/path-style",
|
package/src/next/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { directivesConfigs } from "./directives.mjs";
|
|
|
5
5
|
import { importPathStyleConfigs } from "./imports.mjs";
|
|
6
6
|
import { namingConfigs } from "./naming.mjs";
|
|
7
7
|
|
|
8
|
-
/**
|
|
8
|
+
/** Next.js ESLint flat config entry point. */
|
|
9
9
|
export const eslintConfig = [
|
|
10
10
|
...createCommonConfigs("src/features"),
|
|
11
11
|
...libBoundaryConfigs,
|
package/src/next/naming.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { checkFile } from "../common/plugins.mjs";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/** Next.js-specific naming convention configs for hooks and components. */
|
|
4
4
|
export const namingConfigs = [
|
|
5
5
|
{
|
|
6
6
|
name: "naming/hooks",
|
package/src/node/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createCommonConfigs } from "../common/index.mjs";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/** Node.js ESLint flat config entry point. */
|
|
4
4
|
export const eslintConfig = [
|
|
5
5
|
...createCommonConfigs("scripts/features", { banAliasImports: true }),
|
|
6
6
|
];
|