Skip to content

Commit

Permalink
Update ESLint, update ESLint config, configure Prettier, format all f…
Browse files Browse the repository at this point in the history
…iles using new config
  • Loading branch information
wojtekmaj committed Jan 29, 2022
1 parent 0d2b1f0 commit de77b8f
Show file tree
Hide file tree
Showing 74 changed files with 1,493 additions and 2,245 deletions.
22 changes: 9 additions & 13 deletions .babelrc
@@ -1,22 +1,18 @@
{
"presets": [
"@babel/env",
"@babel/react"
],
"plugins": [
"@babel/transform-runtime"
],
"presets": ["@babel/env", "@babel/react"],
"plugins": ["@babel/transform-runtime"],
"env": {
"production-esm": {
"presets": [
["@babel/env", {
"modules": false
}],
[
"@babel/env",
{
"modules": false
}
],
"@babel/react"
],
"plugins": [
["@babel/transform-runtime", { "useESModules": true }]
]
"plugins": [["@babel/transform-runtime", { "useESModules": true }]]
}
}
}
12 changes: 2 additions & 10 deletions .eslintrc.json
@@ -1,16 +1,8 @@
{
"extends": "wojtekmaj/react",
"parser": "babel-eslint",
"rules": {
"no-underscore-dangle": ["error", { "allow": ["_pdfInfo", "_pageIndex", "_pageInfo"] }],
"react/sort-comp": "off"
},
"extends": "wojtekmaj/react-no-automatic-runtime",
"overrides": [
{
"files": [
"sample/**",
"test/**"
],
"files": ["sample/**", "test/**"],
"rules": {
"import/no-unresolved": "off"
}
Expand Down
4 changes: 4 additions & 0 deletions .husky/pre-commit
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn pretty-quick --staged
5 changes: 5 additions & 0 deletions .prettierignore
@@ -0,0 +1,5 @@
.cache
.yarn
coverage
dist
*.yml
5 changes: 5 additions & 0 deletions .prettierrc.json
@@ -0,0 +1,5 @@
{
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all"
}
9 changes: 2 additions & 7 deletions .vscode/extensions.json
@@ -1,9 +1,4 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"eamodio.gitlens"
],
"unwantedRecommendations": [
"dbaeumer.jshint"
]
"recommendations": ["dbaeumer.vscode-eslint", "eamodio.gitlens", "esbenp.prettier-vscode"],
"unwantedRecommendations": ["dbaeumer.jshint"]
}
2 changes: 2 additions & 0 deletions .vscode/settings.json
@@ -1,4 +1,6 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"search.exclude": {
"**/.yarn": true
}
Expand Down
162 changes: 81 additions & 81 deletions README.md

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions jest.config.json
Expand Up @@ -8,8 +8,6 @@
"moduleNameMapper": {
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
},
"setupFiles": [
"<rootDir>/jest.setup.js"
],
"setupFiles": ["<rootDir>/jest.setup.js"],
"testEnvironment": "<rootDir>/jest.env.js"
}
18 changes: 8 additions & 10 deletions jest.env.js
Expand Up @@ -8,17 +8,15 @@ const JSDOMEnvironment = require('jest-environment-jsdom');

