Skip to content

Commit 85223ca

Browse files
authored
Chore: Update eslint configuration (#224)
- Update missing dev dependencies - Fix root .eslintrc.json and client and server versions - Add lint.yaml workflow - Remove babel settings - Clean up and fix eslint and ts errors
1 parent a976451 commit 85223ca

File tree

19 files changed

+1412
-595
lines changed

19 files changed

+1412
-595
lines changed

.eslintrc.json

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
{
22
"root": true,
3+
"parser": "@typescript-eslint/parser",
34
"extends": [
45
"airbnb-base",
56
"plugin:prettier/recommended",
67
"eslint:recommended",
7-
"plugin:@typescript-eslint/recommended",
8-
"plugin:react-hooks/recommended"
8+
"plugin:@typescript-eslint/recommended"
99
],
10-
"plugins": ["react-refresh", "prettier"],
10+
"plugins": ["prettier", "googleappsscript"],
11+
"env": {
12+
"googleappsscript/googleappsscript": true
13+
},
1114
"rules": {
1215
"prettier/prettier": "error",
1316
"camelcase": "warn",
1417
"import/prefer-default-export": "warn",
1518
"import/no-extraneous-dependencies": "warn",
1619
"prefer-object-spread": "warn",
17-
"spaced-comment": "off",
18-
"react-refresh/only-export-components": [
19-
"warn",
20-
{ "allowConstantExport": true }
20+
"import/extensions": [
21+
"error",
22+
"ignorePackages",
23+
{
24+
"js": "never",
25+
"ts": "never"
26+
}
2127
]
2228
},
23-
"parserOptions": {
24-
"babelOptions": {
25-
"configFile": "./dev/.babelrc"
26-
}
27-
},
28-
"env": { "browser": true, "es2020": true },
2929
"ignorePatterns": ["dist", ".eslintrc.json"],
30-
"parser": "@typescript-eslint/parser"
30+
"settings": {
31+
"import/resolver": {
32+
"node": {
33+
"extensions": [".js", ".ts"]
34+
}
35+
}
36+
}
3137
}

.github/workflows/lint.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: macos-13
8+
timeout-minutes: 8
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Use Node.js ${{ matrix.node-version }}
12+
uses: actions/setup-node@v4
13+
with:
14+
node-version: 20
15+
- name: Install packages
16+
run: yarn install
17+
- name: Run lint
18+
run: yarn lint

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"scripts": {
1111
"dev": "vite",
12+
"lint": "eslint .",
1213
"test:integration": "jest --forceExit test/local-development.test",
1314
"test:integration:extended": "cross-env IS_EXTENDED=true jest --forceExit test/local-development.test",
1415
"test:integration:extended:ci-reporter": "cross-env IS_EXTENDED=true jest --forceExit || node test/utils/image-reporter-standalone.js",
@@ -48,9 +49,7 @@
4849
"react-transition-group": "^4.4.2"
4950
},
5051
"devDependencies": {
51-
"@babel/core": "^7.24.4",
52-
"@babel/plugin-proposal-class-properties": "^7.18.6",
53-
"@babel/preset-env": "^7.24.4",
52+
"@babel/preset-env": "^7.24.6",
5453
"@google/clasp": "^2.4.2",
5554
"@types/expect-puppeteer": "^5.0.0",
5655
"@types/jest-environment-puppeteer": "^5.0.2",
@@ -69,6 +68,7 @@
6968
"eslint-config-airbnb-base": "^15.0.0",
7069
"eslint-config-prettier": "^8.5.0",
7170
"eslint-plugin-googleappsscript": "^1.0.4",
71+
"eslint-plugin-import": "^2.29.1",
7272
"eslint-plugin-jest": "^26.5.3",
7373
"eslint-plugin-prettier": "^4.0.0",
7474
"eslint-plugin-react-hooks": "^4.6.0",
@@ -83,6 +83,7 @@
8383
"puppeteer": "^14.3.0",
8484
"puppeteer-extra": "^3.2.3",
8585
"puppeteer-extra-plugin-stealth": "^2.9.0",
86+
"rollup": "^4.18.0",
8687
"tailwindcss": "^3.4.3",
8788
"typescript": "^5.2.2",
8889
"vite": "^5.2.0",

src/client/.babelrc

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/client/.eslintrc.json

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,24 @@
11
{
22
"root": true,
3-
"parser": "@babel/eslint-parser",
43
"extends": [
54
"airbnb-base",
65
"plugin:prettier/recommended",
7-
"plugin:react/recommended"
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/recommended",
8+
"plugin:react-hooks/recommended"
89
],
9-
"plugins": ["babel", "react", "prettier"],
10-
"env": {
11-
"browser": true,
12-
"es6": true
13-
},
14-
"globals": {
15-
"google": false,
16-
"alert": false,
17-
"css": true
18-
},
19-
"parserOptions": {
20-
"ecmaVersion": 9,
21-
"sourceType": "module",
22-
"ecmaFeatures": {
23-
"jsx": true
24-
}
25-
},
10+
"plugins": ["react-refresh", "prettier"],
2611
"rules": {
2712
"prettier/prettier": "error",
28-
"react/prop-types": "warn",
2913
"camelcase": "warn",
3014
"import/prefer-default-export": "warn",
3115
"import/no-extraneous-dependencies": "warn",
3216
"prefer-object-spread": "warn",
17+
"spaced-comment": "off",
18+
"react-refresh/only-export-components": [
19+
"warn",
20+
{ "allowConstantExport": true }
21+
],
3322
"import/extensions": [
3423
"error",
3524
"ignorePackages",
@@ -50,5 +39,7 @@
5039
"extensions": [".js", ".jsx", ".ts", ".tsx"]
5140
}
5241
}
53-
}
42+
},
43+
"env": { "browser": true, "es2020": true },
44+
"parser": "@typescript-eslint/parser"
5445
}

src/client/dialog-demo-mui/components/FormInput.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ const FormInput = ({ submitNewSheet }: FormInputProps) => {
2323
};
2424

2525
return (
26-
<form
27-
onSubmit={handleSubmit}
28-
>
26+
<form onSubmit={handleSubmit}>
2927
<Grid container spacing={2}>
3028
<Grid item xs={10}>
3129
<TextField

src/client/dialog-demo-mui/components/SheetEditor.jsx

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Button, Typography } from '@mui/material';
44
import FormInput from './FormInput';
55
import SheetTable from './SheetTable';
66

7-
87
// This is a wrapper for google.script.run that lets us use promises.
98
import { serverFunctions } from '../../utils/serverFunctions';
109

@@ -40,29 +39,40 @@ const SheetEditor = () => {
4039
</Typography>
4140

4241
<Typography variant="body1" gutterBottom sx={{ marginBottom: '30px' }}>
43-
This is a sample app that uses the <code>mui</code> library
44-
to help us build a simple React app. Enter a name for a new sheet, hit
45-
enter and the new sheet will be created. Click the red button next to the sheet name to
46-
delete it.
42+
This is a sample app that uses the <code>mui</code> library to help us
43+
build a simple React app. Enter a name for a new sheet, hit enter and
44+
the new sheet will be created. Click the red button next to the sheet
45+
name to delete it.
4746
</Typography>
4847
<FormInput submitNewSheet={submitNewSheet} />
4948

50-
{names.length > 0 &&
51-
<SheetTable rows={names.map((name) => {
52-
return {
53-
sheetName: name.name,
54-
goToButton: <Button
55-
variant="outlined"
56-
disabled={name?.isActive}
57-
onClick={() => setActiveSheet(name.name)}
58-
>Go To Sheet</Button>,
59-
deleteButton: <Button
60-
variant="contained"
61-
color="error"
62-
onClick={() => deleteSheet(name.index)}
63-
>Delete</Button>
64-
}
65-
})} />}
49+
{names.length > 0 && (
50+
<SheetTable
51+
rows={names.map((name) => {
52+
return {
53+
sheetName: name.name,
54+
goToButton: (
55+
<Button
56+
variant="outlined"
57+
disabled={name?.isActive}
58+
onClick={() => setActiveSheet(name.name)}
59+
>
60+
Go To Sheet
61+
</Button>
62+
),
63+
deleteButton: (
64+
<Button
65+
variant="contained"
66+
color="error"
67+
onClick={() => deleteSheet(name.index)}
68+
>
69+
Delete
70+
</Button>
71+
),
72+
};
73+
})}
74+
/>
75+
)}
6676
</div>
6777
);
6878
};

src/client/dialog-demo-mui/components/SheetTable.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import * as React from 'react';
2-
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@mui/material';
2+
import {
3+
Table,
4+
TableBody,
5+
TableCell,
6+
TableContainer,
7+
TableHead,
8+
TableRow,
9+
} from '@mui/material';
310

411
type sheetRow = {
512
sheetName: string;

src/client/dialog-demo-tailwindcss/components/FormInput.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { useState, ChangeEvent, FormEvent } from 'react';
22
import PropTypes from 'prop-types';
33

4-
const FormInput = ({ submitNewSheet }: { submitNewSheet: Function }) => {
4+
const FormInput = ({
5+
submitNewSheet,
6+
}: {
7+
submitNewSheet: (arg: string) => void;
8+
}) => {
59
const [inputValue, setInputValue] = useState('');
610

711
const handleChange = (event: ChangeEvent<HTMLInputElement>) =>

src/server/.babelrc

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)