Skip to content

Commit 1c32af3

Browse files
committed
chore: move react specific eslint configs into react-sdk
fix various lints that were uncovered
1 parent 1286e4f commit 1c32af3

8 files changed

Lines changed: 1069 additions & 58 deletions

File tree

packages/browser-sdk/eslint.config.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
const base = require("@bucketco/eslint-config");
2+
const preactConfig = require("eslint-config-preact");
3+
4+
const compatPlugin = require("eslint-plugin-compat");
5+
const reactPlugin = require("eslint-plugin-react");
6+
const reactHooksPlugin = require("eslint-plugin-react-hooks");
27

38
module.exports = [
49
...base,
510
{
611
// Preact projects
7-
files: ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"],
12+
files: ["**/*.tsx"],
13+
814
settings: {
915
react: {
1016
// We only care about marking h() as being a used variable.
@@ -13,10 +19,18 @@ module.exports = [
1319
version: "16.0",
1420
},
1521
},
22+
plugins: {
23+
compat: compatPlugin,
24+
react: reactPlugin,
25+
"react-hooks": reactHooksPlugin,
26+
},
1627
rules: {
28+
...preactConfig.rules,
1729
// Ignore React attributes that are not valid in Preact.
1830
// Alternatively, we could use the preact/compat alias or turn off the rule.
1931
"react/no-unknown-property": ["off"],
32+
"no-unused-vars": ["off"],
33+
"react/no-danger": ["off"],
2034
},
2135
},
2236
{ ignores: ["dist/", "example/"] },

packages/browser-sdk/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@vitest/coverage-v8": "^2.0.4",
5151
"c8": "~10.1.3",
5252
"eslint": "^9.21.0",
53+
"eslint-config-preact": "^1.5.0",
5354
"http-server": "^14.1.1",
5455
"jsdom": "^24.1.0",
5556
"msw": "^2.3.4",

packages/browser-sdk/src/feedback/ui/FeedbackForm.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ export const FeedbackForm: FunctionComponent<FeedbackFormProps> = ({
9090
if (headerRef.current === null) return;
9191
if (expandedContentRef.current === null) return;
9292

93-
containerRef.current.style.maxHeight =
94-
headerRef.current.clientHeight + "px";
93+
containerRef.current.style.maxHeight = `${headerRef.current.clientHeight}px`;
9594

9695
expandedContentRef.current.style.position = "absolute";
9796
expandedContentRef.current.style.opacity = "0";
@@ -103,11 +102,11 @@ export const FeedbackForm: FunctionComponent<FeedbackFormProps> = ({
103102
if (headerRef.current === null) return;
104103
if (expandedContentRef.current === null) return;
105104

106-
containerRef.current.style.maxHeight =
105+
containerRef.current.style.maxHeight = `${
107106
headerRef.current.clientHeight + // Header height
108107
expandedContentRef.current.clientHeight + // Comment + Button Height
109-
10 + // Gap height
110-
"px";
108+
10 // Gap height
109+
}px`;
111110

112111
expandedContentRef.current.style.position = "relative";
113112
expandedContentRef.current.style.opacity = "1";
@@ -121,8 +120,7 @@ export const FeedbackForm: FunctionComponent<FeedbackFormProps> = ({
121120

122121
formRef.current.style.opacity = "0";
123122
formRef.current.style.pointerEvents = "none";
124-
containerRef.current.style.maxHeight =
125-
submittedRef.current.clientHeight + "px";
123+
containerRef.current.style.maxHeight = `${submittedRef.current.clientHeight}px`;
126124

127125
// Fade in "submitted" step once container has resized
128126
setTimeout(() => {

packages/browser-sdk/src/feedback/ui/StarRating.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const scores = [
5252
},
5353
] as const;
5454

55-
type Score = (typeof scores)[number];
55+
type ScoreNumber = (typeof scores)[number];
5656

5757
export type StarRatingProps = {
5858
name: string;
@@ -118,7 +118,7 @@ const Score = ({
118118
isSelected: boolean;
119119
name: string;
120120
onChange?: h.JSX.GenericEventHandler<HTMLInputElement>;
121-
score: Score;
121+
score: ScoreNumber;
122122
t: FeedbackTranslations;
123123
}) => {
124124
const arrowRef = useRef<HTMLDivElement>(null);

packages/eslint-config/base.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ const globals = require("globals");
77
const tsPlugin = require("@typescript-eslint/eslint-plugin");
88
const tsParser = require("@typescript-eslint/parser");
99
const prettierConfig = require("eslint-config-prettier");
10-
const reactPlugin = require("eslint-plugin-react");
11-
const hooksPlugin = require("eslint-plugin-react-hooks");
1210

1311
module.exports = [
1412
{
@@ -29,8 +27,6 @@ module.exports = [
2927
import: importsPlugin,
3028
"unused-imports": unusedImportsPlugin,
3129
"simple-import-sort": sortImportsPlugin,
32-
react: reactPlugin,
33-
"react-hooks": hooksPlugin,
3430
},
3531
languageOptions: {
3632
globals: {
@@ -62,38 +58,6 @@ module.exports = [
6258
rules: {
6359
...jsPlugin.configs.recommended.rules,
6460
...importsPlugin.configs.recommended.rules,
65-
...reactPlugin.configs.recommended.rules,
66-
...hooksPlugin.configs.recommended.rules,
67-
68-
"react/jsx-key": [
69-
"error",
70-
{
71-
checkFragmentShorthand: true,
72-
},
73-
],
74-
"react/self-closing-comp": ["error"],
75-
"react/prefer-es6-class": ["error"],
76-
"react/prefer-stateless-function": ["warn"],
77-
"react/no-did-mount-set-state": ["error"],
78-
"react/no-did-update-set-state": ["error"],
79-
"react/jsx-filename-extension": [
80-
"warn",
81-
{
82-
extensions: [".mdx", ".jsx", ".tsx"],
83-
},
84-
],
85-
"react/react-in-jsx-scope": ["off"],
86-
"react/jsx-sort-props": [
87-
"error",
88-
{
89-
callbacksLast: true,
90-
shorthandFirst: false,
91-
shorthandLast: true,
92-
ignoreCase: true,
93-
noSortAlphabetically: false,
94-
reservedFirst: true,
95-
},
96-
],
9761

9862
// Imports
9963
"unused-imports/no-unused-vars": [

packages/eslint-config/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"eslint-plugin-react-hooks": "^5.1.0",
1717
"eslint-plugin-simple-import-sort": "^12.1.1",
1818
"eslint-plugin-unused-imports": "^4.1.4",
19+
"globals": "^16.2.0",
1920
"prettier": "^3.5.2",
2021
"typescript": "^5.7.3"
2122
}
Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,50 @@
11
const base = require("@bucketco/eslint-config");
2+
const reactPlugin = require("eslint-plugin-react");
3+
const hooksPlugin = require("eslint-plugin-react-hooks");
24

3-
module.exports = [...base, { ignores: ["dist/", "dev/"] }];
5+
module.exports = [
6+
...base,
7+
{ ignores: ["dist/", "dev/"] },
8+
{
9+
files: ["**/*.ts", "**/*.tsx"],
10+
11+
rules: {
12+
...reactPlugin.configs.recommended.rules,
13+
...hooksPlugin.configs.recommended.rules,
14+
15+
"react/jsx-key": [
16+
"error",
17+
{
18+
checkFragmentShorthand: true,
19+
},
20+
],
21+
"react/self-closing-comp": ["error"],
22+
"react/prefer-es6-class": ["error"],
23+
"react/prefer-stateless-function": ["warn"],
24+
"react/no-did-mount-set-state": ["error"],
25+
"react/no-did-update-set-state": ["error"],
26+
"react/jsx-filename-extension": [
27+
"warn",
28+
{
29+
extensions: [".mdx", ".jsx", ".tsx"],
30+
},
31+
],
32+
"react/react-in-jsx-scope": ["off"],
33+
"react/jsx-sort-props": [
34+
"error",
35+
{
36+
callbacksLast: true,
37+
shorthandFirst: false,
38+
shorthandLast: true,
39+
ignoreCase: true,
40+
noSortAlphabetically: false,
41+
reservedFirst: true,
42+
},
43+
],
44+
},
45+
plugins: {
46+
react: reactPlugin,
47+
"react-hooks": hooksPlugin,
48+
},
49+
},
50+
];

0 commit comments

Comments
 (0)