Skip to content

Commit 0895502

Browse files
committed
BREAKING CHANGE: add new file to improve performance with eslint rules
1 parent 1e0f185 commit 0895502

4 files changed

Lines changed: 41 additions & 1 deletion

File tree

example-app/.eslintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"root": true,
3-
"extends": ["plugin:@bam.tech/recommended", "plugin:@bam.tech/a11y"],
3+
"extends": [
4+
"plugin:@bam.tech/recommended",
5+
"plugin:@bam.tech/a11y",
6+
"plugin:@bam.tech/performance"
7+
],
48
"overrides": [
59
{
610
"files": ["*.test.tsx"],
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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 { FlatList } from "react-native";
7+
8+
export const MyCustomButton = () => {
9+
return <FlatList />;
10+
};

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { a11yConfig } from "./a11y";
22
import { importConfig } from "./import";
33
import { recommendedConfig } from "./recommended";
44
import { testsConfig } from "./tests";
5+
import { performanceConfig } from "./performance";
56

67
export default {
78
recommended: recommendedConfig,
89
tests: testsConfig,
910
a11y: a11yConfig,
1011
import: importConfig,
12+
performance: performanceConfig,
1113
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { defineConfig } from "eslint-define-config";
2+
3+
export const performanceConfig = defineConfig({
4+
rules: {
5+
"no-restricted-imports": [
6+
"warn",
7+
{
8+
paths: [
9+
{
10+
name: "react-native",
11+
importNames: ["FlatList"],
12+
message:
13+
"Please use FlashList from @shopify/flash-list instead of FlatList from react-native.",
14+
},
15+
],
16+
},
17+
],
18+
},
19+
overrides: [
20+
{
21+
files: ["*.js"],
22+
},
23+
],
24+
});

0 commit comments

Comments
 (0)