eslint-plugin-flawless 0.1.9 → 0.1.11

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
@@ -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:
@@ -185,6 +207,7 @@ Requires [type information](https://typescript-eslint.io/linting/typed-linting).
185
207
  | [no-unnecessary-use-memo](src/rules/no-unnecessary-use-memo/documentation.md) | Disallow unnecessary usage of 'useMemo' | | |
186
208
  | [prefer-destructuring-assignment](src/rules/prefer-destructuring-assignment/documentation.md) | Enforce destructuring assignment for component props | 🔧 | |
187
209
  | [prefer-parameter-destructuring](src/rules/prefer-parameter-destructuring/documentation.md) | Enforce destructuring parameters in the function signature | 🔧 | |
210
+ | [prefer-read-only-props](src/rules/prefer-read-only-props/documentation.md) | Enforce that function component props are read-only | 🔧 | 💭 |
188
211
  | [purity](src/rules/purity/documentation.md) | Disallow impure calls such as `math.random` or `os.clock` during render | | |
189
212
  | [toml-sort-keys](src/rules/toml-sort-keys/documentation.md) | Enforce a configured sort order for TOML keys and tables | 🔧 | |
190
213
  | [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,48 @@
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
+ };
10
46
  //#endregion
11
47
  //#region src/rules/jsx-shorthand-fragment/rule.d.ts
12
48
  declare const MESSAGE_ID_NAMED = "useNamedFragment";
@@ -24,7 +60,7 @@ interface JsxShorthandFragmentOptions {
24
60
  */
25
61
  readonly mode?: Mode;
26
62
  }
27
- type Options$3 = [JsxShorthandFragmentOptions?];
63
+ type Options$4 = [JsxShorthandFragmentOptions?];
28
64
  type Mode = "element" | "syntax";
29
65
  //#endregion
30
66
  //#region src/rules/naming-convention/utils/enums.d.ts
@@ -135,7 +171,7 @@ interface NamingSelector {
135
171
  //#endregion
136
172
  //#region src/rules/naming-convention/rule.d.ts
137
173
  type MessageIds$2 = "doesNotMatchFormat" | "doesNotMatchFormatTrimmed" | "missingAffix" | "missingUnderscore" | "satisfyCustom" | "unexpectedUnderscore";
138
- type Options$2 = Array<NamingSelector>;
174
+ type Options$3 = Array<NamingSelector>;
139
175
  //#endregion
140
176
  //#region src/rules/no-unnecessary-use-callback/rule.d.ts
141
177
  declare const MESSAGE_ID_DEFAULT$1 = "default";
@@ -147,6 +183,16 @@ declare const MESSAGE_ID_DEFAULT = "default";
147
183
  declare const MESSAGE_ID_INSIDE_USE_EFFECT = "noUnnecessaryUseMemoInsideUseEffect";
148
184
  type MessageIds = typeof MESSAGE_ID_DEFAULT | typeof MESSAGE_ID_INSIDE_USE_EFFECT;
149
185
  //#endregion
186
+ //#region src/rules/prefer-parameter-destructuring/rule.d.ts
187
+ type Options$2 = [{
188
+ /**
189
+ * Whether the autofix may hoist pattern defaults and computed keys past
190
+ * earlier statements, reordering their side effects. Defaults to `true`;
191
+ * set to `false` to withhold the fix in those cases.
192
+ */
193
+ allowSideEffectReordering?: boolean;
194
+ }];
195
+ //#endregion
150
196
  //#region src/rules/purity/rule.d.ts
151
197
  interface PurityOptions {
152
198
  /**
@@ -179,30 +225,23 @@ declare const plugin: {
179
225
  version: string;
180
226
  };
181
227
  rules: {
182
- "jsx-shorthand-boolean": TSESLint.RuleModule<"setAttributeValue", [], PluginDocumentation, TSESLint.RuleListener> & {
183
- name: string;
184
- };
185
- "jsx-shorthand-fragment": TSESLint.RuleModule<MessageIds$3, Options$3, PluginDocumentation, TSESLint.RuleListener> & {
186
- name: string;
187
- };
188
- "naming-convention": TSESLint.RuleModule<MessageIds$2, Options$2, PluginDocumentation, TSESLint.RuleListener> & {
228
+ "jsx-shorthand-boolean": FlawlessRuleModule<[], "setAttributeValue", Readonly<TSESLint.SourceCode>>;
229
+ "jsx-shorthand-fragment": FlawlessRuleModule<Options$4, MessageIds$3, Readonly<TSESLint.SourceCode>>;
230
+ "naming-convention": TSESLint.RuleModule<MessageIds$2, Options$3, PluginDocumentation, TSESLint.RuleListener> & {
189
231
  name: string;
190
232
  };
191
- "no-unnecessary-use-callback": TSESLint.RuleModule<MessageIds$1, [], PluginDocumentation, TSESLint.RuleListener> & {
192
- name: string;
193
- };
194
- "no-unnecessary-use-memo": TSESLint.RuleModule<MessageIds, [], PluginDocumentation, TSESLint.RuleListener> & {
195
- name: string;
196
- };
197
- "prefer-destructuring-assignment": TSESLint.RuleModule<"default", [], PluginDocumentation, TSESLint.RuleListener> & {
198
- name: string;
199
- };
200
- "prefer-parameter-destructuring": TSESLint.RuleModule<"default", [], PluginDocumentation, TSESLint.RuleListener> & {
201
- name: string;
202
- };
203
- purity: TSESLint.RuleModule<"impureCall", Options$1, PluginDocumentation, TSESLint.RuleListener> & {
233
+ "no-unnecessary-use-callback": FlawlessRuleModule<[], MessageIds$1, Readonly<TSESLint.SourceCode>>;
234
+ "no-unnecessary-use-memo": FlawlessRuleModule<[], MessageIds, Readonly<TSESLint.SourceCode>>;
235
+ "prefer-destructuring-assignment": FlawlessRuleModule<[], "default", Readonly<TSESLint.SourceCode>>;
236
+ "prefer-parameter-destructuring": FlawlessRuleModule<Options$2, "default", Readonly<TSESLint.SourceCode>>;
237
+ "prefer-read-only-props": TSESLint.RuleModule<"preferReadOnlyProps", [{
238
+ fixStyle?: "modifier" | "wrap";
239
+ importSource?: string;
240
+ wrapperType?: string;
241
+ }], PluginDocumentation, TSESLint.RuleListener> & {
204
242
  name: string;
205
243
  };
244
+ purity: FlawlessRuleModule<Options$1, "impureCall", Readonly<TSESLint.SourceCode>>;
206
245
  "toml-sort-keys": TSESLint.RuleModule<"unsorted", Options, PluginDocumentation, TSESLint.RuleListener> & {
207
246
  name: string;
208
247
  };
@@ -223,30 +262,23 @@ declare const _default: {
223
262
  version: string;
224
263
  };
225
264
  rules: {
226
- "jsx-shorthand-boolean": import("${configDir}").RuleModule<"setAttributeValue", [], PluginDocumentation, import("${configDir}").RuleListener> & {
265
+ "jsx-shorthand-boolean": FlawlessRuleModule<[], "setAttributeValue", Readonly<import("${configDir}").SourceCode>>;
266
+ "jsx-shorthand-fragment": FlawlessRuleModule<Options$4, MessageIds$3, Readonly<import("${configDir}").SourceCode>>;
267
+ "naming-convention": import("${configDir}").RuleModule<MessageIds$2, Options$3, PluginDocumentation, import("${configDir}").RuleListener> & {
227
268
  name: string;
228
269
  };
229
- "jsx-shorthand-fragment": import("${configDir}").RuleModule<MessageIds$3, Options$3, PluginDocumentation, import("${configDir}").RuleListener> & {
230
- name: string;
231
- };
232
- "naming-convention": import("${configDir}").RuleModule<MessageIds$2, Options$2, PluginDocumentation, import("${configDir}").RuleListener> & {
233
- name: string;
234
- };
235
- "no-unnecessary-use-callback": import("${configDir}").RuleModule<MessageIds$1, [], PluginDocumentation, import("${configDir}").RuleListener> & {
236
- name: string;
237
- };
238
- "no-unnecessary-use-memo": import("${configDir}").RuleModule<MessageIds, [], PluginDocumentation, import("${configDir}").RuleListener> & {
239
- name: string;
240
- };
241
- "prefer-destructuring-assignment": import("${configDir}").RuleModule<"default", [], PluginDocumentation, import("${configDir}").RuleListener> & {
242
- name: string;
243
- };
244
- "prefer-parameter-destructuring": import("${configDir}").RuleModule<"default", [], PluginDocumentation, import("${configDir}").RuleListener> & {
245
- name: string;
246
- };
247
- purity: import("${configDir}").RuleModule<"impureCall", Options$1, PluginDocumentation, import("${configDir}").RuleListener> & {
270
+ "no-unnecessary-use-callback": FlawlessRuleModule<[], MessageIds$1, Readonly<import("${configDir}").SourceCode>>;
271
+ "no-unnecessary-use-memo": FlawlessRuleModule<[], MessageIds, Readonly<import("${configDir}").SourceCode>>;
272
+ "prefer-destructuring-assignment": FlawlessRuleModule<[], "default", Readonly<import("${configDir}").SourceCode>>;
273
+ "prefer-parameter-destructuring": FlawlessRuleModule<Options$2, "default", Readonly<import("${configDir}").SourceCode>>;
274
+ "prefer-read-only-props": import("${configDir}").RuleModule<"preferReadOnlyProps", [{
275
+ fixStyle?: "modifier" | "wrap";
276
+ importSource?: string;
277
+ wrapperType?: string;
278
+ }], PluginDocumentation, import("${configDir}").RuleListener> & {
248
279
  name: string;
249
280
  };
281
+ purity: FlawlessRuleModule<Options$1, "impureCall", Readonly<import("${configDir}").SourceCode>>;
250
282
  "toml-sort-keys": import("${configDir}").RuleModule<"unsorted", Options, PluginDocumentation, import("${configDir}").RuleListener> & {
251
283
  name: string;
252
284
  };
@@ -264,30 +296,23 @@ declare const _default: {
264
296
  version: string;
265
297
  };
266
298
  rules: {
267
- "jsx-shorthand-boolean": import("${configDir}").RuleModule<"setAttributeValue", [], PluginDocumentation, import("${configDir}").RuleListener> & {
268
- name: string;
269
- };
270
- "jsx-shorthand-fragment": import("${configDir}").RuleModule<MessageIds$3, Options$3, PluginDocumentation, import("${configDir}").RuleListener> & {
271
- name: string;
272
- };
273
- "naming-convention": import("${configDir}").RuleModule<MessageIds$2, Options$2, PluginDocumentation, import("${configDir}").RuleListener> & {
274
- name: string;
275
- };
276
- "no-unnecessary-use-callback": import("${configDir}").RuleModule<MessageIds$1, [], PluginDocumentation, import("${configDir}").RuleListener> & {
277
- name: string;
278
- };
279
- "no-unnecessary-use-memo": import("${configDir}").RuleModule<MessageIds, [], PluginDocumentation, import("${configDir}").RuleListener> & {
280
- name: string;
281
- };
282
- "prefer-destructuring-assignment": import("${configDir}").RuleModule<"default", [], PluginDocumentation, import("${configDir}").RuleListener> & {
283
- name: string;
284
- };
285
- "prefer-parameter-destructuring": import("${configDir}").RuleModule<"default", [], PluginDocumentation, import("${configDir}").RuleListener> & {
299
+ "jsx-shorthand-boolean": FlawlessRuleModule<[], "setAttributeValue", Readonly<import("${configDir}").SourceCode>>;
300
+ "jsx-shorthand-fragment": FlawlessRuleModule<Options$4, MessageIds$3, Readonly<import("${configDir}").SourceCode>>;
301
+ "naming-convention": import("${configDir}").RuleModule<MessageIds$2, Options$3, PluginDocumentation, import("${configDir}").RuleListener> & {
286
302
  name: string;
287
303
  };
288
- purity: import("${configDir}").RuleModule<"impureCall", Options$1, PluginDocumentation, import("${configDir}").RuleListener> & {
304
+ "no-unnecessary-use-callback": FlawlessRuleModule<[], MessageIds$1, Readonly<import("${configDir}").SourceCode>>;
305
+ "no-unnecessary-use-memo": FlawlessRuleModule<[], MessageIds, Readonly<import("${configDir}").SourceCode>>;
306
+ "prefer-destructuring-assignment": FlawlessRuleModule<[], "default", Readonly<import("${configDir}").SourceCode>>;
307
+ "prefer-parameter-destructuring": FlawlessRuleModule<Options$2, "default", Readonly<import("${configDir}").SourceCode>>;
308
+ "prefer-read-only-props": import("${configDir}").RuleModule<"preferReadOnlyProps", [{
309
+ fixStyle?: "modifier" | "wrap";
310
+ importSource?: string;
311
+ wrapperType?: string;
312
+ }], PluginDocumentation, import("${configDir}").RuleListener> & {
289
313
  name: string;
290
314
  };
315
+ purity: FlawlessRuleModule<Options$1, "impureCall", Readonly<import("${configDir}").SourceCode>>;
291
316
  "toml-sort-keys": import("${configDir}").RuleModule<"unsorted", Options, PluginDocumentation, import("${configDir}").RuleListener> & {
292
317
  name: string;
293
318
  };
@@ -296,8 +321,8 @@ declare const _default: {
296
321
  };
297
322
  };
298
323
  };
299
- type RuleOptions = { [K in keyof RuleDefinitions]: NonNullable<RuleDefinitions[K]["defaultOptions"]> };
300
- type Rules = { [K in keyof RuleOptions]: Linter.RuleEntry<RuleOptions[K]> };
324
+ type RuleOptions = { [K in keyof RuleDefinitions]: NonNullable<RuleDefinitions[K]["defaultOptions"]>; };
325
+ type Rules = { [K in keyof RuleOptions]: Linter.RuleEntry<RuleOptions[K]>; };
301
326
  type RuleDefinitions = typeof plugin.rules;
302
327
  //#endregion
303
328
  export { RuleOptions, Rules, _default as default };