@adonisjs/eslint-plugin 2.1.0 → 2.2.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 +17 -0
- package/build/index.d.ts +17 -4
- package/build/index.js +38 -0
- package/build/src/rules/no_backend_import_in_frontend.d.ts +3 -1
- package/build/src/rules/prefer_adonisjs_inertia_form.d.ts +10 -0
- package/build/src/rules/prefer_adonisjs_inertia_link.d.ts +3 -1
- package/build/src/rules/prefer_lazy_controller_import.d.ts +3 -1
- package/build/src/rules/prefer_lazy_listener_import.d.ts +3 -1
- package/build/src/utils.d.ts +3 -1
- package/package.json +17 -17
package/README.md
CHANGED
|
@@ -123,6 +123,23 @@ import { Link } from '@inertiajs/react'
|
|
|
123
123
|
import { Link } from '@adonisjs/inertia/react'
|
|
124
124
|
```
|
|
125
125
|
|
|
126
|
+
## `prefer-adonisjs-inertia-form`
|
|
127
|
+
|
|
128
|
+
> [!NOTE]
|
|
129
|
+
> This rule is for AdonisJS 7+ projects using `@adonisjs/inertia` v4+. You must enable it manually.
|
|
130
|
+
|
|
131
|
+
The `@adonisjs/prefer-adonisjs-inertia-form` rule warns when you import the `Form` component from `@inertiajs/react` or `@inertiajs/vue3` instead of using the typesafe version from `@adonisjs/inertia`.
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
// ❌ Warning: Prefer importing Form from @adonisjs/inertia/react for typesafe routing
|
|
135
|
+
import { Form } from '@inertiajs/react'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
// ✅ Correct
|
|
140
|
+
import { Form } from '@adonisjs/inertia/react'
|
|
141
|
+
```
|
|
142
|
+
|
|
126
143
|
## `no-backend-import-in-frontend`
|
|
127
144
|
|
|
128
145
|
The `@adonisjs/no-backend-import-in-frontend` rule prevents importing backend code in your frontend files located in the `inertia/` directory.
|
package/build/index.d.ts
CHANGED
|
@@ -2,18 +2,31 @@ declare const _default: {
|
|
|
2
2
|
rules: {
|
|
3
3
|
'prefer-lazy-controller-import': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferLazyControllerImport", [], {
|
|
4
4
|
description: string;
|
|
5
|
-
}, import("@typescript-eslint/utils/ts-eslint").RuleListener
|
|
5
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
6
8
|
'prefer-lazy-listener-import': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferLazyListenerImport", [], {
|
|
7
9
|
description: string;
|
|
8
|
-
}, import("@typescript-eslint/utils/ts-eslint").RuleListener
|
|
10
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
9
13
|
'prefer-adonisjs-inertia-link': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferAdonisInertiaLink", [], {
|
|
10
14
|
description: string;
|
|
11
|
-
}, import("@typescript-eslint/utils/ts-eslint").RuleListener
|
|
15
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
16
|
+
name: string;
|
|
17
|
+
};
|
|
18
|
+
'prefer-adonisjs-inertia-form': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferAdonisInertiaForm", [], {
|
|
19
|
+
description: string;
|
|
20
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
12
23
|
'no-backend-import-in-frontend': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noBackendImport", [{
|
|
13
24
|
allowed?: string[];
|
|
14
25
|
}], {
|
|
15
26
|
description: string;
|
|
16
|
-
}, import("@typescript-eslint/utils/ts-eslint").RuleListener
|
|
27
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
28
|
+
name: string;
|
|
29
|
+
};
|
|
17
30
|
};
|
|
18
31
|
};
|
|
19
32
|
export default _default;
|
package/build/index.js
CHANGED
|
@@ -188,6 +188,43 @@ var prefer_adonisjs_inertia_link_default = createEslintRule({
|
|
|
188
188
|
}
|
|
189
189
|
});
|
|
190
190
|
|
|
191
|
+
// src/rules/prefer_adonisjs_inertia_form.ts
|
|
192
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES4 } from "@typescript-eslint/utils";
|
|
193
|
+
var INERTIA_PACKAGES2 = ["@inertiajs/react", "@inertiajs/vue3"];
|
|
194
|
+
var prefer_adonisjs_inertia_form_default = createEslintRule({
|
|
195
|
+
name: "prefer-adonisjs-inertia-form",
|
|
196
|
+
defaultOptions: [],
|
|
197
|
+
meta: {
|
|
198
|
+
type: "suggestion",
|
|
199
|
+
docs: {
|
|
200
|
+
description: "Prefer the typesafe @adonisjs/inertia Form component over the @inertiajs Form component"
|
|
201
|
+
},
|
|
202
|
+
schema: [],
|
|
203
|
+
messages: {
|
|
204
|
+
preferAdonisInertiaForm: "Prefer importing Form from @adonisjs/inertia/{{ framework }} for typesafe routing instead of {{ source }}"
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
create: function(context) {
|
|
208
|
+
return {
|
|
209
|
+
ImportDeclaration(node) {
|
|
210
|
+
const source = node.source.value;
|
|
211
|
+
if (!INERTIA_PACKAGES2.includes(source)) return;
|
|
212
|
+
const hasFormImport = node.specifiers.some((specifier) => {
|
|
213
|
+
if (specifier.type !== AST_NODE_TYPES4.ImportSpecifier) return false;
|
|
214
|
+
return specifier.imported.type === AST_NODE_TYPES4.Identifier && specifier.imported.name === "Form";
|
|
215
|
+
});
|
|
216
|
+
if (!hasFormImport) return;
|
|
217
|
+
const framework = source === "@inertiajs/react" ? "react" : "vue";
|
|
218
|
+
context.report({
|
|
219
|
+
node,
|
|
220
|
+
messageId: "preferAdonisInertiaForm",
|
|
221
|
+
data: { framework, source }
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
|
|
191
228
|
// src/rules/no_backend_import_in_frontend.ts
|
|
192
229
|
import micromatch from "micromatch";
|
|
193
230
|
import { dirname, resolve } from "path";
|
|
@@ -288,6 +325,7 @@ var index_default = {
|
|
|
288
325
|
"prefer-lazy-controller-import": prefer_lazy_controller_import_default,
|
|
289
326
|
"prefer-lazy-listener-import": prefer_lazy_listener_import_default,
|
|
290
327
|
"prefer-adonisjs-inertia-link": prefer_adonisjs_inertia_link_default,
|
|
328
|
+
"prefer-adonisjs-inertia-form": prefer_adonisjs_inertia_form_default,
|
|
291
329
|
"no-backend-import-in-frontend": no_backend_import_in_frontend_default
|
|
292
330
|
}
|
|
293
331
|
};
|
|
@@ -8,5 +8,7 @@ type Options = [{
|
|
|
8
8
|
*/
|
|
9
9
|
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"noBackendImport", Options, {
|
|
10
10
|
description: string;
|
|
11
|
-
}, import("@typescript-eslint/utils/ts-eslint").RuleListener
|
|
11
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
12
14
|
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESLint rule to prefer the typesafe AdonisJS Inertia Form component
|
|
3
|
+
* over the non-typesafe Inertia.js Form component
|
|
4
|
+
*/
|
|
5
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferAdonisInertiaForm", [], {
|
|
6
|
+
description: string;
|
|
7
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
10
|
+
export default _default;
|
|
@@ -4,5 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferAdonisInertiaLink", [], {
|
|
6
6
|
description: string;
|
|
7
|
-
}, import("@typescript-eslint/utils/ts-eslint").RuleListener
|
|
7
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
8
|
+
name: string;
|
|
9
|
+
};
|
|
8
10
|
export default _default;
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferLazyControllerImport", [], {
|
|
5
5
|
description: string;
|
|
6
|
-
}, import("@typescript-eslint/utils/ts-eslint").RuleListener
|
|
6
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
7
9
|
export default _default;
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferLazyListenerImport", [], {
|
|
5
5
|
description: string;
|
|
6
|
-
}, import("@typescript-eslint/utils/ts-eslint").RuleListener
|
|
6
|
+
}, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
7
9
|
export default _default;
|
package/build/src/utils.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export declare const createEslintRule: <Options extends readonly unknown[], Mess
|
|
|
3
3
|
description: string;
|
|
4
4
|
}>>) => ESLintUtils.RuleModule<MessageIds, Options, {
|
|
5
5
|
description: string;
|
|
6
|
-
}, ESLintUtils.RuleListener
|
|
6
|
+
}, ESLintUtils.RuleListener> & {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/eslint-plugin",
|
|
3
3
|
"description": "ESLint plugin to enforce AdonisJS app specific linting rules",
|
|
4
|
-
"version": "2.1
|
|
4
|
+
"version": "2.2.1",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.6.0"
|
|
7
7
|
},
|
|
@@ -33,32 +33,32 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@adonisjs/prettier-config": "^1.4.5",
|
|
35
35
|
"@adonisjs/tsconfig": "^1.4.1",
|
|
36
|
-
"@japa/assert": "^4.
|
|
37
|
-
"@japa/runner": "^
|
|
38
|
-
"@release-it/conventional-changelog": "^10.0.
|
|
36
|
+
"@japa/assert": "^4.2.0",
|
|
37
|
+
"@japa/runner": "^5.0.0",
|
|
38
|
+
"@release-it/conventional-changelog": "^10.0.4",
|
|
39
39
|
"@stylistic/eslint-plugin-ts": "^4.4.1",
|
|
40
|
-
"@swc/core": "^1.
|
|
40
|
+
"@swc/core": "^1.15.8",
|
|
41
41
|
"@types/micromatch": "^4.0.10",
|
|
42
|
-
"@types/node": "^
|
|
43
|
-
"@typescript-eslint/rule-tester": "^8.
|
|
42
|
+
"@types/node": "^25.0.3",
|
|
43
|
+
"@typescript-eslint/rule-tester": "^8.51.0",
|
|
44
44
|
"c8": "^10.1.3",
|
|
45
|
-
"del-cli": "^
|
|
46
|
-
"eslint": "^9.
|
|
45
|
+
"del-cli": "^7.0.0",
|
|
46
|
+
"eslint": "^9.39.2",
|
|
47
47
|
"eslint-config-prettier": "^10.1.8",
|
|
48
|
-
"eslint-plugin-prettier": "^5.5.
|
|
49
|
-
"eslint-plugin-unicorn": "^
|
|
50
|
-
"prettier": "^3.
|
|
51
|
-
"release-it": "^19.
|
|
48
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
49
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
50
|
+
"prettier": "^3.7.4",
|
|
51
|
+
"release-it": "^19.2.2",
|
|
52
52
|
"ts-node-maintained": "^10.9.6",
|
|
53
|
-
"tsup": "^8.5.
|
|
54
|
-
"typescript": "^5.9.
|
|
55
|
-
"typescript-eslint": "^8.
|
|
53
|
+
"tsup": "^8.5.1",
|
|
54
|
+
"typescript": "^5.9.3",
|
|
55
|
+
"typescript-eslint": "^8.51.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"eslint": "^9.9.1"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@typescript-eslint/utils": "^8.
|
|
61
|
+
"@typescript-eslint/utils": "^8.51.0",
|
|
62
62
|
"micromatch": "^4.0.8",
|
|
63
63
|
"read-package-up": "^12.0.0"
|
|
64
64
|
},
|