@yasainet/eslint 0.0.21 → 0.0.22

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 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yasainet/eslint",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "ESLint",
5
5
  "type": "module",
6
6
  "exports": {
@@ -22,12 +22,12 @@ const PROJECT_ROOT = findProjectRoot();
22
22
 
23
23
  const EXCLUDE_LIST = ["proxy.lib.ts"];
24
24
 
25
- /** @description Extract the base name from a .ts filename by stripping all extensions. */
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
- /** @description Scan lib directory derived from featureRoot and build prefix-to-lib-relative-path mapping */
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
- /** @description Build glob patterns scoped to the given feature root */
70
+ /** Build glob patterns scoped to the given feature root. */
71
71
  export const featuresGlob = (featureRoot, subpath) => [
72
72
  `${featureRoot}/${subpath}`,
73
73
  ];
@@ -110,7 +110,7 @@ function makeConfig(name, files, ...patternArrays) {
110
110
  };
111
111
  }
112
112
 
113
- /** @description Next.js-only: restrict @/lib imports to repositories */
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
- /** @description Scope import restriction rules to the given feature root */
131
+ /** Scope import restriction rules to the given feature root. */
132
132
  export function createImportsConfigs(
133
133
  featureRoot,
134
134
  prefixLibMapping,
@@ -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
- /** @description Build common configs scoped to the given feature root */
8
+ /** Build common configs scoped to the given feature root. */
9
9
  export function createCommonConfigs(
10
10
  featureRoot,
11
11
  { banAliasImports = false } = {},
@@ -2,7 +2,7 @@ import jsdocPlugin from "eslint-plugin-jsdoc";
2
2
 
3
3
  import { featuresGlob } from "./constants.mjs";
4
4
 
5
- /** @description Scope JSDoc rules to the given feature root */
5
+ /** Scope JSDoc rules to the given feature root. */
6
6
  export function createJsdocConfigs(featureRoot) {
7
7
  return [
8
8
  {
@@ -1,4 +1,4 @@
1
- /** @description Scope layer rules to the given feature root */
1
+ /** Scope layer rules to the given feature root. */
2
2
  export function createLayersConfigs(featureRoot) {
3
3
  const loggerSelector = "CallExpression[callee.object.name='logger']";
4
4
  const loggerMessage =
@@ -1,6 +1,4 @@
1
- /**
2
- * @description In *.action.ts, `handleXxx` must call the service method `*.xxx()`.
3
- */
1
+ /** In *.action.ts, handleXxx must call the service method *.xxx(). */
4
2
  export const actionHandleServiceRule = {
5
3
  meta: {
6
4
  type: "problem",
@@ -1,7 +1,7 @@
1
1
  import path from "path";
2
2
 
3
3
  /**
4
- * @description Enforce import path style within features:
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
- // Case 1: @/features/{same-feature}/... use relative path
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
- // Case 2: relative path that exits current feature use @/
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
- /** @description Shared local plugin object to avoid ESLint "Cannot redefine plugin" errors */
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,
@@ -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
- /** @description Scope naming rules to the given feature root */
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(
@@ -60,6 +84,7 @@ export function createNamingConfigs(featureRoot, prefixLibMapping) {
60
84
  {
61
85
  name: "naming/schemas",
62
86
  files: featuresGlob(featureRoot, "**/schemas/*.ts"),
87
+ ignores: featuresGlob(featureRoot, "shared/schemas/*.ts"),
63
88
  plugins: { "check-file": checkFile },
64
89
  rules: {
65
90
  "check-file/filename-naming-convention": [
@@ -68,6 +93,17 @@ export function createNamingConfigs(featureRoot, prefixLibMapping) {
68
93
  ],
69
94
  },
70
95
  },
96
+ {
97
+ name: "naming/schemas-shared",
98
+ files: featuresGlob(featureRoot, "shared/schemas/*.ts"),
99
+ plugins: { "check-file": checkFile },
100
+ rules: {
101
+ "check-file/filename-naming-convention": [
102
+ "error",
103
+ { "**/*.ts": `${sharedPrefixPattern}.schema` },
104
+ ],
105
+ },
106
+ },
71
107
  {
72
108
  name: "naming/utils",
73
109
  files: featuresGlob(featureRoot, "*/utils/*.util.ts"),
@@ -119,6 +155,7 @@ export function createNamingConfigs(featureRoot, prefixLibMapping) {
119
155
  {
120
156
  name: "naming/actions",
121
157
  files: featuresGlob(featureRoot, "**/actions/*.ts"),
158
+ ignores: featuresGlob(featureRoot, "shared/actions/*.ts"),
122
159
  plugins: { "check-file": checkFile },
123
160
  rules: {
124
161
  "check-file/filename-naming-convention": [
@@ -127,6 +164,17 @@ export function createNamingConfigs(featureRoot, prefixLibMapping) {
127
164
  ],
128
165
  },
129
166
  },
167
+ {
168
+ name: "naming/actions-shared",
169
+ files: featuresGlob(featureRoot, "shared/actions/*.ts"),
170
+ plugins: { "check-file": checkFile },
171
+ rules: {
172
+ "check-file/filename-naming-convention": [
173
+ "error",
174
+ { "**/*.ts": `${sharedPrefixPattern}.action` },
175
+ ],
176
+ },
177
+ },
130
178
  {
131
179
  name: "naming/actions-export",
132
180
  files: featuresGlob(featureRoot, "**/actions/*.ts"),
@@ -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
- /** @description Shared plugin instances used across ESLint configs */
6
+ /** Shared plugin instances used across ESLint configs. */
7
7
  export const plugins = {
8
8
  "@stylistic": stylistic,
9
9
  "check-file": checkFile,
@@ -2,7 +2,7 @@ import tseslint from "typescript-eslint";
2
2
 
3
3
  import { simpleImportSortPlugin, stylistic } from "./plugins.mjs";
4
4
 
5
- /** @description Base rule configs for code style and TypeScript checks */
5
+ /** Base rule configs for code style and TypeScript checks. */
6
6
  export const rulesConfigs = [
7
7
  {
8
8
  name: "rules/shared",
@@ -1,6 +1,6 @@
1
1
  import { createCommonConfigs } from "../common/index.mjs";
2
2
 
3
- /** @description Deno ESLint flat config entry point */
3
+ /** Deno ESLint flat config entry point. */
4
4
  export const eslintConfig = [
5
5
  ...createCommonConfigs("supabase/functions/features", {
6
6
  banAliasImports: true,
@@ -1,4 +1,4 @@
1
- /** @description Enforce "use server" / "use client" directives per file convention */
1
+ /** Enforce "use server" / "use client" directives per file convention. */
2
2
  export const directivesConfigs = [
3
3
  {
4
4
  name: "directives/server-action",
@@ -1,6 +1,6 @@
1
1
  import { localPlugin } from "../common/local-plugins/index.mjs";
2
2
 
3
- /** @description Next.js: enforce relative paths within same feature, @/ for cross-feature */
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",
@@ -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
- /** @description Next.js ESLint flat config entry point */
8
+ /** Next.js ESLint flat config entry point. */
9
9
  export const eslintConfig = [
10
10
  ...createCommonConfigs("src/features"),
11
11
  ...libBoundaryConfigs,
@@ -1,6 +1,6 @@
1
1
  import { checkFile } from "../common/plugins.mjs";
2
2
 
3
- /** @description Next.js-specific naming convention configs for hooks and components */
3
+ /** Next.js-specific naming convention configs for hooks and components. */
4
4
  export const namingConfigs = [
5
5
  {
6
6
  name: "naming/hooks",
@@ -1,6 +1,6 @@
1
1
  import { createCommonConfigs } from "../common/index.mjs";
2
2
 
3
- /** @description Node.js ESLint flat config entry point */
3
+ /** Node.js ESLint flat config entry point. */
4
4
  export const eslintConfig = [
5
5
  ...createCommonConfigs("scripts/features", { banAliasImports: true }),
6
6
  ];