eslint-plugin-tmdr-nuxt 1.0.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/README.md +75 -0
- package/dist/configs/recommended.d.ts +4 -0
- package/dist/configs/recommended.d.ts.map +1 -0
- package/dist/configs/recommended.js +24 -0
- package/dist/configs/recommended.js.map +1 -0
- package/dist/configs/trial.d.ts +4 -0
- package/dist/configs/trial.d.ts.map +1 -0
- package/dist/configs/trial.js +24 -0
- package/dist/configs/trial.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/rules/async-data-top-level.d.ts +4 -0
- package/dist/rules/async-data-top-level.d.ts.map +1 -0
- package/dist/rules/async-data-top-level.js +62 -0
- package/dist/rules/async-data-top-level.js.map +1 -0
- package/dist/rules/emits-interface-name.d.ts +6 -0
- package/dist/rules/emits-interface-name.d.ts.map +1 -0
- package/dist/rules/emits-interface-name.js +12 -0
- package/dist/rules/emits-interface-name.js.map +1 -0
- package/dist/rules/enforce-component-directory-structure.d.ts +7 -0
- package/dist/rules/enforce-component-directory-structure.d.ts.map +1 -0
- package/dist/rules/enforce-component-directory-structure.js +174 -0
- package/dist/rules/enforce-component-directory-structure.js.map +1 -0
- package/dist/rules/index.d.ts +3 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +38 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/no-async-data-outside-setup.d.ts +4 -0
- package/dist/rules/no-async-data-outside-setup.d.ts.map +1 -0
- package/dist/rules/no-async-data-outside-setup.js +49 -0
- package/dist/rules/no-async-data-outside-setup.js.map +1 -0
- package/dist/rules/no-composable-in-class.d.ts +7 -0
- package/dist/rules/no-composable-in-class.d.ts.map +1 -0
- package/dist/rules/no-composable-in-class.js +69 -0
- package/dist/rules/no-composable-in-class.js.map +1 -0
- package/dist/rules/no-direct-any-in-emits.d.ts +6 -0
- package/dist/rules/no-direct-any-in-emits.d.ts.map +1 -0
- package/dist/rules/no-direct-any-in-emits.js +12 -0
- package/dist/rules/no-direct-any-in-emits.js.map +1 -0
- package/dist/rules/no-direct-any-in-props.d.ts +6 -0
- package/dist/rules/no-direct-any-in-props.d.ts.map +1 -0
- package/dist/rules/no-direct-any-in-props.js +12 -0
- package/dist/rules/no-direct-any-in-props.js.map +1 -0
- package/dist/rules/no-direct-api-call-in-component.d.ts +4 -0
- package/dist/rules/no-direct-api-call-in-component.d.ts.map +1 -0
- package/dist/rules/no-direct-api-call-in-component.js +42 -0
- package/dist/rules/no-direct-api-call-in-component.js.map +1 -0
- package/dist/rules/no-inline-emits-definition.d.ts +4 -0
- package/dist/rules/no-inline-emits-definition.d.ts.map +1 -0
- package/dist/rules/no-inline-emits-definition.js +16 -0
- package/dist/rules/no-inline-emits-definition.js.map +1 -0
- package/dist/rules/no-inline-props-definition.d.ts +4 -0
- package/dist/rules/no-inline-props-definition.d.ts.map +1 -0
- package/dist/rules/no-inline-props-definition.js +16 -0
- package/dist/rules/no-inline-props-definition.js.map +1 -0
- package/dist/rules/no-manual-repository-import.d.ts +12 -0
- package/dist/rules/no-manual-repository-import.d.ts.map +1 -0
- package/dist/rules/no-manual-repository-import.js +80 -0
- package/dist/rules/no-manual-repository-import.js.map +1 -0
- package/dist/rules/props-interface-name.d.ts +6 -0
- package/dist/rules/props-interface-name.d.ts.map +1 -0
- package/dist/rules/props-interface-name.js +12 -0
- package/dist/rules/props-interface-name.js.map +1 -0
- package/dist/rules/require-pinia-composition-api.d.ts +4 -0
- package/dist/rules/require-pinia-composition-api.d.ts.map +1 -0
- package/dist/rules/require-pinia-composition-api.js +40 -0
- package/dist/rules/require-pinia-composition-api.js.map +1 -0
- package/dist/rules/require-typed-emits-signature.d.ts +6 -0
- package/dist/rules/require-typed-emits-signature.d.ts.map +1 -0
- package/dist/rules/require-typed-emits-signature.js +58 -0
- package/dist/rules/require-typed-emits-signature.js.map +1 -0
- package/dist/rules/require-typed-repository.d.ts +6 -0
- package/dist/rules/require-typed-repository.d.ts.map +1 -0
- package/dist/rules/require-typed-repository.js +180 -0
- package/dist/rules/require-typed-repository.js.map +1 -0
- package/dist/rules/require-typescript-interface-props.d.ts +4 -0
- package/dist/rules/require-typescript-interface-props.d.ts.map +1 -0
- package/dist/rules/require-typescript-interface-props.js +49 -0
- package/dist/rules/require-typescript-interface-props.js.map +1 -0
- package/dist/utils/ast.d.ts +4 -0
- package/dist/utils/ast.d.ts.map +1 -0
- package/dist/utils/ast.js +37 -0
- package/dist/utils/ast.js.map +1 -0
- package/dist/utils/define-macro-rule.d.ts +43 -0
- package/dist/utils/define-macro-rule.d.ts.map +1 -0
- package/dist/utils/define-macro-rule.js +230 -0
- package/dist/utils/define-macro-rule.js.map +1 -0
- package/dist/utils/filename.d.ts +5 -0
- package/dist/utils/filename.d.ts.map +1 -0
- package/dist/utils/filename.js +63 -0
- package/dist/utils/filename.js.map +1 -0
- package/dist/utils/formattter.d.ts +3 -0
- package/dist/utils/formattter.d.ts.map +1 -0
- package/dist/utils/formattter.js +18 -0
- package/dist/utils/formattter.js.map +1 -0
- package/dist/utils/rule.d.ts +18 -0
- package/dist/utils/rule.d.ts.map +1 -0
- package/dist/utils/rule.js +21 -0
- package/dist/utils/rule.js.map +1 -0
- package/dist/utils/tester.d.ts +3 -0
- package/dist/utils/tester.d.ts.map +1 -0
- package/dist/utils/tester.js +19 -0
- package/dist/utils/tester.js.map +1 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Timedoor ESLint Plugin
|
|
2
|
+
|
|
3
|
+
`eslint-plugin-tmdr-nuxt` is an ESLint plugin designed for the Timedoor Frontend Team. It enforces **Nuxt.js best practices**, **TypeScript conventions**, and **directory structure** standards in Nuxt 3 projects.
|
|
4
|
+
|
|
5
|
+
There is also a ready-to-use shared config, [`eslint-config-tmdr-nuxt`](./eslint-config), that bundles this plugin alongside other recommended plugins.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
### Plugin only
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install --save-dev eslint-plugin-tmdr-nuxt
|
|
13
|
+
# or
|
|
14
|
+
pnpm add -D eslint-plugin-tmdr-nuxt
|
|
15
|
+
# or
|
|
16
|
+
yarn add -D eslint-plugin-tmdr-nuxt
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Shared config (recommended)
|
|
20
|
+
|
|
21
|
+
The shared config includes `eslint-plugin-tmdr-nuxt` plus a curated set of other ESLint plugins. See the [ESLint Config](https://timedoor-eslint-plugin-nuxt.vercel.app/eslint-config) page for full details.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### Flat Config (`eslint.config.mjs`)
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import pluginTmdrNuxt from 'eslint-plugin-tmdr-nuxt'
|
|
29
|
+
|
|
30
|
+
export default [
|
|
31
|
+
{
|
|
32
|
+
plugins: {
|
|
33
|
+
'tmdr-nuxt': pluginTmdrNuxt,
|
|
34
|
+
},
|
|
35
|
+
rules: {
|
|
36
|
+
'tmdr-nuxt/no-composable-in-class': 'error',
|
|
37
|
+
'tmdr-nuxt/async-data-top-level': 'error',
|
|
38
|
+
// ... add more rules
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or use the built-in `recommended` config to enable all rules at once:
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
import pluginTmdrNuxt from 'eslint-plugin-tmdr-nuxt'
|
|
48
|
+
|
|
49
|
+
export default [
|
|
50
|
+
{
|
|
51
|
+
plugins: { 'tmdr-nuxt': pluginTmdrNuxt },
|
|
52
|
+
...pluginTmdrNuxt.configs.recommended,
|
|
53
|
+
},
|
|
54
|
+
]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Legacy Config (`.eslintrc`)
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"plugins": ["tmdr-nuxt"],
|
|
62
|
+
"rules": {
|
|
63
|
+
"tmdr-nuxt/no-composable-in-class": "error",
|
|
64
|
+
"tmdr-nuxt/async-data-top-level": "error"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Or extend the `recommended` config:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"extends": ["plugin:tmdr-nuxt/recommended"]
|
|
74
|
+
}
|
|
75
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended.d.ts","sourceRoot":"","sources":["../../src/configs/recommended.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAmBpB,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config = {
|
|
4
|
+
rules: {
|
|
5
|
+
"tmdr-nuxt/enforce-component-directory-structure": "error",
|
|
6
|
+
"tmdr-nuxt/require-typescript-interface-props": "error",
|
|
7
|
+
"tmdr-nuxt/no-direct-any-in-props": "error",
|
|
8
|
+
"tmdr-nuxt/no-inline-props-definition": "error",
|
|
9
|
+
"tmdr-nuxt/props-interface-name": "error",
|
|
10
|
+
"tmdr-nuxt/require-typed-emits-signature": "error",
|
|
11
|
+
"tmdr-nuxt/no-direct-any-in-emits": "error",
|
|
12
|
+
"tmdr-nuxt/no-inline-emits-definition": "error",
|
|
13
|
+
"tmdr-nuxt/emits-interface-name": "error",
|
|
14
|
+
"tmdr-nuxt/no-composable-in-class": "error",
|
|
15
|
+
"tmdr-nuxt/async-data-top-level": "error",
|
|
16
|
+
"tmdr-nuxt/no-async-data-outside-setup": "error",
|
|
17
|
+
"tmdr-nuxt/no-direct-api-call-in-component": "error",
|
|
18
|
+
"tmdr-nuxt/no-manual-repository-import": "error",
|
|
19
|
+
"tmdr-nuxt/require-typed-repository": "error",
|
|
20
|
+
"tmdr-nuxt/require-pinia-composition-api": "error",
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
exports.default = config;
|
|
24
|
+
//# sourceMappingURL=recommended.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recommended.js","sourceRoot":"","sources":["../../src/configs/recommended.ts"],"names":[],"mappings":";;AAEA,MAAM,MAAM,GAAkB;IAC5B,KAAK,EAAE;QACL,iDAAiD,EAAE,OAAO;QAC1D,8CAA8C,EAAE,OAAO;QACvD,kCAAkC,EAAE,OAAO;QAC3C,sCAAsC,EAAE,OAAO;QAC/C,gCAAgC,EAAE,OAAO;QACzC,yCAAyC,EAAE,OAAO;QAClD,kCAAkC,EAAE,OAAO;QAC3C,sCAAsC,EAAE,OAAO;QAC/C,gCAAgC,EAAE,OAAO;QACzC,kCAAkC,EAAE,OAAO;QAC3C,gCAAgC,EAAE,OAAO;QACzC,uCAAuC,EAAE,OAAO;QAChD,2CAA2C,EAAE,OAAO;QACpD,uCAAuC,EAAE,OAAO;QAChD,oCAAoC,EAAE,OAAO;QAC7C,yCAAyC,EAAE,OAAO;KACnD;CACF,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trial.d.ts","sourceRoot":"","sources":["../../src/configs/trial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAmBpB,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config = {
|
|
4
|
+
rules: {
|
|
5
|
+
"tmdr-nuxt/enforce-component-directory-structure": "warn",
|
|
6
|
+
"tmdr-nuxt/require-typescript-interface-props": "warn",
|
|
7
|
+
"tmdr-nuxt/no-direct-any-in-props": "warn",
|
|
8
|
+
"tmdr-nuxt/no-inline-props-definition": "warn",
|
|
9
|
+
"tmdr-nuxt/props-interface-name": "warn",
|
|
10
|
+
"tmdr-nuxt/require-typed-emits-signature": "warn",
|
|
11
|
+
"tmdr-nuxt/no-direct-any-in-emits": "warn",
|
|
12
|
+
"tmdr-nuxt/no-inline-emits-definition": "warn",
|
|
13
|
+
"tmdr-nuxt/emits-interface-name": "warn",
|
|
14
|
+
"tmdr-nuxt/no-composable-in-class": "warn",
|
|
15
|
+
"tmdr-nuxt/async-data-top-level": "warn",
|
|
16
|
+
"tmdr-nuxt/no-async-data-outside-setup": "warn",
|
|
17
|
+
"tmdr-nuxt/no-direct-api-call-in-component": "warn",
|
|
18
|
+
"tmdr-nuxt/no-manual-repository-import": "warn",
|
|
19
|
+
"tmdr-nuxt/require-typed-repository": "warn",
|
|
20
|
+
"tmdr-nuxt/require-pinia-composition-api": "warn",
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
exports.default = config;
|
|
24
|
+
//# sourceMappingURL=trial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trial.js","sourceRoot":"","sources":["../../src/configs/trial.ts"],"names":[],"mappings":";;AAEA,MAAM,MAAM,GAAkB;IAC5B,KAAK,EAAE;QACL,iDAAiD,EAAE,MAAM;QACzD,8CAA8C,EAAE,MAAM;QACtD,kCAAkC,EAAE,MAAM;QAC1C,sCAAsC,EAAE,MAAM;QAC9C,gCAAgC,EAAE,MAAM;QACxC,yCAAyC,EAAE,MAAM;QACjD,kCAAkC,EAAE,MAAM;QAC1C,sCAAsC,EAAE,MAAM;QAC9C,gCAAgC,EAAE,MAAM;QACxC,kCAAkC,EAAE,MAAM;QAC1C,gCAAgC,EAAE,MAAM;QACxC,uCAAuC,EAAE,MAAM;QAC/C,2CAA2C,EAAE,MAAM;QACnD,uCAAuC,EAAE,MAAM;QAC/C,oCAAoC,EAAE,MAAM;QAC5C,yCAAyC,EAAE,MAAM;KAClD;CACF,CAAC;AAEF,kBAAe,MAAM,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ESLint, Linter } from "eslint";
|
|
2
|
+
type Plugin = Omit<ESLint.Plugin, "configs"> & {
|
|
3
|
+
configs: ESLint.Plugin["configs"] & Record<"recommended" | "trial", Linter.Config>;
|
|
4
|
+
};
|
|
5
|
+
declare const plugin: Plugin;
|
|
6
|
+
export = plugin;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKxC,KAAK,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG;IAC7C,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,GAC/B,MAAM,CAAC,aAAa,GAAG,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;CAClD,CAAC;AAEF,QAAA,MAAM,MAAM,EAAE,MAUb,CAAC;AAEF,SAAS,MAAM,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const rules_1 = require("./rules");
|
|
6
|
+
const recommended_1 = __importDefault(require("./configs/recommended"));
|
|
7
|
+
const trial_1 = __importDefault(require("./configs/trial"));
|
|
8
|
+
const plugin = {
|
|
9
|
+
meta: {
|
|
10
|
+
name: "eslint-plugin-tmdr-nuxt",
|
|
11
|
+
version: "1.0.0",
|
|
12
|
+
},
|
|
13
|
+
rules: rules_1.rules,
|
|
14
|
+
configs: {
|
|
15
|
+
recommended: recommended_1.default,
|
|
16
|
+
trial: trial_1.default,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
module.exports = plugin;
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,mCAAgC;AAChC,wEAAgD;AAChD,4DAAoC;AAOpC,MAAM,MAAM,GAAW;IACrB,IAAI,EAAE;QACJ,IAAI,EAAE,yBAAyB;QAC/B,OAAO,EAAE,OAAO;KACjB;IACD,KAAK,EAAL,aAAK;IACL,OAAO,EAAE;QACP,WAAW,EAAX,qBAAW;QACX,KAAK,EAAL,eAAK;KACN;CACF,CAAC;AAEF,iBAAS,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-data-top-level.d.ts","sourceRoot":"","sources":["../../src/rules/async-data-top-level.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,iBAAiB;;CAgD5B,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asyncDataTopLevel = void 0;
|
|
4
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
+
const rule_1 = require("../utils/rule");
|
|
6
|
+
const ast_1 = require("../utils/ast");
|
|
7
|
+
const NON_TOP_LEVEL_ANCESTORS = new Set([
|
|
8
|
+
utils_1.AST_NODE_TYPES.FunctionDeclaration,
|
|
9
|
+
utils_1.AST_NODE_TYPES.FunctionExpression,
|
|
10
|
+
utils_1.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
11
|
+
utils_1.AST_NODE_TYPES.ClassDeclaration,
|
|
12
|
+
utils_1.AST_NODE_TYPES.ClassExpression,
|
|
13
|
+
utils_1.AST_NODE_TYPES.IfStatement,
|
|
14
|
+
utils_1.AST_NODE_TYPES.ForStatement,
|
|
15
|
+
utils_1.AST_NODE_TYPES.ForInStatement,
|
|
16
|
+
utils_1.AST_NODE_TYPES.ForOfStatement,
|
|
17
|
+
utils_1.AST_NODE_TYPES.WhileStatement,
|
|
18
|
+
utils_1.AST_NODE_TYPES.DoWhileStatement,
|
|
19
|
+
utils_1.AST_NODE_TYPES.TryStatement,
|
|
20
|
+
utils_1.AST_NODE_TYPES.SwitchStatement,
|
|
21
|
+
]);
|
|
22
|
+
exports.asyncDataTopLevel = (0, rule_1.createRule)({
|
|
23
|
+
name: "async-data-top-level",
|
|
24
|
+
meta: {
|
|
25
|
+
docs: {
|
|
26
|
+
description: "Enforce useAsyncData to be called at the top level of setup or inside custom composable.",
|
|
27
|
+
},
|
|
28
|
+
type: "problem",
|
|
29
|
+
messages: {
|
|
30
|
+
"issue:invalid-call": "'{{name}}' must be called at the top level of <script setup> or inside custom composable.",
|
|
31
|
+
},
|
|
32
|
+
schema: [],
|
|
33
|
+
defaultOptions: [],
|
|
34
|
+
hasSuggestions: false,
|
|
35
|
+
},
|
|
36
|
+
create: (context) => {
|
|
37
|
+
return (0, rule_1.withTemplateVisitor)(context, {
|
|
38
|
+
script: {
|
|
39
|
+
CallExpression(node) {
|
|
40
|
+
const nuxtFetchComposables = ["useAsyncData", "useFetch"];
|
|
41
|
+
const isCallingUseAsyncData = node.callee.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
42
|
+
nuxtFetchComposables.includes(node.callee.name);
|
|
43
|
+
if (!isCallingUseAsyncData)
|
|
44
|
+
return;
|
|
45
|
+
const composableName = node.callee.type === utils_1.AST_NODE_TYPES.Identifier
|
|
46
|
+
? node.callee.name
|
|
47
|
+
: "";
|
|
48
|
+
const ancestors = context.sourceCode.getAncestors(node);
|
|
49
|
+
const isTopLevel = !ancestors.some((ancestor) => NON_TOP_LEVEL_ANCESTORS.has(ancestor.type));
|
|
50
|
+
if (!isTopLevel && !(0, ast_1.isInsideComposable)(ancestors)) {
|
|
51
|
+
context.report({
|
|
52
|
+
node,
|
|
53
|
+
messageId: "issue:invalid-call",
|
|
54
|
+
data: { name: composableName },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=async-data-top-level.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-data-top-level.js","sourceRoot":"","sources":["../../src/rules/async-data-top-level.ts"],"names":[],"mappings":";;;AAAA,oDAA0D;AAC1D,wCAAgE;AAChE,sCAAkD;AAElD,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IACtC,sBAAc,CAAC,mBAAmB;IAClC,sBAAc,CAAC,kBAAkB;IACjC,sBAAc,CAAC,uBAAuB;IACtC,sBAAc,CAAC,gBAAgB;IAC/B,sBAAc,CAAC,eAAe;IAC9B,sBAAc,CAAC,WAAW;IAC1B,sBAAc,CAAC,YAAY;IAC3B,sBAAc,CAAC,cAAc;IAC7B,sBAAc,CAAC,cAAc;IAC7B,sBAAc,CAAC,cAAc;IAC7B,sBAAc,CAAC,gBAAgB;IAC/B,sBAAc,CAAC,YAAY;IAC3B,sBAAc,CAAC,eAAe;CAC/B,CAAC,CAAC;AAEU,QAAA,iBAAiB,GAAG,IAAA,iBAAU,EAAC;IAC1C,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EACT,0FAA0F;SAC7F;QACD,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE;YACR,oBAAoB,EAClB,2FAA2F;SAC9F;QACD,MAAM,EAAE,EAAE;QACV,cAAc,EAAE,EAAE;QAClB,cAAc,EAAE,KAAK;KACtB;IACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,OAAO,IAAA,0BAAmB,EAAC,OAAO,EAAE;YAClC,MAAM,EAAE;gBACN,cAAc,CAAC,IAAI;oBACjB,MAAM,oBAAoB,GAAG,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;oBAC1D,MAAM,qBAAqB,GACzB,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,UAAU;wBAC9C,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;oBAElD,IAAI,CAAC,qBAAqB;wBAAE,OAAO;oBAEnC,MAAM,cAAc,GAClB,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,UAAU;wBAC5C,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;wBAClB,CAAC,CAAC,EAAE,CAAC;oBAET,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;oBACxD,MAAM,UAAU,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC9C,uBAAuB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAC3C,CAAC;oBAEF,IAAI,CAAC,UAAU,IAAI,CAAC,IAAA,wBAAkB,EAAC,SAAS,CAAC,EAAE,CAAC;wBAClD,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,oBAAoB;4BAC/B,IAAI,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;yBAC/B,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const emitsInterfaceName: import("@typescript-eslint/utils/ts-eslint").RuleModule<"issue:invalid-interface-name" | "hint:rename-interface", [{
|
|
2
|
+
pattern?: string;
|
|
3
|
+
}], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=emits-interface-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emits-interface-name.d.ts","sourceRoot":"","sources":["../../src/rules/emits-interface-name.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,kBAAkB;;;;CAM7B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emitsInterfaceName = void 0;
|
|
4
|
+
const define_macro_rule_1 = require("../utils/define-macro-rule");
|
|
5
|
+
exports.emitsInterfaceName = (0, define_macro_rule_1.createInterfaceNameRule)({
|
|
6
|
+
macroName: "defineEmits",
|
|
7
|
+
ruleName: "emits-interface-name",
|
|
8
|
+
description: "Enforce naming convention for emits interface/type",
|
|
9
|
+
subjectLabel: "Emits",
|
|
10
|
+
defaultSuffix: "Emits",
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=emits-interface-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emits-interface-name.js","sourceRoot":"","sources":["../../src/rules/emits-interface-name.ts"],"names":[],"mappings":";;;AAAA,kEAAqE;AAExD,QAAA,kBAAkB,GAAG,IAAA,2CAAuB,EAAC;IACxD,SAAS,EAAE,aAAa;IACxB,QAAQ,EAAE,sBAAsB;IAChC,WAAW,EAAE,oDAAoD;IACjE,YAAY,EAAE,OAAO;IACrB,aAAa,EAAE,OAAO;CACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const enforceComponentDirectoryStructure: import("@typescript-eslint/utils/ts-eslint").RuleModule<"issue:component-ui-dir" | "issue:component-dir-ui" | "issue:component-layout-dir" | "issue:layout-parent-dir" | "issue:invalid-dir" | "issue:must-components-dir", {
|
|
2
|
+
allowedDirs: string[];
|
|
3
|
+
overrideDefaults: boolean;
|
|
4
|
+
}[], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=enforce-component-directory-structure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enforce-component-directory-structure.d.ts","sourceRoot":"","sources":["../../src/rules/enforce-component-directory-structure.ts"],"names":[],"mappings":"AA4FA,eAAO,MAAM,kCAAkC;iBAiCpB,MAAM,EAAE;;;;CA0GjC,CAAC"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enforceComponentDirectoryStructure = void 0;
|
|
4
|
+
const filename_1 = require("../utils/filename");
|
|
5
|
+
const formattter_1 = require("../utils/formattter");
|
|
6
|
+
const rule_1 = require("../utils/rule");
|
|
7
|
+
const whitelistNuxtDirs = ["layouts", "pages"];
|
|
8
|
+
const whitelistNuxtFiles = ["app.vue", "error.vue"];
|
|
9
|
+
const validateFilename = (fileName, affix, type) => {
|
|
10
|
+
let regex;
|
|
11
|
+
if (type === "prefix") {
|
|
12
|
+
regex = new RegExp(`^${affix}[A-Z][a-zA-Z]*\.vue$`);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
regex = new RegExp(`^[A-Z][a-zA-Z]*${affix}\.vue$`);
|
|
16
|
+
}
|
|
17
|
+
return regex.test(fileName);
|
|
18
|
+
};
|
|
19
|
+
const messagesMap = {
|
|
20
|
+
ui: {
|
|
21
|
+
inside: "issue:component-ui-dir",
|
|
22
|
+
outside: "issue:component-dir-ui",
|
|
23
|
+
},
|
|
24
|
+
layout: {
|
|
25
|
+
inside: "issue:component-layout-dir",
|
|
26
|
+
outside: "issue:component-layout-dir",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const validateDirectory = ({ subPath, affix, type, prefixDirectory, }) => {
|
|
30
|
+
const splittedSubPath = subPath.split("/");
|
|
31
|
+
const messageIds = messagesMap[prefixDirectory];
|
|
32
|
+
if (splittedSubPath.length <= 2) {
|
|
33
|
+
if (validateFilename(splittedSubPath[1], affix, type)) {
|
|
34
|
+
return messageIds.outside;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const [_, componentDir, ...files] = subPath.split("/");
|
|
38
|
+
const componentFile = files.filter((f) => f.endsWith(".vue"));
|
|
39
|
+
if (!componentFile[0]) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const hasFileAffix = validateFilename(componentFile[0], affix, type);
|
|
43
|
+
const hasDirectory = componentDir === prefixDirectory;
|
|
44
|
+
if (!hasDirectory && hasFileAffix) {
|
|
45
|
+
return messageIds.outside;
|
|
46
|
+
}
|
|
47
|
+
if (hasDirectory && !hasFileAffix) {
|
|
48
|
+
return messageIds.inside;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
};
|
|
52
|
+
const getAllowedDirs = (dirs, overrideDefaults) => {
|
|
53
|
+
const defaultDirs = ["ui", "layout", "section"];
|
|
54
|
+
if (overrideDefaults) {
|
|
55
|
+
return dirs;
|
|
56
|
+
}
|
|
57
|
+
return [...defaultDirs, ...dirs];
|
|
58
|
+
};
|
|
59
|
+
exports.enforceComponentDirectoryStructure = (0, rule_1.createRule)({
|
|
60
|
+
name: "enforce-component-directory-structure",
|
|
61
|
+
meta: {
|
|
62
|
+
docs: {
|
|
63
|
+
description: "Validate that components convention name are placed in the correct directory structure",
|
|
64
|
+
},
|
|
65
|
+
type: "layout",
|
|
66
|
+
messages: {
|
|
67
|
+
"issue:component-ui-dir": `Filename must be start with "Ui" when the component is placed in a "components/ui" directory.`,
|
|
68
|
+
"issue:component-dir-ui": `Filename must be placed in a "components/ui" directory when the filename starts with "Ui".`,
|
|
69
|
+
"issue:component-layout-dir": `Filename must be start with "{{parentName}}" when the component is placed in a "components/layout/{{parentDir}}" directory.`,
|
|
70
|
+
"issue:layout-parent-dir": `File must have at least 1 parent directory inside "components/layout" directory.`,
|
|
71
|
+
"issue:invalid-dir": "Component must be placed in a valid directory. Allowed directories are: {{allowedDirs}}.",
|
|
72
|
+
"issue:must-components-dir": `Component must be placed inside the "components" directory.`,
|
|
73
|
+
},
|
|
74
|
+
schema: {
|
|
75
|
+
type: "array",
|
|
76
|
+
minItems: 0,
|
|
77
|
+
items: [
|
|
78
|
+
{
|
|
79
|
+
type: "object",
|
|
80
|
+
properties: {
|
|
81
|
+
allowedDirs: { type: "array", items: { type: "string" } },
|
|
82
|
+
overrideDefaults: { type: "boolean" },
|
|
83
|
+
},
|
|
84
|
+
additionalProperties: false,
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
},
|
|
88
|
+
defaultOptions: [
|
|
89
|
+
{
|
|
90
|
+
allowedDirs: [],
|
|
91
|
+
overrideDefaults: false,
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
hasSuggestions: false,
|
|
95
|
+
},
|
|
96
|
+
create: (context) => {
|
|
97
|
+
var _a, _b;
|
|
98
|
+
const relativePath = (0, filename_1.getRelativePath)(context);
|
|
99
|
+
const isNuxtDir = whitelistNuxtDirs.some((dir) => relativePath.startsWith(`${dir}/`));
|
|
100
|
+
const isNuxtFile = whitelistNuxtFiles.some((file) => relativePath === file);
|
|
101
|
+
if (!relativePath.endsWith(".vue") || isNuxtDir || isNuxtFile) {
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
const allowedDirs = getAllowedDirs(((_a = context.options[0]) === null || _a === void 0 ? void 0 : _a.allowedDirs) || [], ((_b = context.options[0]) === null || _b === void 0 ? void 0 : _b.overrideDefaults) || false);
|
|
105
|
+
return (0, rule_1.withTemplateVisitor)(context, {
|
|
106
|
+
script: {
|
|
107
|
+
Program: (node) => {
|
|
108
|
+
const componentsDir = `/${relativePath}`.split("/components");
|
|
109
|
+
if (componentsDir.length <= 1) {
|
|
110
|
+
context.report({
|
|
111
|
+
node,
|
|
112
|
+
messageId: "issue:must-components-dir",
|
|
113
|
+
});
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const subPath = componentsDir[componentsDir.length - 1];
|
|
117
|
+
const messageIdUi = validateDirectory({
|
|
118
|
+
subPath,
|
|
119
|
+
affix: "Ui",
|
|
120
|
+
type: "prefix",
|
|
121
|
+
prefixDirectory: "ui",
|
|
122
|
+
});
|
|
123
|
+
if (messageIdUi) {
|
|
124
|
+
context.report({
|
|
125
|
+
node,
|
|
126
|
+
messageId: messageIdUi,
|
|
127
|
+
});
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const [_, subCompDir, ...files] = subPath.split("/");
|
|
131
|
+
if (subCompDir === "layout") {
|
|
132
|
+
const parentDir = files[files.length - 2];
|
|
133
|
+
if (!parentDir) {
|
|
134
|
+
context.report({
|
|
135
|
+
node,
|
|
136
|
+
messageId: "issue:layout-parent-dir",
|
|
137
|
+
});
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const messageIdLayout = validateDirectory({
|
|
141
|
+
subPath,
|
|
142
|
+
affix: (0, formattter_1.capitalize)(parentDir, "-"),
|
|
143
|
+
type: "prefix",
|
|
144
|
+
prefixDirectory: "layout",
|
|
145
|
+
});
|
|
146
|
+
if (messageIdLayout) {
|
|
147
|
+
context.report({
|
|
148
|
+
node,
|
|
149
|
+
data: {
|
|
150
|
+
parentName: (0, formattter_1.capitalize)(parentDir, "-"),
|
|
151
|
+
parentDir,
|
|
152
|
+
},
|
|
153
|
+
messageId: messageIdLayout,
|
|
154
|
+
});
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const isInAllowedDir = allowedDirs.some((dir) => subPath.startsWith(`/${dir}/`));
|
|
159
|
+
if (!isInAllowedDir) {
|
|
160
|
+
context.report({
|
|
161
|
+
node,
|
|
162
|
+
messageId: "issue:invalid-dir",
|
|
163
|
+
data: {
|
|
164
|
+
allowedDirs: allowedDirs.join(", "),
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
//# sourceMappingURL=enforce-component-directory-structure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enforce-component-directory-structure.js","sourceRoot":"","sources":["../../src/rules/enforce-component-directory-structure.ts"],"names":[],"mappings":";;;AAAA,gDAAoD;AACpD,oDAAiD;AACjD,wCAAgE;AAEhE,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC/C,MAAM,kBAAkB,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAEpD,MAAM,gBAAgB,GAAG,CACvB,QAAgB,EAChB,KAAa,EACb,IAAyB,EACzB,EAAE;IACF,IAAI,KAAK,CAAC;IACV,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,KAAK,GAAG,IAAI,MAAM,CAAC,IAAI,KAAK,sBAAsB,CAAC,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,KAAK,GAAG,IAAI,MAAM,CAAC,kBAAkB,KAAK,QAAQ,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAC9B,CAAC,CAAC;AAaF,MAAM,WAAW,GAGb;IACF,EAAE,EAAE;QACF,MAAM,EAAE,wBAAwB;QAChC,OAAO,EAAE,wBAAwB;KAClC;IACD,MAAM,EAAE;QACN,MAAM,EAAE,4BAA4B;QACpC,OAAO,EAAE,4BAA4B;KACtC;CACF,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,EACzB,OAAO,EACP,KAAK,EACL,IAAI,EACJ,eAAe,GACC,EAAqB,EAAE;IACvC,MAAM,eAAe,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,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AAM,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rules = void 0;
|
|
4
|
+
const enforce_component_directory_structure_1 = require("./enforce-component-directory-structure");
|
|
5
|
+
const require_typescript_interface_props_1 = require("./require-typescript-interface-props");
|
|
6
|
+
const no_direct_any_in_props_1 = require("./no-direct-any-in-props");
|
|
7
|
+
const no_inline_props_definition_1 = require("./no-inline-props-definition");
|
|
8
|
+
const props_interface_name_1 = require("./props-interface-name");
|
|
9
|
+
const require_typed_emits_signature_1 = require("./require-typed-emits-signature");
|
|
10
|
+
const emits_interface_name_1 = require("./emits-interface-name");
|
|
11
|
+
const no_direct_any_in_emits_1 = require("./no-direct-any-in-emits");
|
|
12
|
+
const no_inline_emits_definition_1 = require("./no-inline-emits-definition");
|
|
13
|
+
const no_composable_in_class_1 = require("./no-composable-in-class");
|
|
14
|
+
const async_data_top_level_1 = require("./async-data-top-level");
|
|
15
|
+
const no_async_data_outside_setup_1 = require("./no-async-data-outside-setup");
|
|
16
|
+
const no_direct_api_call_in_component_1 = require("./no-direct-api-call-in-component");
|
|
17
|
+
const no_manual_repository_import_1 = require("./no-manual-repository-import");
|
|
18
|
+
const require_typed_repository_1 = require("./require-typed-repository");
|
|
19
|
+
const require_pinia_composition_api_1 = require("./require-pinia-composition-api");
|
|
20
|
+
exports.rules = {
|
|
21
|
+
"enforce-component-directory-structure": enforce_component_directory_structure_1.enforceComponentDirectoryStructure,
|
|
22
|
+
"require-typescript-interface-props": require_typescript_interface_props_1.requireTypescriptInterfaceProps,
|
|
23
|
+
"no-direct-any-in-props": no_direct_any_in_props_1.noDirectAnyInProps,
|
|
24
|
+
"no-inline-props-definition": no_inline_props_definition_1.noInlinePropsDefinition,
|
|
25
|
+
"props-interface-name": props_interface_name_1.propsInterfaceName,
|
|
26
|
+
"require-typed-emits-signature": require_typed_emits_signature_1.requireTypedEmitsSignature,
|
|
27
|
+
"no-direct-any-in-emits": no_direct_any_in_emits_1.noDirectAnyInEmits,
|
|
28
|
+
"no-inline-emits-definition": no_inline_emits_definition_1.noInlineEmitsDefinition,
|
|
29
|
+
"emits-interface-name": emits_interface_name_1.emitsInterfaceName,
|
|
30
|
+
"no-composable-in-class": no_composable_in_class_1.noComposableInClass,
|
|
31
|
+
"async-data-top-level": async_data_top_level_1.asyncDataTopLevel,
|
|
32
|
+
"no-async-data-outside-setup": no_async_data_outside_setup_1.noAsyncDataOutsideSetup,
|
|
33
|
+
"no-direct-api-call-in-component": no_direct_api_call_in_component_1.noDirectApiCallInComponent,
|
|
34
|
+
"no-manual-repository-import": no_manual_repository_import_1.noManualRepositoryImport,
|
|
35
|
+
"require-typed-repository": require_typed_repository_1.requireTypedRepository,
|
|
36
|
+
"require-pinia-composition-api": require_pinia_composition_api_1.requirePiniaCompositionApi,
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":";;;AACA,mGAA6F;AAC7F,6FAAuF;AACvF,qEAA8D;AAC9D,6EAAuE;AACvE,iEAA4D;AAC5D,mFAA6E;AAC7E,iEAA4D;AAC5D,qEAA8D;AAC9D,6EAAuE;AACvE,qEAA+D;AAC/D,iEAA2D;AAC3D,+EAAwE;AACxE,uFAA+E;AAC/E,+EAAyE;AACzE,yEAAoE;AACpE,mFAA6E;AAEhE,QAAA,KAAK,GAAG;IACnB,uCAAuC,EAAE,0EAAkC;IAC3E,oCAAoC,EAAE,oEAA+B;IACrE,wBAAwB,EAAE,2CAAkB;IAC5C,4BAA4B,EAAE,oDAAuB;IACrD,sBAAsB,EAAE,yCAAkB;IAC1C,+BAA+B,EAAE,0DAA0B;IAC3D,wBAAwB,EAAE,2CAAkB;IAC5C,4BAA4B,EAAE,oDAAuB;IACrD,sBAAsB,EAAE,yCAAkB;IAC1C,wBAAwB,EAAE,4CAAmB;IAC7C,sBAAsB,EAAE,wCAAiB;IACzC,6BAA6B,EAAE,qDAAuB;IACtD,iCAAiC,EAAE,4DAA0B;IAC7D,6BAA6B,EAAE,sDAAwB;IACvD,0BAA0B,EAAE,iDAAsB;IAClD,+BAA+B,EAAE,0DAA0B;CACvB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const noAsyncDataOutsideSetup: import("@typescript-eslint/utils/ts-eslint").RuleModule<"issue:invalid-call", never[], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
2
|
+
name: string;
|
|
3
|
+
};
|
|
4
|
+
//# sourceMappingURL=no-async-data-outside-setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-async-data-outside-setup.d.ts","sourceRoot":"","sources":["../../src/rules/no-async-data-outside-setup.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,uBAAuB;;CA+ClC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noAsyncDataOutsideSetup = void 0;
|
|
4
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
+
const filename_1 = require("../utils/filename");
|
|
6
|
+
const rule_1 = require("../utils/rule");
|
|
7
|
+
const ast_1 = require("../utils/ast");
|
|
8
|
+
exports.noAsyncDataOutsideSetup = (0, rule_1.createRule)({
|
|
9
|
+
name: "no-async-data-outside-setup",
|
|
10
|
+
meta: {
|
|
11
|
+
docs: {
|
|
12
|
+
description: "Disallow useAsyncData/useFetch outside of Vue component or composable functions.",
|
|
13
|
+
},
|
|
14
|
+
type: "problem",
|
|
15
|
+
messages: {
|
|
16
|
+
"issue:invalid-call": "Nuxt composable '{{name}}' cannot be used outside of Vue component or composable function.",
|
|
17
|
+
},
|
|
18
|
+
schema: [],
|
|
19
|
+
defaultOptions: [],
|
|
20
|
+
hasSuggestions: false,
|
|
21
|
+
},
|
|
22
|
+
create: (context) => {
|
|
23
|
+
return (0, rule_1.withTemplateVisitor)(context, {
|
|
24
|
+
script: {
|
|
25
|
+
CallExpression(node) {
|
|
26
|
+
if ((0, filename_1.isVueFile)(context.filename))
|
|
27
|
+
return;
|
|
28
|
+
const nuxtFetchComposables = ["useAsyncData", "useFetch"];
|
|
29
|
+
const isCallingNuxtFetchComposable = node.callee.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
30
|
+
nuxtFetchComposables.includes(node.callee.name);
|
|
31
|
+
if (!isCallingNuxtFetchComposable)
|
|
32
|
+
return;
|
|
33
|
+
const composableName = node.callee.type === utils_1.AST_NODE_TYPES.Identifier
|
|
34
|
+
? node.callee.name
|
|
35
|
+
: "";
|
|
36
|
+
const ancestors = context.sourceCode.getAncestors(node);
|
|
37
|
+
if (!(0, ast_1.isInsideComposable)(ancestors)) {
|
|
38
|
+
context.report({
|
|
39
|
+
node,
|
|
40
|
+
messageId: "issue:invalid-call",
|
|
41
|
+
data: { name: composableName },
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=no-async-data-outside-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-async-data-outside-setup.js","sourceRoot":"","sources":["../../src/rules/no-async-data-outside-setup.ts"],"names":[],"mappings":";;;AAAA,oDAA0D;AAC1D,gDAA8C;AAC9C,wCAAgE;AAChE,sCAAkD;AAErC,QAAA,uBAAuB,GAAG,IAAA,iBAAU,EAAC;IAChD,IAAI,EAAE,6BAA6B;IACnC,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,WAAW,EACT,kFAAkF;SACrF;QACD,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE;YACR,oBAAoB,EAClB,4FAA4F;SAC/F;QACD,MAAM,EAAE,EAAE;QACV,cAAc,EAAE,EAAE;QAClB,cAAc,EAAE,KAAK;KACtB;IACD,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,OAAO,IAAA,0BAAmB,EAAC,OAAO,EAAE;YAClC,MAAM,EAAE;gBACN,cAAc,CAAC,IAAI;oBACjB,IAAI,IAAA,oBAAS,EAAC,OAAO,CAAC,QAAQ,CAAC;wBAAE,OAAO;oBAExC,MAAM,oBAAoB,GAAG,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;oBAC1D,MAAM,4BAA4B,GAChC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,UAAU;wBAC9C,oBAAoB,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;oBAElD,IAAI,CAAC,4BAA4B;wBAAE,OAAO;oBAE1C,MAAM,cAAc,GAClB,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,sBAAc,CAAC,UAAU;wBAC5C,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI;wBAClB,CAAC,CAAC,EAAE,CAAC;oBAET,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;oBAExD,IAAI,CAAC,IAAA,wBAAkB,EAAC,SAAS,CAAC,EAAE,CAAC;wBACnC,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI;4BACJ,SAAS,EAAE,oBAAoB;4BAC/B,IAAI,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;yBAC/B,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const noComposableInClass: import("@typescript-eslint/utils/ts-eslint").RuleModule<"issue:composable-call", {
|
|
2
|
+
allowedComposables: string[];
|
|
3
|
+
overrideDefaults: boolean;
|
|
4
|
+
}[], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=no-composable-in-class.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-composable-in-class.d.ts","sourceRoot":"","sources":["../../src/rules/no-composable-in-class.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,mBAAmB;;;;;CAsE9B,CAAC"}
|