@arrirpc/eslint-plugin 0.45.1 → 0.45.3
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +70 -4
- package/dist/configs.cjs +22 -0
- package/dist/configs.d.cts +25 -0
- package/dist/configs.d.mts +25 -0
- package/dist/configs.d.ts +25 -0
- package/dist/configs.mjs +17 -0
- package/dist/plugin.cjs +12 -0
- package/dist/plugin.d.cts +26 -0
- package/dist/plugin.d.mts +26 -0
- package/dist/plugin.d.ts +26 -0
- package/dist/plugin.mjs +1 -0
- package/dist/{index.cjs → shared/eslint-plugin.5adc55bc.cjs} +25 -17
- package/dist/{index.mjs → shared/eslint-plugin.aced4931.mjs} +24 -15
- package/package.json +3 -3
package/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
# Arri-RPC Eslint Plugin
|
1
|
+
# Arri-RPC Eslint Plugin and Configs
|
2
|
+
|
3
|
+
This library provides some useful lint rules when building Arri RPC schemas.
|
2
4
|
|
3
5
|
## Installation
|
4
6
|
|
@@ -12,15 +14,24 @@ pnpm i --save-dev @arrirpc/eslint-plugin
|
|
12
14
|
|
13
15
|
## Usage
|
14
16
|
|
15
|
-
###
|
17
|
+
### Ecosystem Note
|
18
|
+
|
19
|
+
This library supports both [flat file config format](https://eslint.org/docs/latest/use/configure/configuration-files) and the [legacy config format](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated). Right now, the legacy format is the default. When more of the ecosystem has moved to supporting the new format this library will swap defaults, and potentially drop support for the old format. When such a change happens, it will be marked as a breaking change.
|
20
|
+
|
21
|
+
### Legacy Eslint Config
|
22
|
+
|
23
|
+
#### Using the default recommended configuration
|
24
|
+
|
25
|
+
This turns all of the `@arrirpc/eslint` rules on
|
16
26
|
|
17
27
|
```jsonc
|
18
28
|
{
|
19
|
-
"extends": ["plugin:@arrirpc/recommended"],
|
29
|
+
"extends": ["plugin:@arrirpc/legacy-config-recommended"],
|
30
|
+
"files": ["**/*.ts"],
|
20
31
|
}
|
21
32
|
```
|
22
33
|
|
23
|
-
|
34
|
+
#### Manual Setup
|
24
35
|
|
25
36
|
```jsonc
|
26
37
|
{
|
@@ -37,3 +48,58 @@ pnpm i --save-dev @arrirpc/eslint-plugin
|
|
37
48
|
},
|
38
49
|
}
|
39
50
|
```
|
51
|
+
|
52
|
+
### Flat File Config
|
53
|
+
|
54
|
+
#### Using the default recommended configuration
|
55
|
+
|
56
|
+
This turns all of the `@arrirpc/eslint` rules on. Please note that the file extension is required to get it work properly.
|
57
|
+
|
58
|
+
```js
|
59
|
+
// eslint.config.js
|
60
|
+
import arri from "@arrirpc/eslint-plugin/dist/configs.mjs";
|
61
|
+
|
62
|
+
export default [
|
63
|
+
arri.recommended,
|
64
|
+
{
|
65
|
+
files: ["src/**/*.ts"], // you will still need to tell eslint which files to lint like so
|
66
|
+
},
|
67
|
+
];
|
68
|
+
```
|
69
|
+
|
70
|
+
If you need commonjs support you can change the `.mjs` extension to `.cjs`
|
71
|
+
|
72
|
+
```ts
|
73
|
+
import arri from "@arrirpc/eslint-plugin/dist/configs.cjs";
|
74
|
+
```
|
75
|
+
|
76
|
+
##### Note
|
77
|
+
|
78
|
+
When the flat file config format becomes the default these long imports with explicit `.mjs`/`.cjs` suffixes will not longer be required. This method is just a hacky way for us keep the old and new style configs in one package.
|
79
|
+
|
80
|
+
#### Manual setup
|
81
|
+
|
82
|
+
The plugin can be enabled in flat file configs like so. Fortunately this doesn't require the long ugly imports.
|
83
|
+
|
84
|
+
```js
|
85
|
+
// eslint.config.js
|
86
|
+
import arri from "@arrirpc/eslint";
|
87
|
+
|
88
|
+
export default [
|
89
|
+
{
|
90
|
+
plugins: {
|
91
|
+
arri,
|
92
|
+
},
|
93
|
+
rules: {
|
94
|
+
// check to see if an ID has been assigned to root a.object() schemas
|
95
|
+
"arri/no-anonymous-object": 2,
|
96
|
+
// check to see if an ID has been assigned to a.enumerator() or a.stringEnum() schemas
|
97
|
+
"arri/no-anonymous-enumerator": 2,
|
98
|
+
// check to see if an ID has been assigned to a.discriminator() schemas
|
99
|
+
"arri/no-anonymous-discriminator": 2,
|
100
|
+
// check to see if an ID has been assigned to a.recursive() schemas
|
101
|
+
"arri/no-anonymous-recursive": 2,
|
102
|
+
},
|
103
|
+
},
|
104
|
+
];
|
105
|
+
```
|
package/dist/configs.cjs
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
const plugin = require('./shared/eslint-plugin.5adc55bc.cjs');
|
6
|
+
|
7
|
+
const flatConfigs = {
|
8
|
+
recommended: {
|
9
|
+
plugins: {
|
10
|
+
arri: plugin.plugin
|
11
|
+
},
|
12
|
+
rules: plugin.prefixedRuleMap("arri", {
|
13
|
+
"no-anonymous-object": 2,
|
14
|
+
"no-anonymous-enumerator": 2,
|
15
|
+
"no-anonymous-discriminator": 2,
|
16
|
+
"no-anonymous-recursive": 2
|
17
|
+
})
|
18
|
+
}
|
19
|
+
};
|
20
|
+
|
21
|
+
exports.default = flatConfigs;
|
22
|
+
exports.flatConfigs = flatConfigs;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import * as eslint from 'eslint';
|
2
|
+
import { Linter } from 'eslint';
|
3
|
+
|
4
|
+
declare const flatConfigs: {
|
5
|
+
readonly recommended: {
|
6
|
+
plugins: {
|
7
|
+
arri: {
|
8
|
+
meta: {
|
9
|
+
name?: string | undefined;
|
10
|
+
version?: string | undefined;
|
11
|
+
};
|
12
|
+
configs: Record<string, Linter.FlatConfig<Linter.RulesRecord> | eslint.ESLint.ConfigData<Linter.RulesRecord> | Linter.FlatConfig<Linter.RulesRecord>[]>;
|
13
|
+
rules: {
|
14
|
+
readonly "no-anonymous-discriminator": eslint.Rule.RuleModule;
|
15
|
+
readonly "no-anonymous-enumerator": eslint.Rule.RuleModule;
|
16
|
+
readonly "no-anonymous-object": eslint.Rule.RuleModule;
|
17
|
+
readonly "no-anonymous-recursive": eslint.Rule.RuleModule;
|
18
|
+
};
|
19
|
+
};
|
20
|
+
};
|
21
|
+
rules: Record<"arri/no-anonymous-discriminator" | "arri/no-anonymous-enumerator" | "arri/no-anonymous-object" | "arri/no-anonymous-recursive", Linter.RuleEntry<any[]>>;
|
22
|
+
};
|
23
|
+
};
|
24
|
+
|
25
|
+
export { flatConfigs as default, flatConfigs };
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import * as eslint from 'eslint';
|
2
|
+
import { Linter } from 'eslint';
|
3
|
+
|
4
|
+
declare const flatConfigs: {
|
5
|
+
readonly recommended: {
|
6
|
+
plugins: {
|
7
|
+
arri: {
|
8
|
+
meta: {
|
9
|
+
name?: string | undefined;
|
10
|
+
version?: string | undefined;
|
11
|
+
};
|
12
|
+
configs: Record<string, Linter.FlatConfig<Linter.RulesRecord> | eslint.ESLint.ConfigData<Linter.RulesRecord> | Linter.FlatConfig<Linter.RulesRecord>[]>;
|
13
|
+
rules: {
|
14
|
+
readonly "no-anonymous-discriminator": eslint.Rule.RuleModule;
|
15
|
+
readonly "no-anonymous-enumerator": eslint.Rule.RuleModule;
|
16
|
+
readonly "no-anonymous-object": eslint.Rule.RuleModule;
|
17
|
+
readonly "no-anonymous-recursive": eslint.Rule.RuleModule;
|
18
|
+
};
|
19
|
+
};
|
20
|
+
};
|
21
|
+
rules: Record<"arri/no-anonymous-discriminator" | "arri/no-anonymous-enumerator" | "arri/no-anonymous-object" | "arri/no-anonymous-recursive", Linter.RuleEntry<any[]>>;
|
22
|
+
};
|
23
|
+
};
|
24
|
+
|
25
|
+
export { flatConfigs as default, flatConfigs };
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import * as eslint from 'eslint';
|
2
|
+
import { Linter } from 'eslint';
|
3
|
+
|
4
|
+
declare const flatConfigs: {
|
5
|
+
readonly recommended: {
|
6
|
+
plugins: {
|
7
|
+
arri: {
|
8
|
+
meta: {
|
9
|
+
name?: string | undefined;
|
10
|
+
version?: string | undefined;
|
11
|
+
};
|
12
|
+
configs: Record<string, Linter.FlatConfig<Linter.RulesRecord> | eslint.ESLint.ConfigData<Linter.RulesRecord> | Linter.FlatConfig<Linter.RulesRecord>[]>;
|
13
|
+
rules: {
|
14
|
+
readonly "no-anonymous-discriminator": eslint.Rule.RuleModule;
|
15
|
+
readonly "no-anonymous-enumerator": eslint.Rule.RuleModule;
|
16
|
+
readonly "no-anonymous-object": eslint.Rule.RuleModule;
|
17
|
+
readonly "no-anonymous-recursive": eslint.Rule.RuleModule;
|
18
|
+
};
|
19
|
+
};
|
20
|
+
};
|
21
|
+
rules: Record<"arri/no-anonymous-discriminator" | "arri/no-anonymous-enumerator" | "arri/no-anonymous-object" | "arri/no-anonymous-recursive", Linter.RuleEntry<any[]>>;
|
22
|
+
};
|
23
|
+
};
|
24
|
+
|
25
|
+
export { flatConfigs as default, flatConfigs };
|
package/dist/configs.mjs
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
import { p as plugin, a as prefixedRuleMap } from './shared/eslint-plugin.aced4931.mjs';
|
2
|
+
|
3
|
+
const flatConfigs = {
|
4
|
+
recommended: {
|
5
|
+
plugins: {
|
6
|
+
arri: plugin
|
7
|
+
},
|
8
|
+
rules: prefixedRuleMap("arri", {
|
9
|
+
"no-anonymous-object": 2,
|
10
|
+
"no-anonymous-enumerator": 2,
|
11
|
+
"no-anonymous-discriminator": 2,
|
12
|
+
"no-anonymous-recursive": 2
|
13
|
+
})
|
14
|
+
}
|
15
|
+
};
|
16
|
+
|
17
|
+
export { flatConfigs as default, flatConfigs };
|
package/dist/plugin.cjs
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
const plugin = require('./shared/eslint-plugin.5adc55bc.cjs');
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
exports.configs = plugin.configs;
|
10
|
+
exports.default = plugin.plugin;
|
11
|
+
exports.meta = plugin.meta;
|
12
|
+
exports.rules = plugin.rules;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import * as eslint from 'eslint';
|
2
|
+
import { ESLint } from 'eslint';
|
3
|
+
|
4
|
+
declare const meta: ESLint.Plugin["meta"];
|
5
|
+
declare const configs: ESLint.Plugin["configs"];
|
6
|
+
declare const rules: {
|
7
|
+
readonly "no-anonymous-discriminator": eslint.Rule.RuleModule;
|
8
|
+
readonly "no-anonymous-enumerator": eslint.Rule.RuleModule;
|
9
|
+
readonly "no-anonymous-object": eslint.Rule.RuleModule;
|
10
|
+
readonly "no-anonymous-recursive": eslint.Rule.RuleModule;
|
11
|
+
};
|
12
|
+
declare const _default: {
|
13
|
+
meta: {
|
14
|
+
name?: string | undefined;
|
15
|
+
version?: string | undefined;
|
16
|
+
};
|
17
|
+
configs: Record<string, ESLint.ConfigData<eslint.Linter.RulesRecord> | eslint.Linter.FlatConfig<eslint.Linter.RulesRecord> | eslint.Linter.FlatConfig<eslint.Linter.RulesRecord>[]>;
|
18
|
+
rules: {
|
19
|
+
readonly "no-anonymous-discriminator": eslint.Rule.RuleModule;
|
20
|
+
readonly "no-anonymous-enumerator": eslint.Rule.RuleModule;
|
21
|
+
readonly "no-anonymous-object": eslint.Rule.RuleModule;
|
22
|
+
readonly "no-anonymous-recursive": eslint.Rule.RuleModule;
|
23
|
+
};
|
24
|
+
};
|
25
|
+
|
26
|
+
export { configs, _default as default, meta, rules };
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import * as eslint from 'eslint';
|
2
|
+
import { ESLint } from 'eslint';
|
3
|
+
|
4
|
+
declare const meta: ESLint.Plugin["meta"];
|
5
|
+
declare const configs: ESLint.Plugin["configs"];
|
6
|
+
declare const rules: {
|
7
|
+
readonly "no-anonymous-discriminator": eslint.Rule.RuleModule;
|
8
|
+
readonly "no-anonymous-enumerator": eslint.Rule.RuleModule;
|
9
|
+
readonly "no-anonymous-object": eslint.Rule.RuleModule;
|
10
|
+
readonly "no-anonymous-recursive": eslint.Rule.RuleModule;
|
11
|
+
};
|
12
|
+
declare const _default: {
|
13
|
+
meta: {
|
14
|
+
name?: string | undefined;
|
15
|
+
version?: string | undefined;
|
16
|
+
};
|
17
|
+
configs: Record<string, ESLint.ConfigData<eslint.Linter.RulesRecord> | eslint.Linter.FlatConfig<eslint.Linter.RulesRecord> | eslint.Linter.FlatConfig<eslint.Linter.RulesRecord>[]>;
|
18
|
+
rules: {
|
19
|
+
readonly "no-anonymous-discriminator": eslint.Rule.RuleModule;
|
20
|
+
readonly "no-anonymous-enumerator": eslint.Rule.RuleModule;
|
21
|
+
readonly "no-anonymous-object": eslint.Rule.RuleModule;
|
22
|
+
readonly "no-anonymous-recursive": eslint.Rule.RuleModule;
|
23
|
+
};
|
24
|
+
};
|
25
|
+
|
26
|
+
export { configs, _default as default, meta, rules };
|
package/dist/plugin.d.ts
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
import * as eslint from 'eslint';
|
2
|
+
import { ESLint } from 'eslint';
|
3
|
+
|
4
|
+
declare const meta: ESLint.Plugin["meta"];
|
5
|
+
declare const configs: ESLint.Plugin["configs"];
|
6
|
+
declare const rules: {
|
7
|
+
readonly "no-anonymous-discriminator": eslint.Rule.RuleModule;
|
8
|
+
readonly "no-anonymous-enumerator": eslint.Rule.RuleModule;
|
9
|
+
readonly "no-anonymous-object": eslint.Rule.RuleModule;
|
10
|
+
readonly "no-anonymous-recursive": eslint.Rule.RuleModule;
|
11
|
+
};
|
12
|
+
declare const _default: {
|
13
|
+
meta: {
|
14
|
+
name?: string | undefined;
|
15
|
+
version?: string | undefined;
|
16
|
+
};
|
17
|
+
configs: Record<string, ESLint.ConfigData<eslint.Linter.RulesRecord> | eslint.Linter.FlatConfig<eslint.Linter.RulesRecord> | eslint.Linter.FlatConfig<eslint.Linter.RulesRecord>[]>;
|
18
|
+
rules: {
|
19
|
+
readonly "no-anonymous-discriminator": eslint.Rule.RuleModule;
|
20
|
+
readonly "no-anonymous-enumerator": eslint.Rule.RuleModule;
|
21
|
+
readonly "no-anonymous-object": eslint.Rule.RuleModule;
|
22
|
+
readonly "no-anonymous-recursive": eslint.Rule.RuleModule;
|
23
|
+
};
|
24
|
+
};
|
25
|
+
|
26
|
+
export { configs, _default as default, meta, rules };
|
package/dist/plugin.mjs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export { c as configs, p as default, m as meta, r as rules } from './shared/eslint-plugin.aced4931.mjs';
|
@@ -1,7 +1,5 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
-
|
5
3
|
function argHasIdKey(arg) {
|
6
4
|
if (arg.type === "ObjectExpression") {
|
7
5
|
for (const prop of arg.properties) {
|
@@ -277,29 +275,39 @@ const noAnonymousRecursive = {
|
|
277
275
|
}
|
278
276
|
};
|
279
277
|
|
278
|
+
const rules$1 = {
|
279
|
+
"no-anonymous-discriminator": noAnonymousDiscriminator,
|
280
|
+
"no-anonymous-enumerator": noAnonymousEnumerator,
|
281
|
+
"no-anonymous-object": noAnonymousObject,
|
282
|
+
"no-anonymous-recursive": noAnonymousRecursive
|
283
|
+
};
|
284
|
+
function prefixedRuleMap(prefix, rules2) {
|
285
|
+
const result = {};
|
286
|
+
for (const key of Object.keys(rules2)) {
|
287
|
+
result[`${prefix}/${key}`] = rules2[key];
|
288
|
+
}
|
289
|
+
return result;
|
290
|
+
}
|
291
|
+
|
280
292
|
const meta = {
|
281
293
|
name: "@arrirpc"
|
282
294
|
};
|
283
295
|
const configs = {
|
284
|
-
recommended: {
|
296
|
+
"legacy-config-recommended": {
|
285
297
|
plugins: ["@arrirpc"],
|
286
|
-
rules: {
|
287
|
-
"
|
288
|
-
"
|
289
|
-
"
|
290
|
-
"
|
291
|
-
}
|
298
|
+
rules: prefixedRuleMap("@arrirpc", {
|
299
|
+
"no-anonymous-object": 2,
|
300
|
+
"no-anonymous-recursive": 2,
|
301
|
+
"no-anonymous-discriminator": 2,
|
302
|
+
"no-anonymous-enumerator": 2
|
303
|
+
})
|
292
304
|
}
|
293
305
|
};
|
294
|
-
const rules =
|
295
|
-
|
296
|
-
"no-anonymous-recursive": noAnonymousRecursive,
|
297
|
-
"no-anonymous-discriminator": noAnonymousDiscriminator,
|
298
|
-
"no-anonymous-enumerator": noAnonymousEnumerator
|
299
|
-
};
|
300
|
-
const index = { meta, configs, rules };
|
306
|
+
const rules = rules$1;
|
307
|
+
const plugin = { meta, configs, rules: rules$1 };
|
301
308
|
|
302
309
|
exports.configs = configs;
|
303
|
-
exports.default = index;
|
304
310
|
exports.meta = meta;
|
311
|
+
exports.plugin = plugin;
|
312
|
+
exports.prefixedRuleMap = prefixedRuleMap;
|
305
313
|
exports.rules = rules;
|
@@ -273,26 +273,35 @@ const noAnonymousRecursive = {
|
|
273
273
|
}
|
274
274
|
};
|
275
275
|
|
276
|
+
const rules$1 = {
|
277
|
+
"no-anonymous-discriminator": noAnonymousDiscriminator,
|
278
|
+
"no-anonymous-enumerator": noAnonymousEnumerator,
|
279
|
+
"no-anonymous-object": noAnonymousObject,
|
280
|
+
"no-anonymous-recursive": noAnonymousRecursive
|
281
|
+
};
|
282
|
+
function prefixedRuleMap(prefix, rules2) {
|
283
|
+
const result = {};
|
284
|
+
for (const key of Object.keys(rules2)) {
|
285
|
+
result[`${prefix}/${key}`] = rules2[key];
|
286
|
+
}
|
287
|
+
return result;
|
288
|
+
}
|
289
|
+
|
276
290
|
const meta = {
|
277
291
|
name: "@arrirpc"
|
278
292
|
};
|
279
293
|
const configs = {
|
280
|
-
recommended: {
|
294
|
+
"legacy-config-recommended": {
|
281
295
|
plugins: ["@arrirpc"],
|
282
|
-
rules: {
|
283
|
-
"
|
284
|
-
"
|
285
|
-
"
|
286
|
-
"
|
287
|
-
}
|
296
|
+
rules: prefixedRuleMap("@arrirpc", {
|
297
|
+
"no-anonymous-object": 2,
|
298
|
+
"no-anonymous-recursive": 2,
|
299
|
+
"no-anonymous-discriminator": 2,
|
300
|
+
"no-anonymous-enumerator": 2
|
301
|
+
})
|
288
302
|
}
|
289
303
|
};
|
290
|
-
const rules =
|
291
|
-
|
292
|
-
"no-anonymous-recursive": noAnonymousRecursive,
|
293
|
-
"no-anonymous-discriminator": noAnonymousDiscriminator,
|
294
|
-
"no-anonymous-enumerator": noAnonymousEnumerator
|
295
|
-
};
|
296
|
-
const index = { meta, configs, rules };
|
304
|
+
const rules = rules$1;
|
305
|
+
const plugin = { meta, configs, rules: rules$1 };
|
297
306
|
|
298
|
-
export {
|
307
|
+
export { prefixedRuleMap as a, configs as c, meta as m, plugin as p, rules as r };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arrirpc/eslint-plugin",
|
3
|
-
"version": "0.45.
|
3
|
+
"version": "0.45.3",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": {
|
6
6
|
"name": "joshmossas",
|
@@ -14,8 +14,8 @@
|
|
14
14
|
"url": "https://github.com/modiimedia/arri.git",
|
15
15
|
"directory": "tooling/eslint-plugin"
|
16
16
|
},
|
17
|
-
"main": "./dist/
|
18
|
-
"module": "./dist/
|
17
|
+
"main": "./dist/plugin.cjs",
|
18
|
+
"module": "./dist/plugin.mjs",
|
19
19
|
"files": [
|
20
20
|
"dist"
|
21
21
|
],
|