Skip to content

Commit 04e2e7a

Browse files
committed
Update ESLint, update ESLint config, configure Prettier, format all files using new config
1 parent 0d2b1f0 commit 04e2e7a

Some content is hidden

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

77 files changed

+1670
-2496
lines changed

.babelrc

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
11
{
2-
"presets": [
3-
"@babel/env",
4-
"@babel/react"
5-
],
6-
"plugins": [
7-
"@babel/transform-runtime"
8-
],
2+
"presets": ["@babel/env", "@babel/react"],
3+
"plugins": ["@babel/transform-runtime"],
94
"env": {
105
"production-esm": {
116
"presets": [
12-
["@babel/env", {
13-
"modules": false
14-
}],
7+
[
8+
"@babel/env",
9+
{
10+
"modules": false
11+
}
12+
],
1513
"@babel/react"
1614
],
17-
"plugins": [
18-
["@babel/transform-runtime", { "useESModules": true }]
19-
]
15+
"plugins": [["@babel/transform-runtime", { "useESModules": true }]]
2016
}
2117
}
2218
}

.eslintrc.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
{
2-
"extends": "wojtekmaj/react",
3-
"parser": "babel-eslint",
4-
"rules": {
5-
"no-underscore-dangle": ["error", { "allow": ["_pdfInfo", "_pageIndex", "_pageInfo"] }],
6-
"react/sort-comp": "off"
7-
},
2+
"extends": "wojtekmaj/react-no-automatic-runtime",
83
"overrides": [
94
{
10-
"files": [
11-
"sample/**",
12-
"test/**"
13-
],
5+
"files": ["sample/**", "test/**"],
146
"rules": {
157
"import/no-unresolved": "off"
168
}

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
yarn pretty-quick --staged

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.cache
2+
.yarn
3+
coverage
4+
dist
5+
*.yml

.prettierrc.json

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

.vscode/extensions.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
{
2-
"recommendations": [
3-
"dbaeumer.vscode-eslint",
4-
"eamodio.gitlens"
5-
],
6-
"unwantedRecommendations": [
7-
"dbaeumer.jshint"
8-
]
2+
"recommendations": ["dbaeumer.vscode-eslint", "eamodio.gitlens", "esbenp.prettier-vscode"],
3+
"unwantedRecommendations": ["dbaeumer.jshint"]
94
}

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
2+
"editor.defaultFormatter": "esbenp.prettier-vscode",
3+
"editor.formatOnSave": true,
24
"search.exclude": {
35
"**/.yarn": true
46
}

README.md

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

jest.config.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
"moduleNameMapper": {
99
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
1010
},
11-
"setupFiles": [
12-
"<rootDir>/jest.setup.js"
13-
],
11+
"setupFiles": ["<rootDir>/jest.setup.js"],
1412
"testEnvironment": "<rootDir>/jest.env.js"
1513
}

jest.env.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable import/no-extraneous-dependencies */
2-
31
/**
42
* Workaround for https://github.com/facebook/jest/issues/7780
53
*/
@@ -8,17 +6,15 @@ const JSDOMEnvironment = require('jest-environment-jsdom');
86

97
class CustomJSDOMEnvironment extends JSDOMEnvironment {
108
constructor(config) {
11-
super(
12-
{
13-
...config,
14-
globals: {
15-
...config.globals,
16-
Uint32Array,
17-
Uint8Array,
18-
ArrayBuffer,
19-
},
9+
super({
10+
...config,
11+
globals: {
12+
...config.globals,
13+
Uint32Array,
14+
Uint8Array,
15+
ArrayBuffer,
2016
},
21-
);
17+
});
2218
}
2319
}
2420

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"copy-styles": "node ./copy-styles.js",
1515
"jest": "jest",
1616
"lint": "eslint sample/ src/ test/ --ext .jsx,.js",
17+
"postinstall": "husky install",
1718
"prepack": "yarn clean && yarn build",
1819
"test": "yarn lint && yarn jest"
1920
},
@@ -88,11 +89,13 @@
8889
"@babel/preset-env": "^7.15.0",
8990
"@babel/preset-react": "^7.14.0",
9091
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.0",
91-
"babel-eslint": "^10.0.0",
9292
"enzyme": "^3.10.0",
93-
"eslint": "~7.19.0",
94-
"eslint-config-wojtekmaj": "^0.5.0",
93+
"eslint": "^8.5.0",
94+
"eslint-config-wojtekmaj": "^0.6.5",
95+
"husky": "^7.0.0",
9596
"jest": "^27.0.0",
97+
"prettier": "^2.5.0",
98+
"pretty-quick": "^3.1.0",
9699
"react": "^17.0.0",
97100
"react-dom": "^17.0.0",
98101
"rimraf": "^3.0.0",

sample/create-react-app-5/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en-US">
33
<head>
44
<meta charset="utf-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>react-pdf sample page</title>
77
</head>
88
<body>

sample/create-react-app-5/src/Sample.jsx

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,14 @@ export default function Sample() {
2828
</header>
2929
<div className="Example__container">
3030
<div className="Example__container__load">
31-
<label htmlFor="file">Load from file:</label>
32-
{' '}
33-
<input
34-
onChange={onFileChange}
35-
type="file"
36-
/>
31+
<label htmlFor="file">Load from file:</label>{' '}
32+
<input onChange={onFileChange} type="file" />
3733
</div>
3834
<div className="Example__container__document">
39-
<Document
40-
file={file}
41-
onLoadSuccess={onDocumentLoadSuccess}
42-
options={options}
43-
>
44-
{
45-
Array.from(
46-
new Array(numPages),
47-
(el, index) => (
48-
<Page
49-
key={`page_${index + 1}`}
50-
pageNumber={index + 1}
51-
/>
52-
),
53-
)
54-
}
35+
<Document file={file} onLoadSuccess={onDocumentLoadSuccess} options={options}>
36+
{Array.from(new Array(numPages), (el, index) => (
37+
<Page key={`page_${index + 1}`} pageNumber={index + 1} />
38+
))}
5539
</Document>
5640
</div>
5741
</div>

sample/parcel/.babelrc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"presets": [
3-
["@babel/preset-env", {
4-
"modules": false
5-
}],
3+
[
4+
"@babel/preset-env",
5+
{
6+
"modules": false
7+
}
8+
],
69
"@babel/react"
710
]
811
}

sample/parcel/Sample.jsx

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,14 @@ export default function Sample() {
3030
</header>
3131
<div className="Example__container">
3232
<div className="Example__container__load">
33-
<label htmlFor="file">Load from file:</label>
34-
{' '}
35-
<input
36-
onChange={onFileChange}
37-
type="file"
38-
/>
33+
<label htmlFor="file">Load from file:</label>{' '}
34+
<input onChange={onFileChange} type="file" />
3935
</div>
4036
<div className="Example__container__document">
41-
<Document
42-
file={file}
43-
onLoadSuccess={onDocumentLoadSuccess}
44-
options={options}
45-
>
46-
{
47-
Array.from(
48-
new Array(numPages),
49-
(el, index) => (
50-
<Page
51-
key={`page_${index + 1}`}
52-
pageNumber={index + 1}
53-
/>
54-
),
55-
)
56-
}
37+
<Document file={file} onLoadSuccess={onDocumentLoadSuccess} options={options}>
38+
{Array.from(new Array(numPages), (el, index) => (
39+
<Page key={`page_${index + 1}`} pageNumber={index + 1} />
40+
))}
5741
</Document>
5842
</div>
5943
</div>

sample/parcel/Sample.less

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ body {
55
}
66

77
.Example {
8-
input, button {
8+
input,
9+
button {
910
font: inherit;
1011
}
1112

1213
header {
1314
background-color: rgb(50, 54, 57);
14-
box-shadow: 0 0 8px rgba(0, 0, 0, .5);
15+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
1516
padding: 20px;
1617
color: white;
1718

@@ -44,8 +45,8 @@ body {
4445
}
4546

4647
&__Page {
47-
max-width: calc(~"100% - 2em");
48-
box-shadow: 0 0 8px rgba(0, 0, 0, .5);
48+
max-width: calc(~'100% - 2em');
49+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
4950
margin: 1em;
5051

5152
canvas {

sample/parcel/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en-US">
33
<head>
44
<meta charset="utf-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>react-pdf sample page</title>
77
</head>
88
<body>

sample/parcel2/Sample.jsx

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,14 @@ export default function Sample() {
3030
</header>
3131
<div className="Example__container">
3232
<div className="Example__container__load">
33-
<label htmlFor="file">Load from file:</label>
34-
{' '}
35-
<input
36-
onChange={onFileChange}
37-
type="file"
38-
/>
33+
<label htmlFor="file">Load from file:</label>{' '}
34+
<input onChange={onFileChange} type="file" />
3935
</div>
4036
<div className="Example__container__document">
41-
<Document
42-
file={file}
43-
onLoadSuccess={onDocumentLoadSuccess}
44-
options={options}
45-
>
46-
{
47-
Array.from(
48-
new Array(numPages),
49-
(el, index) => (
50-
<Page
51-
key={`page_${index + 1}`}
52-
pageNumber={index + 1}
53-
/>
54-
),
55-
)
56-
}
37+
<Document file={file} onLoadSuccess={onDocumentLoadSuccess} options={options}>
38+
{Array.from(new Array(numPages), (el, index) => (
39+
<Page key={`page_${index + 1}`} pageNumber={index + 1} />
40+
))}
5741
</Document>
5842
</div>
5943
</div>

sample/parcel2/Sample.less

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ body {
55
}
66

77
.Example {
8-
input, button {
8+
input,
9+
button {
910
font: inherit;
1011
}
1112

1213
header {
1314
background-color: rgb(50, 54, 57);
14-
box-shadow: 0 0 8px rgba(0, 0, 0, .5);
15+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
1516
padding: 20px;
1617
color: white;
1718

@@ -44,8 +45,8 @@ body {
4445
}
4546

4647
&__Page {
47-
max-width: calc(~"100% - 2em");
48-
box-shadow: 0 0 8px rgba(0, 0, 0, .5);
48+
max-width: calc(~'100% - 2em');
49+
box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
4950
margin: 1em;
5051

5152
canvas {

sample/parcel2/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en-US">
33
<head>
44
<meta charset="utf-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>react-pdf sample page</title>
77
</head>
88
<body>

sample/webpack4/.babelrc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"presets": [
3-
["@babel/preset-env", {
4-
"modules": false
5-
}],
3+
[
4+
"@babel/preset-env",
5+
{
6+
"modules": false
7+
}
8+
],
69
"@babel/react"
710
]
811
}

0 commit comments

Comments
 (0)