eslint-plugin-flawless 0.1.10 → 0.1.12
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 +25 -0
- package/dist/index.d.mts +106 -60
- package/dist/index.mjs +1 -3067
- package/dist/oxlint.d.mts +5 -0
- package/dist/oxlint.mjs +25 -0
- package/dist/plugin-DYVtpuio.mjs +4226 -0
- package/dist/rules/arrow-return-style/worker.d.mts +25 -0
- package/dist/rules/arrow-return-style/worker.mjs +90 -0
- package/package.json +11 -2
package/README.md
CHANGED
|
@@ -97,6 +97,28 @@ export default [
|
|
|
97
97
|
}
|
|
98
98
|
```
|
|
99
99
|
|
|
100
|
+
### oxlint (via jsPlugins)
|
|
101
|
+
|
|
102
|
+
The non-type-aware rules are also published as an
|
|
103
|
+
[oxlint JS plugin](https://oxc.rs/docs/guide/usage/linter/writing-js-plugins) at
|
|
104
|
+
the `eslint-plugin-awesome/oxlint` entry point, so the same rules run under
|
|
105
|
+
oxlint without any code duplication. Add `@oxlint/plugins` and the plugin as
|
|
106
|
+
runtime dependencies, then reference it from your oxlint config:
|
|
107
|
+
|
|
108
|
+
```jsonc
|
|
109
|
+
// .oxlintrc.json
|
|
110
|
+
{
|
|
111
|
+
"jsPlugins": ["eslint-plugin-awesome/oxlint"],
|
|
112
|
+
"rules": {
|
|
113
|
+
"awesome/my-new-rule": "error",
|
|
114
|
+
},
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The plugin key stays the same as under ESLint (`awesome`). Rules that require
|
|
119
|
+
TypeScript type information or a custom parser are ESLint-only, since oxlint's
|
|
120
|
+
JS plugin API supports neither.
|
|
121
|
+
|
|
100
122
|
## Development
|
|
101
123
|
|
|
102
124
|
Scripts you’ll use during development:
|
|
@@ -178,13 +200,16 @@ Requires [type information](https://typescript-eslint.io/linting/typed-linting).
|
|
|
178
200
|
|
|
179
201
|
| Name | Description | 🔧 | 💭 |
|
|
180
202
|
| :-------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------- | :-- | :-- |
|
|
203
|
+
| [arrow-return-style](src/rules/arrow-return-style/documentation.md) | Enforce arrow function return style based on line length | 🔧 | |
|
|
181
204
|
| [jsx-shorthand-boolean](src/rules/jsx-shorthand-boolean/documentation.md) | Disallow shorthand boolean JSX attributes | 🔧 | |
|
|
182
205
|
| [jsx-shorthand-fragment](src/rules/jsx-shorthand-fragment/documentation.md) | Enforce a consistent fragment form: the shorthand `<>...</>` or a named fragment | 🔧 | |
|
|
183
206
|
| [naming-convention](src/rules/naming-convention/documentation.md) | Enforce naming conventions for everything across a codebase | | 💭 |
|
|
207
|
+
| [no-export-default-arrow](src/rules/no-export-default-arrow/documentation.md) | Disallow anonymous arrow functions as export default declarations | 🔧 | |
|
|
184
208
|
| [no-unnecessary-use-callback](src/rules/no-unnecessary-use-callback/documentation.md) | Disallow unnecessary usage of 'useCallback' | | |
|
|
185
209
|
| [no-unnecessary-use-memo](src/rules/no-unnecessary-use-memo/documentation.md) | Disallow unnecessary usage of 'useMemo' | | |
|
|
186
210
|
| [prefer-destructuring-assignment](src/rules/prefer-destructuring-assignment/documentation.md) | Enforce destructuring assignment for component props | 🔧 | |
|
|
187
211
|
| [prefer-parameter-destructuring](src/rules/prefer-parameter-destructuring/documentation.md) | Enforce destructuring parameters in the function signature | 🔧 | |
|
|
212
|
+
| [prefer-read-only-props](src/rules/prefer-read-only-props/documentation.md) | Enforce that function component props are read-only | 🔧 | 💭 |
|
|
188
213
|
| [purity](src/rules/purity/documentation.md) | Disallow impure calls such as `math.random` or `os.clock` during render | | |
|
|
189
214
|
| [toml-sort-keys](src/rules/toml-sort-keys/documentation.md) | Enforce a configured sort order for TOML keys and tables | 🔧 | |
|
|
190
215
|
| [yaml-block-key-blank-lines](src/rules/yaml-block-key-blank-lines/documentation.md) | Enforce blank lines around top-level YAML block collection keys | 🔧 | |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,73 @@
|
|
|
1
1
|
import { TSESLint } from "@typescript-eslint/utils";
|
|
2
2
|
import { Linter } from "eslint";
|
|
3
|
-
|
|
4
3
|
//#region src/util.d.ts
|
|
5
4
|
interface PluginDocumentation {
|
|
6
5
|
description: string;
|
|
7
6
|
recommended?: boolean;
|
|
8
7
|
requiresTypeChecking: boolean;
|
|
9
8
|
}
|
|
9
|
+
declare const createRule: <Options extends readonly unknown[], MessageIds extends string>({ meta, name, ...rule }: Readonly<import("${configDir}").RuleWithMetaAndName<Options, MessageIds, PluginDocumentation>>) => TSESLint.RuleModule<MessageIds, Options, PluginDocumentation, TSESLint.RuleListener> & {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A rule context whose `sourceCode` is replaced with a custom type. YAML rules
|
|
14
|
+
* use this to receive a `YAMLSourceCode` (whose token/AST APIs accept YAML
|
|
15
|
+
* nodes) instead of the default ESLint `SourceCode`.
|
|
16
|
+
*
|
|
17
|
+
* @template MessageIds - The rule's message identifiers.
|
|
18
|
+
* @template Options - The rule's options tuple.
|
|
19
|
+
* @template SourceCode - The source code type exposed on `context.sourceCode`.
|
|
20
|
+
*/
|
|
21
|
+
type RuleContextWithSourceCode<MessageIds extends string, Options extends ReadonlyArray<unknown>, SourceCode> = Omit<Readonly<TSESLint.RuleContext<MessageIds, Options>>, "sourceCode"> & {
|
|
22
|
+
readonly sourceCode: SourceCode;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* A rule listener extended with oxlint's `createOnce` per-file lifecycle hooks.
|
|
26
|
+
*
|
|
27
|
+
* `before` runs before AST traversal of each file (returning `false` skips the
|
|
28
|
+
* file); `after` runs once traversal completes. Under oxlint these map to the
|
|
29
|
+
* native hooks; under ESLint {@link createFlawlessRule} emulates them.
|
|
30
|
+
*/
|
|
31
|
+
type FlawlessRuleListener = TSESLint.RuleListener & {
|
|
32
|
+
after?: () => void;
|
|
33
|
+
before?: () => boolean | void;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* An ESLint rule module that additionally carries oxlint's `createOnce` method,
|
|
37
|
+
* so a single definition runs on both linters.
|
|
38
|
+
*
|
|
39
|
+
* @template Options - The rule's options tuple.
|
|
40
|
+
* @template MessageIds - The rule's message identifiers.
|
|
41
|
+
* @template SourceCode - The source code type exposed on `context.sourceCode`.
|
|
42
|
+
*/
|
|
43
|
+
type FlawlessRuleModule<Options extends ReadonlyArray<unknown>, MessageIds extends string, SourceCode = Readonly<TSESLint.SourceCode>> = ReturnType<typeof createRule<Options, MessageIds>> & {
|
|
44
|
+
createOnce: (context: RuleContextWithSourceCode<MessageIds, Options, SourceCode>) => FlawlessRuleListener;
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/rules/arrow-return-style/rule.d.ts
|
|
48
|
+
declare const IMPLICIT = "useImplicitReturn";
|
|
49
|
+
declare const EXPLICIT = "useExplicitReturn";
|
|
50
|
+
declare const COMPLEX_EXPLICIT = "useExplicitReturnComplex";
|
|
51
|
+
type MessageIds$4 = typeof COMPLEX_EXPLICIT | typeof EXPLICIT | typeof IMPLICIT;
|
|
52
|
+
type ObjectReturnStyle = "always-explicit" | "complex-explicit" | "off";
|
|
53
|
+
type Options$5 = [{
|
|
54
|
+
/** Always use explicit returns for JSX bodies. */
|
|
55
|
+
jsxAlwaysUseExplicitReturn?: boolean;
|
|
56
|
+
/** Maximum emitted line length (tab-expanded) before requiring an explicit return. */
|
|
57
|
+
maxLen?: number;
|
|
58
|
+
/** Object property / array element count above which a literal body counts as complex. */
|
|
59
|
+
maxObjectProperties?: number;
|
|
60
|
+
/** Always use explicit returns for arrows assigned to named exports. */
|
|
61
|
+
namedExportsAlwaysUseExplicitReturn?: boolean;
|
|
62
|
+
/** When to force explicit returns for object/array literal bodies. */
|
|
63
|
+
objectReturnStyle?: ObjectReturnStyle;
|
|
64
|
+
/** Columns a tab occupies when measuring against `maxLen`. */
|
|
65
|
+
tabWidth?: number;
|
|
66
|
+
/** Consult oxfmt for boundary decisions; `printWidth` defaults to `maxLen`. */
|
|
67
|
+
useOxfmt?: boolean | {
|
|
68
|
+
printWidth?: number;
|
|
69
|
+
};
|
|
70
|
+
}];
|
|
10
71
|
//#endregion
|
|
11
72
|
//#region src/rules/jsx-shorthand-fragment/rule.d.ts
|
|
12
73
|
declare const MESSAGE_ID_NAMED = "useNamedFragment";
|
|
@@ -189,30 +250,25 @@ declare const plugin: {
|
|
|
189
250
|
version: string;
|
|
190
251
|
};
|
|
191
252
|
rules: {
|
|
192
|
-
"
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
"jsx-shorthand-fragment": TSESLint.RuleModule<MessageIds$3, Options$4, PluginDocumentation, TSESLint.RuleListener> & {
|
|
196
|
-
name: string;
|
|
197
|
-
};
|
|
253
|
+
"arrow-return-style": FlawlessRuleModule<Options$5, MessageIds$4, Readonly<TSESLint.SourceCode>>;
|
|
254
|
+
"jsx-shorthand-boolean": FlawlessRuleModule<[], "setAttributeValue", Readonly<TSESLint.SourceCode>>;
|
|
255
|
+
"jsx-shorthand-fragment": FlawlessRuleModule<Options$4, MessageIds$3, Readonly<TSESLint.SourceCode>>;
|
|
198
256
|
"naming-convention": TSESLint.RuleModule<MessageIds$2, Options$3, PluginDocumentation, TSESLint.RuleListener> & {
|
|
199
257
|
name: string;
|
|
200
258
|
};
|
|
201
|
-
"no-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
"
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
name: string;
|
|
212
|
-
};
|
|
213
|
-
purity: TSESLint.RuleModule<"impureCall", Options$1, PluginDocumentation, TSESLint.RuleListener> & {
|
|
259
|
+
"no-export-default-arrow": FlawlessRuleModule<[], "disallowExportDefaultArrow", Readonly<TSESLint.SourceCode>>;
|
|
260
|
+
"no-unnecessary-use-callback": FlawlessRuleModule<[], MessageIds$1, Readonly<TSESLint.SourceCode>>;
|
|
261
|
+
"no-unnecessary-use-memo": FlawlessRuleModule<[], MessageIds, Readonly<TSESLint.SourceCode>>;
|
|
262
|
+
"prefer-destructuring-assignment": FlawlessRuleModule<[], "default", Readonly<TSESLint.SourceCode>>;
|
|
263
|
+
"prefer-parameter-destructuring": FlawlessRuleModule<Options$2, "default", Readonly<TSESLint.SourceCode>>;
|
|
264
|
+
"prefer-read-only-props": TSESLint.RuleModule<"preferReadOnlyProps", [{
|
|
265
|
+
fixStyle?: "modifier" | "wrap";
|
|
266
|
+
importSource?: string;
|
|
267
|
+
wrapperType?: string;
|
|
268
|
+
}], PluginDocumentation, TSESLint.RuleListener> & {
|
|
214
269
|
name: string;
|
|
215
270
|
};
|
|
271
|
+
purity: FlawlessRuleModule<Options$1, "impureCall", Readonly<TSESLint.SourceCode>>;
|
|
216
272
|
"toml-sort-keys": TSESLint.RuleModule<"unsorted", Options, PluginDocumentation, TSESLint.RuleListener> & {
|
|
217
273
|
name: string;
|
|
218
274
|
};
|
|
@@ -233,30 +289,25 @@ declare const _default: {
|
|
|
233
289
|
version: string;
|
|
234
290
|
};
|
|
235
291
|
rules: {
|
|
236
|
-
"
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
"jsx-shorthand-fragment": import("${configDir}").RuleModule<MessageIds$3, Options$4, PluginDocumentation, import("${configDir}").RuleListener> & {
|
|
240
|
-
name: string;
|
|
241
|
-
};
|
|
292
|
+
"arrow-return-style": FlawlessRuleModule<Options$5, MessageIds$4, Readonly<import("${configDir}").SourceCode>>;
|
|
293
|
+
"jsx-shorthand-boolean": FlawlessRuleModule<[], "setAttributeValue", Readonly<import("${configDir}").SourceCode>>;
|
|
294
|
+
"jsx-shorthand-fragment": FlawlessRuleModule<Options$4, MessageIds$3, Readonly<import("${configDir}").SourceCode>>;
|
|
242
295
|
"naming-convention": import("${configDir}").RuleModule<MessageIds$2, Options$3, PluginDocumentation, import("${configDir}").RuleListener> & {
|
|
243
296
|
name: string;
|
|
244
297
|
};
|
|
245
|
-
"no-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
"
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
name: string;
|
|
256
|
-
};
|
|
257
|
-
purity: import("${configDir}").RuleModule<"impureCall", Options$1, PluginDocumentation, import("${configDir}").RuleListener> & {
|
|
298
|
+
"no-export-default-arrow": FlawlessRuleModule<[], "disallowExportDefaultArrow", Readonly<import("${configDir}").SourceCode>>;
|
|
299
|
+
"no-unnecessary-use-callback": FlawlessRuleModule<[], MessageIds$1, Readonly<import("${configDir}").SourceCode>>;
|
|
300
|
+
"no-unnecessary-use-memo": FlawlessRuleModule<[], MessageIds, Readonly<import("${configDir}").SourceCode>>;
|
|
301
|
+
"prefer-destructuring-assignment": FlawlessRuleModule<[], "default", Readonly<import("${configDir}").SourceCode>>;
|
|
302
|
+
"prefer-parameter-destructuring": FlawlessRuleModule<Options$2, "default", Readonly<import("${configDir}").SourceCode>>;
|
|
303
|
+
"prefer-read-only-props": import("${configDir}").RuleModule<"preferReadOnlyProps", [{
|
|
304
|
+
fixStyle?: "modifier" | "wrap";
|
|
305
|
+
importSource?: string;
|
|
306
|
+
wrapperType?: string;
|
|
307
|
+
}], PluginDocumentation, import("${configDir}").RuleListener> & {
|
|
258
308
|
name: string;
|
|
259
309
|
};
|
|
310
|
+
purity: FlawlessRuleModule<Options$1, "impureCall", Readonly<import("${configDir}").SourceCode>>;
|
|
260
311
|
"toml-sort-keys": import("${configDir}").RuleModule<"unsorted", Options, PluginDocumentation, import("${configDir}").RuleListener> & {
|
|
261
312
|
name: string;
|
|
262
313
|
};
|
|
@@ -274,30 +325,25 @@ declare const _default: {
|
|
|
274
325
|
version: string;
|
|
275
326
|
};
|
|
276
327
|
rules: {
|
|
277
|
-
"
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
"jsx-shorthand-fragment": import("${configDir}").RuleModule<MessageIds$3, Options$4, PluginDocumentation, import("${configDir}").RuleListener> & {
|
|
281
|
-
name: string;
|
|
282
|
-
};
|
|
328
|
+
"arrow-return-style": FlawlessRuleModule<Options$5, MessageIds$4, Readonly<import("${configDir}").SourceCode>>;
|
|
329
|
+
"jsx-shorthand-boolean": FlawlessRuleModule<[], "setAttributeValue", Readonly<import("${configDir}").SourceCode>>;
|
|
330
|
+
"jsx-shorthand-fragment": FlawlessRuleModule<Options$4, MessageIds$3, Readonly<import("${configDir}").SourceCode>>;
|
|
283
331
|
"naming-convention": import("${configDir}").RuleModule<MessageIds$2, Options$3, PluginDocumentation, import("${configDir}").RuleListener> & {
|
|
284
332
|
name: string;
|
|
285
333
|
};
|
|
286
|
-
"no-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
"
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
name: string;
|
|
297
|
-
};
|
|
298
|
-
purity: import("${configDir}").RuleModule<"impureCall", Options$1, PluginDocumentation, import("${configDir}").RuleListener> & {
|
|
334
|
+
"no-export-default-arrow": FlawlessRuleModule<[], "disallowExportDefaultArrow", Readonly<import("${configDir}").SourceCode>>;
|
|
335
|
+
"no-unnecessary-use-callback": FlawlessRuleModule<[], MessageIds$1, Readonly<import("${configDir}").SourceCode>>;
|
|
336
|
+
"no-unnecessary-use-memo": FlawlessRuleModule<[], MessageIds, Readonly<import("${configDir}").SourceCode>>;
|
|
337
|
+
"prefer-destructuring-assignment": FlawlessRuleModule<[], "default", Readonly<import("${configDir}").SourceCode>>;
|
|
338
|
+
"prefer-parameter-destructuring": FlawlessRuleModule<Options$2, "default", Readonly<import("${configDir}").SourceCode>>;
|
|
339
|
+
"prefer-read-only-props": import("${configDir}").RuleModule<"preferReadOnlyProps", [{
|
|
340
|
+
fixStyle?: "modifier" | "wrap";
|
|
341
|
+
importSource?: string;
|
|
342
|
+
wrapperType?: string;
|
|
343
|
+
}], PluginDocumentation, import("${configDir}").RuleListener> & {
|
|
299
344
|
name: string;
|
|
300
345
|
};
|
|
346
|
+
purity: FlawlessRuleModule<Options$1, "impureCall", Readonly<import("${configDir}").SourceCode>>;
|
|
301
347
|
"toml-sort-keys": import("${configDir}").RuleModule<"unsorted", Options, PluginDocumentation, import("${configDir}").RuleListener> & {
|
|
302
348
|
name: string;
|
|
303
349
|
};
|
|
@@ -306,8 +352,8 @@ declare const _default: {
|
|
|
306
352
|
};
|
|
307
353
|
};
|
|
308
354
|
};
|
|
309
|
-
type RuleOptions = { [K in keyof RuleDefinitions]: NonNullable<RuleDefinitions[K]["defaultOptions"]
|
|
310
|
-
type Rules = { [K in keyof RuleOptions]: Linter.RuleEntry<RuleOptions[K]
|
|
355
|
+
type RuleOptions = { [K in keyof RuleDefinitions]: NonNullable<RuleDefinitions[K]["defaultOptions"]>; };
|
|
356
|
+
type Rules = { [K in keyof RuleOptions]: Linter.RuleEntry<RuleOptions[K]>; };
|
|
311
357
|
type RuleDefinitions = typeof plugin.rules;
|
|
312
358
|
//#endregion
|
|
313
359
|
export { RuleOptions, Rules, _default as default };
|