oxlint-plugin-react-native 0.1.0 → 0.2.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 +1 -1
- package/dist/rules/no-unused-styles.js +30 -1
- package/dist/util/stylesheet.js +2 -1
- package/package.json +18 -6
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ In your Oxlint config (e.g. `.oxlintrc.json`), register the plugin by **name** a
|
|
|
52
52
|
| [no-inline-styles](docs/no-inline-styles.md) | Disallow inline style objects; prefer `StyleSheet.create` | — |
|
|
53
53
|
| [no-raw-text](docs/no-raw-text.md) | Require text inside `<Text>` (or allowed components) | — |
|
|
54
54
|
| [no-single-element-style-arrays](docs/no-single-element-style-arrays.md) | Disallow single-element style arrays (`style={[x]}`) | ✅ |
|
|
55
|
-
| [no-unused-styles](docs/no-unused-styles.md) | Report unused styles from `StyleSheet.create` |
|
|
55
|
+
| [no-unused-styles](docs/no-unused-styles.md) | Report unused styles from `StyleSheet.create` | ✅ |
|
|
56
56
|
| [sort-styles](docs/sort-styles.md) | Enforce order of class names and style properties | ✅ |
|
|
57
57
|
|
|
58
58
|
Each rule is documented in the [docs](docs/) folder with examples and options.
|
|
@@ -14,7 +14,35 @@ const rule = detect((context, components) => {
|
|
|
14
14
|
".",
|
|
15
15
|
node.key.name,
|
|
16
16
|
].join("");
|
|
17
|
-
context.report({
|
|
17
|
+
context.report({
|
|
18
|
+
node,
|
|
19
|
+
message,
|
|
20
|
+
fix(fixer) {
|
|
21
|
+
const parent = node.parent;
|
|
22
|
+
if (!parent || !parent.properties) {
|
|
23
|
+
return fixer.remove(node);
|
|
24
|
+
}
|
|
25
|
+
const properties = parent.properties;
|
|
26
|
+
const index = properties.indexOf(node);
|
|
27
|
+
if (index === -1)
|
|
28
|
+
return fixer.remove(node);
|
|
29
|
+
let removeStart;
|
|
30
|
+
let removeEnd;
|
|
31
|
+
if (index === 0) {
|
|
32
|
+
removeStart = node.range[0];
|
|
33
|
+
removeEnd =
|
|
34
|
+
properties.length > 1
|
|
35
|
+
? properties[1].range[0]
|
|
36
|
+
: node.range[1];
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const prev = properties[index - 1];
|
|
40
|
+
removeStart = prev.range[1];
|
|
41
|
+
removeEnd = node.range[1];
|
|
42
|
+
}
|
|
43
|
+
return fixer.removeRange([removeStart, removeEnd]);
|
|
44
|
+
},
|
|
45
|
+
});
|
|
18
46
|
});
|
|
19
47
|
}
|
|
20
48
|
});
|
|
@@ -65,6 +93,7 @@ const rule = detect((context, components) => {
|
|
|
65
93
|
export default {
|
|
66
94
|
meta: {
|
|
67
95
|
schema: [],
|
|
96
|
+
fixable: "code",
|
|
68
97
|
},
|
|
69
98
|
createOnce: rule,
|
|
70
99
|
};
|
package/dist/util/stylesheet.js
CHANGED
|
@@ -86,7 +86,8 @@ export const astHelpers = {
|
|
|
86
86
|
if (!declaration)
|
|
87
87
|
return false;
|
|
88
88
|
// export const styles = StyleSheet.create(...)
|
|
89
|
-
if (declaration.parent &&
|
|
89
|
+
if (declaration.parent &&
|
|
90
|
+
declaration.parent.type === "ExportNamedDeclaration")
|
|
90
91
|
return true;
|
|
91
92
|
return false;
|
|
92
93
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oxlint-plugin-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React Native specific linting rules for Oxlint",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"oxlint",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
"format": "oxfmt",
|
|
33
33
|
"format:check": "oxfmt --check",
|
|
34
34
|
"test": "jest",
|
|
35
|
-
"test:watch": "jest --watch"
|
|
35
|
+
"test:watch": "jest --watch",
|
|
36
|
+
"release": "semantic-release"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"@oxlint/plugins": "1.43.0"
|
|
@@ -41,15 +42,26 @@
|
|
|
41
42
|
"@babel/core": "7.29.0",
|
|
42
43
|
"@babel/preset-env": "7.29.0",
|
|
43
44
|
"@babel/preset-typescript": "7.28.5",
|
|
45
|
+
"@commitlint/cli": "^20.4.1",
|
|
46
|
+
"@commitlint/config-conventional": "^20.4.1",
|
|
47
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
48
|
+
"@semantic-release/git": "^10.0.1",
|
|
44
49
|
"@types/jest": "30.0.0",
|
|
45
|
-
"@types/node": "25.2.
|
|
50
|
+
"@types/node": "25.2.3",
|
|
51
|
+
"commitlint": "^20.4.1",
|
|
46
52
|
"jest": "30.2.0",
|
|
47
|
-
"oxfmt": "^0.
|
|
48
|
-
"oxlint": "1.
|
|
49
|
-
"oxlint-tsgolint": "^0.
|
|
53
|
+
"oxfmt": "^0.31.0",
|
|
54
|
+
"oxlint": "1.46.0",
|
|
55
|
+
"oxlint-tsgolint": "^0.12.0",
|
|
56
|
+
"semantic-release": "^25.0.3",
|
|
50
57
|
"typescript": "5.9.3"
|
|
51
58
|
},
|
|
52
59
|
"peerDependencies": {
|
|
53
60
|
"oxlint": ">=1.0.0"
|
|
61
|
+
},
|
|
62
|
+
"commitlint": {
|
|
63
|
+
"extends": [
|
|
64
|
+
"@commitlint/config-conventional"
|
|
65
|
+
]
|
|
54
66
|
}
|
|
55
67
|
}
|