@chungwei/oxlint-plugin 0.0.0-stage → 0.1.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 +86 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +16 -0
- package/dist/rules/no-em-dash.d.ts +1 -0
- package/dist/rules/no-em-dash.js +38 -0
- package/dist/rules/no-inline-component-props.d.ts +1 -0
- package/dist/rules/no-inline-component-props.js +176 -0
- package/dist/rules/prefer-jsx-short-circuit.d.ts +1 -0
- package/dist/rules/prefer-jsx-short-circuit.js +121 -0
- package/package.json +34 -3
package/README.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@chungwei/oxlint-plugin`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Custom Oxlint rules migrated from paint-mixer-app.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install -D @chungwei/oxlint-plugin oxlint
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Requires Oxlint 1.79.0 or later. The rules are authored in TypeScript and published as unbundled JavaScript with TypeScript declarations. Consumers need no build step, TypeScript loader, or Vite+ runtime.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
Add the plugin and enable the rules in `oxlint.config.ts`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { defineConfig } from "oxlint";
|
|
19
|
+
|
|
20
|
+
export default defineConfig({
|
|
21
|
+
jsPlugins: [{ name: "chungwei", specifier: "@chungwei/oxlint-plugin" }],
|
|
22
|
+
rules: {
|
|
23
|
+
"chungwei/no-em-dash": "error",
|
|
24
|
+
"chungwei/no-inline-component-props": "error",
|
|
25
|
+
"chungwei/prefer-jsx-short-circuit": "error",
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The same `jsPlugins` and `rules` entries work under `lint` in a Vite+ config. All rules accept no options. Enable them individually when using this plugin directly. `@chungwei/oxlint-config` installs the plugin and enables all three rules as errors.
|
|
31
|
+
|
|
32
|
+
The plugin is also available as both a default and a named export:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import plugin from "@chungwei/oxlint-plugin";
|
|
36
|
+
import { plugin as namedPlugin } from "@chungwei/oxlint-plugin";
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
When replacing the app's local plugin, use the alias `custom` instead of `chungwei` to keep existing `custom/*` rule settings and disable comments.
|
|
40
|
+
|
|
41
|
+
## Rules
|
|
42
|
+
|
|
43
|
+
| Rule | Behavior | Fix |
|
|
44
|
+
| --------------------------- | ---------------------------------------------------------------------------------------- | ----------------- |
|
|
45
|
+
| `no-em-dash` | Disallows em dashes in string literals, template text, JSX text, and JSX attribute text. | None |
|
|
46
|
+
| `no-inline-component-props` | Requires named types for destructured component props in `.tsx` files. | None |
|
|
47
|
+
| `prefer-jsx-short-circuit` | Prefers short-circuit rendering for JSX child ternaries with one empty branch. | Editor suggestion |
|
|
48
|
+
|
|
49
|
+
### `no-em-dash`
|
|
50
|
+
|
|
51
|
+
Checks decoded strings and templates, including Unicode escapes. JSX text and literal JSX attributes also recognize `—`, decimal `—`, and hexadecimal `—` entities, including leading zeros. Comments, regular expressions, and entity text in ordinary JavaScript strings are allowed.
|
|
52
|
+
|
|
53
|
+
### `no-inline-component-props`
|
|
54
|
+
|
|
55
|
+
Reports inline object types within the first parameter's annotation when props are destructured. It recognizes uppercase function and variable names, `memo` and `forwardRef` wrappers, and default exports that return JSX. React import aliases and shadowed bindings are taken into account.
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
// Reported
|
|
59
|
+
function Panel({ title }: { title: string }) {
|
|
60
|
+
return <h2>{title}</h2>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Allowed
|
|
64
|
+
interface PanelProps {
|
|
65
|
+
title: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function Panel({ title }: PanelProps) {
|
|
69
|
+
return <h2>{title}</h2>;
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Non-destructured props, named types, ordinary helper functions, and files other than `.tsx` are allowed. The rule does not rename or extract types automatically.
|
|
74
|
+
|
|
75
|
+
### `prefer-jsx-short-circuit`
|
|
76
|
+
|
|
77
|
+
Reports a ternary directly in JSX children when one branch is JSX and the other is `null`, `false`, or unshadowed `undefined`.
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
// Reported
|
|
81
|
+
<div>{count ? <Panel /> : null}</div>;
|
|
82
|
+
|
|
83
|
+
// Suggested
|
|
84
|
+
<div>{!!count && <Panel />}</div>;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Suggestions coerce conditions to booleans when needed so falsy numbers do not render as text. For an empty truthy branch, the suggestion negates the condition. The rule offers no suggestion if replacement would discard a comment. It does not automatically fix code, and does not check ternaries in attributes, callbacks, or ordinary return expressions.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { eslintCompatPlugin } from "@oxlint/plugins";
|
|
2
|
+
import { noEmDashRule } from "./rules/no-em-dash.js";
|
|
3
|
+
import { noInlineComponentPropsRule } from "./rules/no-inline-component-props.js";
|
|
4
|
+
import { preferJsxShortCircuitRule } from "./rules/prefer-jsx-short-circuit.js";
|
|
5
|
+
const plugin = eslintCompatPlugin({
|
|
6
|
+
meta: {
|
|
7
|
+
name: "@chungwei/oxlint-plugin",
|
|
8
|
+
},
|
|
9
|
+
rules: {
|
|
10
|
+
"no-em-dash": noEmDashRule,
|
|
11
|
+
"no-inline-component-props": noInlineComponentPropsRule,
|
|
12
|
+
"prefer-jsx-short-circuit": preferJsxShortCircuitRule,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
export { plugin };
|
|
16
|
+
export default plugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const noEmDashRule: import("@oxlint/plugins").Rule;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
const emDash = /\u2014/;
|
|
3
|
+
const jsxEmDash = /\u2014|&(?:mdash|#0*8212|#[xX]0*2014);/;
|
|
4
|
+
export const noEmDashRule = defineRule({
|
|
5
|
+
meta: {
|
|
6
|
+
type: "suggestion",
|
|
7
|
+
docs: {
|
|
8
|
+
description: "Disallow em dashes in source text",
|
|
9
|
+
},
|
|
10
|
+
schema: [],
|
|
11
|
+
messages: {
|
|
12
|
+
noEmDash: "Do not use em dashes in text. Use words or other punctuation.",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
createOnce(context) {
|
|
16
|
+
return {
|
|
17
|
+
Literal(node) {
|
|
18
|
+
const hasEmDash = typeof node.value === "string" &&
|
|
19
|
+
(node.parent.type === "JSXAttribute"
|
|
20
|
+
? jsxEmDash.test(node.value)
|
|
21
|
+
: emDash.test(node.value));
|
|
22
|
+
if (hasEmDash) {
|
|
23
|
+
context.report({ node, messageId: "noEmDash" });
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
JSXText(node) {
|
|
27
|
+
if (jsxEmDash.test(node.value)) {
|
|
28
|
+
context.report({ node, messageId: "noEmDash" });
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
TemplateElement(node) {
|
|
32
|
+
if (emDash.test(node.value.cooked ?? node.value.raw)) {
|
|
33
|
+
context.report({ node, messageId: "noEmDash" });
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const noInlineComponentPropsRule: import("@oxlint/plugins").Rule;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
function returnsJsx(value) {
|
|
3
|
+
if (!value) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
switch (value.type) {
|
|
7
|
+
case "JSXElement":
|
|
8
|
+
case "JSXFragment":
|
|
9
|
+
return true;
|
|
10
|
+
case "ReturnStatement":
|
|
11
|
+
case "AwaitExpression":
|
|
12
|
+
return returnsJsx(value.argument);
|
|
13
|
+
case "BlockStatement":
|
|
14
|
+
return value.body.some(returnsJsx);
|
|
15
|
+
case "SwitchStatement":
|
|
16
|
+
return value.cases.some(returnsJsx);
|
|
17
|
+
case "SwitchCase":
|
|
18
|
+
return value.consequent.some(returnsJsx);
|
|
19
|
+
case "TryStatement":
|
|
20
|
+
return returnsJsx(value.block) || returnsJsx(value.handler) || returnsJsx(value.finalizer);
|
|
21
|
+
case "CatchClause":
|
|
22
|
+
case "DoWhileStatement":
|
|
23
|
+
case "WhileStatement":
|
|
24
|
+
case "ForStatement":
|
|
25
|
+
case "ForInStatement":
|
|
26
|
+
case "ForOfStatement":
|
|
27
|
+
case "LabeledStatement":
|
|
28
|
+
case "WithStatement":
|
|
29
|
+
return returnsJsx(value.body);
|
|
30
|
+
case "IfStatement":
|
|
31
|
+
case "ConditionalExpression":
|
|
32
|
+
return returnsJsx(value.consequent) || returnsJsx(value.alternate);
|
|
33
|
+
case "LogicalExpression":
|
|
34
|
+
return returnsJsx(value.left) || returnsJsx(value.right);
|
|
35
|
+
case "ArrayExpression":
|
|
36
|
+
return value.elements.some(returnsJsx);
|
|
37
|
+
case "SequenceExpression":
|
|
38
|
+
return returnsJsx(value.expressions.at(-1) ?? null);
|
|
39
|
+
case "TSAsExpression":
|
|
40
|
+
case "TSSatisfiesExpression":
|
|
41
|
+
case "TSNonNullExpression":
|
|
42
|
+
case "TSTypeAssertion":
|
|
43
|
+
case "ParenthesizedExpression":
|
|
44
|
+
return returnsJsx(value.expression);
|
|
45
|
+
default:
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export const noInlineComponentPropsRule = defineRule({
|
|
50
|
+
meta: {
|
|
51
|
+
type: "suggestion",
|
|
52
|
+
docs: {
|
|
53
|
+
description: "Disallow inline object types in destructured component props",
|
|
54
|
+
},
|
|
55
|
+
schema: [],
|
|
56
|
+
messages: {
|
|
57
|
+
namedProps: "Declare a named props interface above the component instead of using an inline object type on destructured props.",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
create(context) {
|
|
61
|
+
const reported = new Set();
|
|
62
|
+
return {
|
|
63
|
+
TSTypeLiteral(node) {
|
|
64
|
+
if (!context.filename.endsWith(".tsx")) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
let component = node.parent;
|
|
68
|
+
while (component.type !== "FunctionDeclaration" &&
|
|
69
|
+
component.type !== "FunctionExpression" &&
|
|
70
|
+
component.type !== "ArrowFunctionExpression") {
|
|
71
|
+
if (component.type === "Program") {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
component = component.parent;
|
|
75
|
+
}
|
|
76
|
+
const parameter = component.params[0];
|
|
77
|
+
const props = parameter?.type === "AssignmentPattern" ? parameter.left : parameter;
|
|
78
|
+
if (props?.type !== "ObjectPattern" && props?.type !== "ArrayPattern") {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const annotation = props.typeAnnotation;
|
|
82
|
+
if (!annotation ||
|
|
83
|
+
node.start < annotation.start ||
|
|
84
|
+
node.end > annotation.end ||
|
|
85
|
+
reported.has(annotation.start)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
let expression = component;
|
|
89
|
+
let owner = expression.parent;
|
|
90
|
+
let hasReactWrapper = false;
|
|
91
|
+
while (true) {
|
|
92
|
+
if (owner.type === "TSAsExpression" ||
|
|
93
|
+
owner.type === "TSSatisfiesExpression" ||
|
|
94
|
+
owner.type === "TSNonNullExpression" ||
|
|
95
|
+
owner.type === "TSTypeAssertion" ||
|
|
96
|
+
owner.type === "ParenthesizedExpression") {
|
|
97
|
+
expression = owner;
|
|
98
|
+
owner = owner.parent;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (owner.type === "CallExpression" && isReactWrapper(owner.callee)) {
|
|
102
|
+
if (owner.arguments[0] !== expression) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
hasReactWrapper = true;
|
|
106
|
+
expression = owner;
|
|
107
|
+
owner = owner.parent;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
const variableName = owner.type === "VariableDeclarator" && owner.id.type === "Identifier"
|
|
113
|
+
? owner.id.name
|
|
114
|
+
: null;
|
|
115
|
+
if (!hasReactWrapper &&
|
|
116
|
+
![component.id?.name, variableName].some((name) => name && /^[A-Z]/.test(name)) &&
|
|
117
|
+
!(owner.type === "ExportDefaultDeclaration" && returnsJsx(component.body))) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
reported.add(annotation.start);
|
|
121
|
+
context.report({ node: annotation, messageId: "namedProps" });
|
|
122
|
+
function isReactWrapper(callee) {
|
|
123
|
+
if (callee.type === "Identifier") {
|
|
124
|
+
const imported = reactImportName(callee);
|
|
125
|
+
return imported === "memo" || imported === "forwardRef";
|
|
126
|
+
}
|
|
127
|
+
if (callee.type !== "MemberExpression" || reactImportName(callee.object) !== "*") {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
const name = !callee.computed && callee.property.type === "Identifier"
|
|
131
|
+
? callee.property.name
|
|
132
|
+
: callee.property.type === "Literal"
|
|
133
|
+
? callee.property.value
|
|
134
|
+
: null;
|
|
135
|
+
return name === "memo" || name === "forwardRef";
|
|
136
|
+
}
|
|
137
|
+
function reactImportName(value) {
|
|
138
|
+
if (value.type !== "Identifier") {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
let scope = context.sourceCode.getScope(value);
|
|
142
|
+
while (true) {
|
|
143
|
+
const binding = scope.set.get(value.name);
|
|
144
|
+
if (binding) {
|
|
145
|
+
const definition = binding.defs[0];
|
|
146
|
+
if (definition?.type !== "ImportBinding") {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
const specifier = definition.node;
|
|
150
|
+
const declaration = specifier.parent;
|
|
151
|
+
if (declaration?.type !== "ImportDeclaration" ||
|
|
152
|
+
declaration.source.value !== "react" ||
|
|
153
|
+
declaration.importKind === "type") {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
if (specifier.type === "ImportSpecifier") {
|
|
157
|
+
if (specifier.importKind === "type") {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
return specifier.imported.type === "Identifier"
|
|
161
|
+
? specifier.imported.name
|
|
162
|
+
: specifier.imported.value;
|
|
163
|
+
}
|
|
164
|
+
return "*";
|
|
165
|
+
}
|
|
166
|
+
if (!scope.upper) {
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
scope = scope.upper;
|
|
170
|
+
}
|
|
171
|
+
return value.name === "React" ? "*" : value.name;
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const preferJsxShortCircuitRule: import("@oxlint/plugins").Rule;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { defineRule } from "@oxlint/plugins";
|
|
2
|
+
const booleanOperators = new Set([
|
|
3
|
+
"==",
|
|
4
|
+
"===",
|
|
5
|
+
"!=",
|
|
6
|
+
"!==",
|
|
7
|
+
"<",
|
|
8
|
+
"<=",
|
|
9
|
+
">",
|
|
10
|
+
">=",
|
|
11
|
+
"in",
|
|
12
|
+
"instanceof",
|
|
13
|
+
]);
|
|
14
|
+
function unwrap(node) {
|
|
15
|
+
while (node.type === "ParenthesizedExpression") {
|
|
16
|
+
node = node.expression;
|
|
17
|
+
}
|
|
18
|
+
return node;
|
|
19
|
+
}
|
|
20
|
+
function isJsx(node) {
|
|
21
|
+
const expression = unwrap(node);
|
|
22
|
+
return expression.type === "JSXElement" || expression.type === "JSXFragment";
|
|
23
|
+
}
|
|
24
|
+
function isEmptyRender(node, sourceCode) {
|
|
25
|
+
const expression = unwrap(node);
|
|
26
|
+
if (expression.type === "Literal") {
|
|
27
|
+
return expression.value === null || expression.value === false;
|
|
28
|
+
}
|
|
29
|
+
if (expression.type !== "Identifier" || expression.name !== "undefined") {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
let scope = sourceCode.getScope(expression);
|
|
33
|
+
while (true) {
|
|
34
|
+
const binding = scope.set.get("undefined");
|
|
35
|
+
if (binding) {
|
|
36
|
+
return binding.defs.length === 0;
|
|
37
|
+
}
|
|
38
|
+
if (!scope.upper) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
scope = scope.upper;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function isBoolean(node) {
|
|
45
|
+
const expression = unwrap(node);
|
|
46
|
+
return ((expression.type === "Literal" && typeof expression.value === "boolean") ||
|
|
47
|
+
(expression.type === "UnaryExpression" && expression.operator === "!") ||
|
|
48
|
+
(expression.type === "BinaryExpression" && booleanOperators.has(expression.operator)));
|
|
49
|
+
}
|
|
50
|
+
function unaryOperand(node, sourceCode) {
|
|
51
|
+
const text = sourceCode.getText(node);
|
|
52
|
+
return node.type === "Identifier" ||
|
|
53
|
+
node.type === "MemberExpression" ||
|
|
54
|
+
node.type === "CallExpression" ||
|
|
55
|
+
node.type === "ChainExpression" ||
|
|
56
|
+
node.type === "ThisExpression" ||
|
|
57
|
+
node.type === "ParenthesizedExpression"
|
|
58
|
+
? text
|
|
59
|
+
: `(${text})`;
|
|
60
|
+
}
|
|
61
|
+
function isJsxChild(node) {
|
|
62
|
+
let parent = node.parent;
|
|
63
|
+
while (parent?.type === "ParenthesizedExpression") {
|
|
64
|
+
parent = parent.parent;
|
|
65
|
+
}
|
|
66
|
+
return (parent?.type === "JSXExpressionContainer" &&
|
|
67
|
+
(parent.parent.type === "JSXElement" || parent.parent.type === "JSXFragment"));
|
|
68
|
+
}
|
|
69
|
+
export const preferJsxShortCircuitRule = defineRule({
|
|
70
|
+
meta: {
|
|
71
|
+
type: "suggestion",
|
|
72
|
+
docs: {
|
|
73
|
+
description: "Prefer short-circuit rendering when one JSX ternary branch renders nothing",
|
|
74
|
+
},
|
|
75
|
+
hasSuggestions: true,
|
|
76
|
+
schema: [],
|
|
77
|
+
messages: {
|
|
78
|
+
preferShortCircuit: "Prefer short-circuit rendering when one ternary branch renders nothing.",
|
|
79
|
+
replaceWithShortCircuit: "Replace the ternary with short-circuit rendering.",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
createOnce(context) {
|
|
83
|
+
return {
|
|
84
|
+
ConditionalExpression(node) {
|
|
85
|
+
if (!isJsxChild(node)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const { sourceCode } = context;
|
|
89
|
+
const jsxWhenTruthy = isJsx(node.consequent) && isEmptyRender(node.alternate, sourceCode);
|
|
90
|
+
const jsxWhenFalsy = isEmptyRender(node.consequent, sourceCode) && isJsx(node.alternate);
|
|
91
|
+
if (!jsxWhenTruthy && !jsxWhenFalsy) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const renderedNode = jsxWhenTruthy ? node.consequent : node.alternate;
|
|
95
|
+
const operand = unaryOperand(node.test, sourceCode);
|
|
96
|
+
const condition = jsxWhenTruthy
|
|
97
|
+
? isBoolean(node.test)
|
|
98
|
+
? sourceCode.getText(node.test)
|
|
99
|
+
: `!!${operand}`
|
|
100
|
+
: `!${operand}`;
|
|
101
|
+
const losesComments = sourceCode
|
|
102
|
+
.getCommentsInside(node)
|
|
103
|
+
.some((comment) => ![node.test, renderedNode].some((retained) => comment.start >= retained.start && comment.end <= retained.end));
|
|
104
|
+
context.report({
|
|
105
|
+
node,
|
|
106
|
+
messageId: "preferShortCircuit",
|
|
107
|
+
suggest: losesComments
|
|
108
|
+
? []
|
|
109
|
+
: [
|
|
110
|
+
{
|
|
111
|
+
messageId: "replaceWithShortCircuit",
|
|
112
|
+
fix(fixer) {
|
|
113
|
+
return fixer.replaceText(node, `${condition} && ${sourceCode.getText(renderedNode)}`);
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chungwei/oxlint-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Custom Oxlint rules for source text and React components",
|
|
5
|
+
"repository": {
|
|
6
|
+
"url": "https://github.com/chungweileong94/oxlint-collections",
|
|
7
|
+
"directory": "packages/oxlint-plugin"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@oxlint/plugins": "^1.79.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"oxlint": "1.79.0",
|
|
29
|
+
"typescript": "^7.0.2"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"oxlint": ">=1.79.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc --project tsconfig.build.json"
|
|
36
|
+
}
|
|
6
37
|
}
|