Skip to content

Commit fcfc066

Browse files
committed
BREAKING CHANGE: add performance rule to prevent usage of react native svg
1 parent a794dbf commit fcfc066

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Save without formatting: [⌘ + K] > [S]
2+
3+
// This should trigger one error breaking eslint-plugin-react-native:
4+
// no-restricted-imports
5+
6+
import Svg, { Circle, Rect } from "react-native-svg";
7+
8+
export const SvgComponent = () => {
9+
return (
10+
<Svg height="50%" width="50%" viewBox="0 0 100 100">
11+
<Circle
12+
cx="50"
13+
cy="50"
14+
r="45"
15+
stroke="blue"
16+
strokeWidth="2.5"
17+
fill="green"
18+
/>
19+
<Rect
20+
x="15"
21+
y="15"
22+
width="70"
23+
height="70"
24+
stroke="red"
25+
strokeWidth="2"
26+
fill="yellow"
27+
/>
28+
</Svg>
29+
);
30+
};

example-app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"dependencies": {
4040
"expo": "^49.0.0",
4141
"react": "^18.2.0",
42-
"react-native": "^0.73.0"
42+
"react-native": "^0.73.0",
43+
"react-native-svg": "^15.5.0"
4344
}
4445
}

packages/eslint-plugin/lib/configs/performance.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ export const performanceConfig = defineConfig({
2323
message:
2424
"Please use useFocusEffect instead of useIsFocused to avoid excessive rerenders.",
2525
},
26+
{
27+
name: "react-native-svg",
28+
message:
29+
"Usage of react-native-svg is discouraged. Consider alternatives if applicable.",
30+
},
2631
],
2732
},
2833
],

0 commit comments

Comments
 (0)