class CustomJSDOMEnvironment extends JSDOMEnvironment {
constructor(config) {
super(
{
...config,
globals: {
...config.globals,
Uint32Array,
Uint8Array,
ArrayBuffer,
},
super({
...config,
globals: {
...config.globals,
Uint32Array,
Uint8Array,
ArrayBuffer,
},
);
});
}
}

Expand Down
9 changes: 6 additions & 3 deletions package.json
Expand Up @@ -14,6 +14,7 @@
"copy-styles": "node ./copy-styles.js",
"jest": "jest",
"lint": "eslint sample/ src/ test/ --ext .jsx,.js",
"postinstall": "husky install",
"prepack": "yarn clean && yarn build",
"test": "yarn lint && yarn jest"
},
Expand Down Expand Up @@ -88,11 +89,13 @@
"@babel/preset-env": "^7.15.0",
"@babel/preset-react": "^7.14.0",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.0",
"babel-eslint": "^10.0.0",
"enzyme": "^3.10.0",
"eslint": "~7.19.0",
"eslint-config-wojtekmaj": "^0.5.0",
"eslint": "^8.5.0",
"eslint-config-wojtekmaj": "^0.6.5",
"husky": "^7.0.0",
"jest": "^27.0.0",
"prettier": "^2.5.0",
"pretty-quick": "^3.1.0",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"rimraf": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion sample/create-react-app-5/public/index.html
Expand Up @@ -2,7 +2,7 @@
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>react-pdf sample page</title>
</head>
<body>
Expand Down
28 changes: 6 additions & 22 deletions sample/create-react-app-5/src/Sample.jsx
Expand Up @@ -28,30 +28,14 @@ export default function Sample() {
</header>
<div className="Example__container">
<div className="Example__container__load">
<label htmlFor="file">Load from file:</label>
{' '}
<input
onChange={onFileChange}
type="file"
/>
<label htmlFor="file">Load from file:</label>{' '}
<input onChange={onFileChange} type="file" />
</div>
<div className="Example__container__document">
<Document
file={file}
onLoadSuccess={onDocumentLoadSuccess}
options={options}
>
{
Array.from(
new Array(numPages),
(el, index) => (
<Page
key={`page_${index + 1}`}
pageNumber={index + 1}
/>
),
)
}
<Document file={file} onLoadSuccess={onDocumentLoadSuccess} options={options}>
{Array.from(new Array(numPages), (el, index) => (
<Page key={`page_${index + 1}`} pageNumber={index + 1} />
))}
</Document>
</div>
</div>
Expand Down
9 changes: 6 additions & 3 deletions sample/parcel/.babelrc
@@ -1,8 +1,11 @@
{
"presets": [
["@babel/preset-env", {
"modules": false
}],
[
"@babel/preset-env",
{
"modules": false
}
],
"@babel/react"
]
}
28 changes: 6 additions & 22 deletions sample/parcel/Sample.jsx
Expand Up @@ -30,30 +30,14 @@ export default function Sample() {
</header>
<div className="Example__container">
<div className="Example__container__load">
<label htmlFor="file">Load from file:</label>
{' '}
<input
onChange={onFileChange}
type="file"
/>
<label htmlFor="file">Load from file:</label>{' '}
<input onChange={onFileChange} type="file" />
</div>
<div className="Example__container__document">
<Document
file={file}
onLoadSuccess={onDocumentLoadSuccess}
options={options}
>
{
Array.from(
new Array(numPages),
(el, index) => (
<Page
key={`page_${index + 1}`}
pageNumber={index + 1}
/>
),
)
}
<Document file={file} onLoadSuccess={onDocumentLoadSuccess} options={options}>
{Array.from(new Array(numPages), (el, index) => (
<Page key={`page_${index + 1}`} pageNumber={index + 1} />
))}
</Document>
</div>
</div>
Expand Down
9 changes: 5 additions & 4 deletions sample/parcel/Sample.less
Expand Up @@ -5,13 +5,14 @@ body {
}

.Example {
input, button {
input,
button {
font: inherit;
}

header {
background-color: rgb(50, 54, 57);
box-shadow: 0 0 8px rgba(0, 0, 0, .5);
box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
padding: 20px;
color: white;

Expand Down Expand Up @@ -44,8 +45,8 @@ body {
}

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

canvas {
Expand Down
2 changes: 1 addition & 1 deletion sample/parcel/index.html
Expand Up @@ -2,7 +2,7 @@
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>react-pdf sample page</title>
</head>
<body>
Expand Down
28 changes: 6 additions & 22 deletions sample/parcel2/Sample.jsx
Expand Up @@ -30,30 +30,14 @@ export default function Sample() {
</header>
<div className="Example__container">
<div className="Example__container__load">
<label htmlFor="file">Load from file:</label>
{' '}
<input
onChange={onFileChange}
type="file"
/>
<label htmlFor="file">Load from file:</label>{' '}
<input onChange={onFileChange} type="file" />
</div>
<div className="Example__container__document">
<Document
file={file}
onLoadSuccess={onDocumentLoadSuccess}
options={options}
>
{
Array.from(
new Array(numPages),
(el, index) => (
<Page
key={`page_${index + 1}`}
pageNumber={index + 1}
/>
),
)
}
<Document file={file} onLoadSuccess={onDocumentLoadSuccess} options={options}>
{Array.from(new Array(numPages), (el, index) => (
<Page key={`page_${index + 1}`} pageNumber={index + 1} />
))}
</Document>
</div>
</div>
Expand Down
9 changes: 5 additions & 4 deletions sample/parcel2/Sample.less
Expand Up @@ -5,13 +5,14 @@ body {
}

.Example {
input, button {
input,
button {
font: inherit;
}

header {
background-color: rgb(50, 54, 57);
box-shadow: 0 0 8px rgba(0, 0, 0, .5);
box-shadow: 0 0 8px rgba(0, 0, 0, 0.5);
padding: 20px;
color: white;

Expand Down Expand Up @@ -44,8 +45,8 @@ body {
}

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

canvas {
Expand Down
2 changes: 1 addition & 1 deletion sample/parcel2/index.html
Expand Up @@ -2,7 +2,7 @@
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>react-pdf sample page</title>
</head>
<body>
Expand Down
9 changes: 6 additions & 3 deletions sample/webpack4/.babelrc
@@ -1,8 +1,11 @@
{
"presets": [
["@babel/preset-env", {
"modules": false
}],
[
"@babel/preset-env",
{
"modules": false
}
],
"@babel/react"
]
}

0 comments on commit de77b8f

Please sign in to comment.