eslint-plugin-flawless 0.1.10 → 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";
@@ -189,30 +225,23 @@ declare const plugin: {
189
225
  version: string;
190
226
  };
191
227
  rules: {
192
- "jsx-shorthand-boolean": TSESLint.RuleModule<"setAttributeValue", [], PluginDocumentation, TSESLint.RuleListener> & {
193
- name: string;
194
- };
195
- "jsx-shorthand-fragment": TSESLint.RuleModule<MessageIds$3, Options$4, PluginDocumentation, TSESLint.RuleListener> & {
196
- name: string;
197
- };
228
+ "jsx-shorthand-boolean": FlawlessRuleModule<[], "setAttributeValue", Readonly<TSESLint.SourceCode>>;
229
+ "jsx-shorthand-fragment": FlawlessRuleModule<Options$4, MessageIds$3, Readonly<TSESLint.SourceCode>>;
198
230
  "naming-convention": TSESLint.RuleModule<MessageIds$2, Options$3, PluginDocumentation, TSESLint.RuleListener> & {
199
231
  name: string;
200
232
  };
201
- "no-unnecessary-use-callback": TSESLint.RuleModule<MessageIds$1, [], PluginDocumentation, TSESLint.RuleListener> & {
202
- name: string;
203
- };
204
- "no-unnecessary-use-memo": TSESLint.RuleModule<MessageIds, [], PluginDocumentation, TSESLint.RuleListener> & {
205
- name: string;
206
- };
207
- "prefer-destructuring-assignment": TSESLint.RuleModule<"default", [], PluginDocumentation, TSESLint.RuleListener> & {
208
- name: string;
209
- };
210
- "prefer-parameter-destructuring": TSESLint.RuleModule<"default", Options$2, PluginDocumentation, TSESLint.RuleListener> & {
211
- name: string;
212
- };
213
- 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> & {
214
242
  name: string;
215
243
  };
244
+ purity: FlawlessRuleModule<Options$1, "impureCall", Readonly<TSESLint.SourceCode>>;
216
245
  "toml-sort-keys": TSESLint.RuleModule<"unsorted", Options, PluginDocumentation, TSESLint.RuleListener> & {
217
246
  name: string;
218
247
  };
@@ -233,30 +262,23 @@ declare const _default: {
233
262
  version: string;
234
263
  };
235
264
  rules: {
236
- "jsx-shorthand-boolean": import("${configDir}").RuleModule<"setAttributeValue", [], PluginDocumentation, import("${configDir}").RuleListener> & {
237
- name: string;
238
- };
239
- "jsx-shorthand-fragment": import("${configDir}").RuleModule<MessageIds$3, Options$4, PluginDocumentation, import("${configDir}").RuleListener> & {
240
- name: string;
241
- };
265
+ "jsx-shorthand-boolean": FlawlessRuleModule<[], "setAttributeValue", Readonly<import("${configDir}").SourceCode>>;
266
+ "jsx-shorthand-fragment": FlawlessRuleModule<Options$4, MessageIds$3, Readonly<import("${configDir}").SourceCode>>;
242
267
  "naming-convention": import("${configDir}").RuleModule<MessageIds$2, Options$3, PluginDocumentation, import("${configDir}").RuleListener> & {
243
268
  name: string;
244
269
  };
245
- "no-unnecessary-use-callback": import("${configDir}").RuleModule<MessageIds$1, [], PluginDocumentation, import("${configDir}").RuleListener> & {
246
- name: string;
247
- };
248
- "no-unnecessary-use-memo": import("${configDir}").RuleModule<MessageIds, [], PluginDocumentation, import("${configDir}").RuleListener> & {
249
- name: string;
250
- };
251
- "prefer-destructuring-assignment": import("${configDir}").RuleModule<"default", [], PluginDocumentation, import("${configDir}").RuleListener> & {
252
- name: string;
253
- };
254
- "prefer-parameter-destructuring": import("${configDir}").RuleModule<"default", Options$2, PluginDocumentation, import("${configDir}").RuleListener> & {
255
- name: string;
256
- };
257
- 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> & {
258
279
  name: string;
259
280
  };
281
+ purity: FlawlessRuleModule<Options$1, "impureCall", Readonly<import("${configDir}").SourceCode>>;
260
282
  "toml-sort-keys": import("${configDir}").RuleModule<"unsorted", Options, PluginDocumentation, import("${configDir}").RuleListener> & {
261
283
  name: string;
262
284
  };
@@ -274,30 +296,23 @@ declare const _default: {
274
296
  version: string;
275
297
  };
276
298
  rules: {
277
- "jsx-shorthand-boolean": import("${configDir}").RuleModule<"setAttributeValue", [], PluginDocumentation, import("${configDir}").RuleListener> & {
278
- name: string;
279
- };
280
- "jsx-shorthand-fragment": import("${configDir}").RuleModule<MessageIds$3, Options$4, PluginDocumentation, import("${configDir}").RuleListener> & {
281
- name: string;
282
- };
299
+ "jsx-shorthand-boolean": FlawlessRuleModule<[], "setAttributeValue", Readonly<import("${configDir}").SourceCode>>;
300
+ "jsx-shorthand-fragment": FlawlessRuleModule<Options$4, MessageIds$3, Readonly<import("${configDir}").SourceCode>>;
283
301
  "naming-convention": import("${configDir}").RuleModule<MessageIds$2, Options$3, PluginDocumentation, import("${configDir}").RuleListener> & {
284
302
  name: string;
285
303
  };
286
- "no-unnecessary-use-callback": import("${configDir}").RuleModule<MessageIds$1, [], PluginDocumentation, import("${configDir}").RuleListener> & {
287
- name: string;
288
- };
289
- "no-unnecessary-use-memo": import("${configDir}").RuleModule<MessageIds, [], PluginDocumentation, import("${configDir}").RuleListener> & {
290
- name: string;
291
- };
292
- "prefer-destructuring-assignment": import("${configDir}").RuleModule<"default", [], PluginDocumentation, import("${configDir}").RuleListener> & {
293
- name: string;
294
- };
295
- "prefer-parameter-destructuring": import("${configDir}").RuleModule<"default", Options$2, PluginDocumentation, import("${configDir}").RuleListener> & {
296
- name: string;
297
- };
298
- 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> & {
299
313
  name: string;
300
314
  };
315
+ purity: FlawlessRuleModule<Options$1, "impureCall", Readonly<import("${configDir}").SourceCode>>;
301
316
  "toml-sort-keys": import("${configDir}").RuleModule<"unsorted", Options, PluginDocumentation, import("${configDir}").RuleListener> & {
302
317
  name: string;
303
318
  };
@@ -306,8 +321,8 @@ declare const _default: {
306
321
  };
307
322
  };
308
323
  };
309
- type RuleOptions = { [K in keyof RuleDefinitions]: NonNullable<RuleDefinitions[K]["defaultOptions"]> };
310
- 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]>; };
311
326
  type RuleDefinitions = typeof plugin.rules;
312
327
  //#endregion
313
328
  export { RuleOptions, Rules, _default as default };