Skip to content

Commit b43d0ef

Browse files
committed
chore: integrate prettier with eslint, fix lint/format errors
- Add Prettier integration to ESLint config - Fix all formatting and lint errors in main and example code - Update ESLint config to allow process.env - Update documentation and examples for consistency
1 parent d89a955 commit b43d0ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+997
-972
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Checks
2-
on:
2+
on:
33
push:
44
branches:
55
- main

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
dist/
3+
build/
4+
coverage/

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "es5",
5+
"printWidth": 100,
6+
"tabWidth": 2
7+
}

README.md

Lines changed: 118 additions & 116 deletions
Large diffs are not rendered by default.

eslint.config.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,35 @@
1-
import js from '@eslint/js'
2-
import globals from 'globals'
3-
import reactHooks from 'eslint-plugin-react-hooks'
4-
import reactRefresh from 'eslint-plugin-react-refresh'
5-
import tseslint from 'typescript-eslint'
6-
import { defineConfig, globalIgnores } from 'eslint/config'
1+
import js from '@eslint/js';
2+
import globals from 'globals';
3+
import reactHooks from 'eslint-plugin-react-hooks';
4+
import reactRefresh from 'eslint-plugin-react-refresh';
5+
import tseslint from 'typescript-eslint';
6+
import { defineConfig, globalIgnores } from 'eslint/config';
7+
import prettierPlugin from 'eslint-plugin-prettier';
8+
import prettierConfig from 'eslint-config-prettier';
79

810
export default defineConfig([
9-
globalIgnores(['dist']),
11+
globalIgnores(['dist', 'node_modules', 'build', 'coverage']),
1012
{
11-
files: ['**/*.{ts,tsx}'],
13+
files: ['**/*.{ts,tsx,js,jsx}'],
1214
extends: [
1315
js.configs.recommended,
1416
tseslint.configs.recommended,
1517
reactHooks.configs['recommended-latest'],
1618
reactRefresh.configs.vite,
19+
prettierConfig,
1720
],
21+
plugins: {
22+
prettier: prettierPlugin,
23+
},
24+
rules: {
25+
...prettierPlugin.configs.recommended.rules,
26+
},
1827
languageOptions: {
1928
ecmaVersion: 2020,
20-
globals: globals.browser,
29+
globals: {
30+
...globals.browser,
31+
process: 'readonly',
32+
},
2133
},
2234
},
23-
])
35+
]);

example/postcss.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
/* global module */
12
module.exports = {
23
plugins: {
34
tailwindcss: {},
45
autoprefixer: {},
56
},
6-
}
7+
};

example/public/index.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
55
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<meta name="theme-color" content="#000000" />
8-
<meta
9-
name="description"
10-
content="Web site created using create-react-app"
11-
/>
8+
<meta name="description" content="Web site created using create-react-app" />
129
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
1310
<!--
1411
manifest.json provides metadata used when your web app is installed on a

example/src/App.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { StacApiProvider } from "stac-react";
2-
import Header from "./layout/Header";
3-
import Main from "./pages/Main";
1+
import { StacApiProvider } from 'stac-react';
2+
import Header from './layout/Header';
3+
import Main from './pages/Main';
44

55
function App() {
6+
const apiUrl = process.env.REACT_APP_STAC_API;
67
return (
7-
<StacApiProvider apiUrl={process.env.REACT_APP_STAC_API}>
8+
<StacApiProvider apiUrl={apiUrl}>
89
<div className="App grid grid-rows-[min-content_1fr]">
910
<Header />
1011
<main className="flex items-stretch">

example/src/App.test.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* global test, expect */
12
import { render, screen } from '@testing-library/react';
23
import App from './App';
34

example/src/components/buttons/index.jsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@ const ButtonType = {
44
type: T.oneOf(['submit', 'button']),
55
onClick: T.func.isRequired,
66
children: T.node.isRequired,
7-
}
7+
};
88

99
const DefaultButtonType = {
1010
...ButtonType,
1111
className: T.string,
12-
}
12+
};
1313

1414
export function Button({ type, className, children, onClick }) {
1515
return (
16-
<button
17-
type={type}
18-
className={`${className} px-2 py-1 rounded`}
19-
onClick={onClick}
20-
>
16+
<button type={type} className={`${className} px-2 py-1 rounded`} onClick={onClick}>
2117
{children}
2218
</button>
2319
);
2420
}
2521

2622
Button.propTypes = DefaultButtonType;
2723
Button.defaultProps = {
28-
type: 'button'
29-
}
24+
type: 'button',
25+
};
3026

3127
export function PrimaryButton({ children, ...rest }) {
32-
return <Button {...rest} className='bg-slate-600 text-white active:bg-slate-700'>{children}</Button>;
28+
return (
29+
<Button {...rest} className="bg-slate-600 text-white active:bg-slate-700">
30+
{children}
31+
</Button>
32+
);
3333
}
3434

3535
PrimaryButton.propTypes = ButtonType;

0 commit comments

Comments
 (0)