Skip to content

Commit f99167c

Browse files
authored
chore(lint): lint all files (facebook#12288)
This change consolidates all lint rules and paths to the root of the repo, and runs them as part of the `lint` workflow.
1 parent 19fa58d commit f99167c

Some content is hidden

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

61 files changed

+269
-174
lines changed

.eslintignore

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
node_modules/
2-
build
3-
my-app*
4-
packages/react-scripts/template
5-
packages/react-scripts/fixtures
6-
fixtures/
2+
build/
3+
test/fixtures/webpack-message-formatting/src/AppBabel.js
4+
packages/react-error-overlay/lib/

.eslintrc.json

+35-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,39 @@
1414
"no-console": "off",
1515
"strict": ["error", "global"],
1616
"curly": "warn"
17-
}
17+
},
18+
"overrides": [
19+
{
20+
"files": [
21+
"docusaurus/website/src/**/*.js",
22+
"packages/cra-template/**/*.js",
23+
"packages/react-error-overlay/**/*.js",
24+
"packages/react-scripts/fixtures/kitchensink/template/{src,integration}/**/*.js",
25+
"test/fixtures/*/src/*.js"
26+
],
27+
"excludedFiles": ["packages/react-error-overlay/*.js"],
28+
"extends": ["react-app", "react-app/jest"]
29+
},
30+
{
31+
"files": [
32+
"test/fixtures/webpack-message-formatting/src/{AppLintError,AppLintWarning,AppUnknownFile}.js"
33+
],
34+
"rules": {
35+
"no-unused-vars": "off",
36+
"no-undef": "off"
37+
}
38+
},
39+
{
40+
"files": ["test/fixtures/webpack-message-formatting/src/Export5.js"],
41+
"rules": {
42+
"import/no-anonymous-default-export": "off"
43+
}
44+
},
45+
{
46+
"files": ["test/fixtures/issue-5176-flow-class-properties/src/App.js"],
47+
"rules": {
48+
"no-dupe-class-members": "off"
49+
}
50+
}
51+
]
1852
}

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Build
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:

.github/workflows/lint.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Lint
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
lint:
@@ -15,5 +15,11 @@ jobs:
1515
run: npm i -g npm@8
1616
- name: Install
1717
run: npm ci --prefer-offline
18+
- name: Build
19+
run: npm run build
1820
- name: Alex
1921
run: npm run alex
22+
- name: Prettier
23+
run: npm run prettier -- --list-different
24+
- name: Eslint
25+
run: npm run eslint -- --max-warnings 0

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.idea/
22
.vscode/
33
node_modules/
4-
build
4+
build/
55
.DS_Store
66
*.tgz
77
my-app*

.prettierignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
build/
2+
package-lock.json
3+
test/fixtures/webpack-message-formatting/src/AppBabel.js
4+
test/fixtures/webpack-message-formatting/src/AppCss.css
5+
packages/react-error-overlay/fixtures/bundle*
6+
packages/react-error-overlay/fixtures/inline*
7+
packages/react-error-overlay/fixtures/junk*
8+
packages/react-error-overlay/lib/
9+
packages/react-error-overlay/coverage/

docusaurus/docs/adding-typescript.md

+4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ To start a new Create React App project with [TypeScript](https://www.typescript
1414
```sh
1515
npx create-react-app my-app --template typescript
1616
```
17+
1718
or
19+
1820
```sh
1921
yarn create react-app my-app --template typescript
2022
```
@@ -28,7 +30,9 @@ To add [TypeScript](https://www.typescriptlang.org/) to an existing Create React
2830
```sh
2931
npm install --save typescript @types/node @types/react @types/react-dom @types/jest
3032
```
33+
3134
or
35+
3236
```sh
3337
yarn add typescript @types/node @types/react @types/react-dom @types/jest
3438
```

docusaurus/docs/advanced-configuration.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ You can adjust various development and production settings by setting environmen
1515
| PORT | ✅ Used | 🚫 Ignored | By default, the development web server will attempt to listen on port 3000 or prompt you to attempt the next available port. You may use this variable to specify a different port. |
1616
| HTTPS | ✅ Used | 🚫 Ignored | When set to `true`, Create React App will run the development server in `https` mode. |
1717
| WDS_SOCKET_HOST | ✅ Used | 🚫 Ignored | When set, Create React App will run the development server with a custom websocket hostname for hot module reloading. Normally, `webpack-dev-server` defaults to `window.location.hostname` for the SockJS hostname. You may use this variable to start local development on more than one Create React App project at a time. See [webpack-dev-server documentation](https://webpack.js.org/configuration/dev-server/#devserversockhost) for more details. |
18-
| WDS_SOCKET_PATH | ✅ Used | 🚫 Ignored | When set, Create React App will run the development server with a custom websocket path for hot module reloading. Normally, `webpack-dev-server` defaults to `/ws` for the SockJS pathname. You may use this variable to start local development on more than one Create React App project at a time. See [webpack-dev-server documentation](https://webpack.js.org/configuration/dev-server/#devserversockpath) for more details. |
18+
| WDS_SOCKET_PATH | ✅ Used | 🚫 Ignored | When set, Create React App will run the development server with a custom websocket path for hot module reloading. Normally, `webpack-dev-server` defaults to `/ws` for the SockJS pathname. You may use this variable to start local development on more than one Create React App project at a time. See [webpack-dev-server documentation](https://webpack.js.org/configuration/dev-server/#devserversockpath) for more details. |
1919
| WDS_SOCKET_PORT | ✅ Used | 🚫 Ignored | When set, Create React App will run the development server with a custom websocket port for hot module reloading. Normally, `webpack-dev-server` defaults to `window.location.port` for the SockJS port. You may use this variable to start local development on more than one Create React App project at a time. See [webpack-dev-server documentation](https://webpack.js.org/configuration/dev-server/#devserversockport) for more details. |
2020
| PUBLIC_URL | ✅ Used | ✅ Used | Create React App assumes your application is hosted at the serving web server's root or a subpath as specified in [`package.json` (`homepage`)](deployment#building-for-relative-paths). Normally, Create React App ignores the hostname. You may use this variable to force assets to be referenced verbatim to the url you provide (hostname included). This may be particularly useful when using a CDN to host your application. |
2121
| BUILD_PATH | 🚫 Ignored | ✅ Used | By default, Create React App will output compiled assets to a `/build` directory adjacent to your `/src`. You may use this variable to specify a new path for Create React App to output assets. BUILD_PATH should be specified as a path relative to the root of your project. |
@@ -24,7 +24,7 @@ You can adjust various development and production settings by setting environmen
2424
| CHOKIDAR_USEPOLLING | ✅ Used | 🚫 Ignored | When set to `true`, the watcher runs in polling mode, as necessary inside a VM. Use this option if `npm start` isn't detecting changes. |
2525
| GENERATE_SOURCEMAP | 🚫 Ignored | ✅ Used | When set to `false`, source maps are not generated for a production build. This solves out of memory (OOM) issues on some smaller machines. |
2626
| INLINE_RUNTIME_CHUNK | 🚫 Ignored | ✅ Used | By default, Create React App will embed the runtime script into `index.html` during the production build. When set to `false`, the script will not be embedded and will be imported as usual. This is normally required when dealing with CSP. |
27-
| IMAGE_INLINE_SIZE_LIMIT | ✅ Used | ✅ Used | By default, images smaller than 10,000 bytes are encoded as a data URI in base64 and inlined in the CSS or JS build artifact. Set this to control the size limit in bytes. Setting it to `0` will disable the inlining of images. |
27+
| IMAGE_INLINE_SIZE_LIMIT | ✅ Used | ✅ Used | By default, images smaller than 10,000 bytes are encoded as a data URI in base64 and inlined in the CSS or JS build artifact. Set this to control the size limit in bytes. Setting it to `0` will disable the inlining of images. |
2828
| FAST_REFRESH | ✅ Used | 🚫 Ignored | When set to `false`, disables experimental support for Fast Refresh to allow you to tweak your components in real time without reloading the page. |
2929
| TSC_COMPILE_ON_ERROR | ✅ Used | ✅ Used | When set to `true`, you can run and properly build TypeScript projects even if there are TypeScript type check errors. These errors are printed as warnings in the terminal and/or browser console. |
3030
| ESLINT_NO_DEV_ERRORS | ✅ Used | 🚫 Ignored | When set to `true`, ESLint errors are converted to warnings during development. As a result, ESLint output will no longer appear in the error overlay. |

docusaurus/docs/loading-graphql-files.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ You can also use the `gql` template tag the same way you would use the non-macro
5757

5858
```js
5959
import { gql } from 'graphql.macro';
60-
60+
6161
const query = gql`
6262
query User {
6363
user(id: 5) {

docusaurus/docs/proxying-api-requests-in-development.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Next, create `src/setupProxy.js` and place the following contents in it:
8787
```js
8888
const { createProxyMiddleware } = require('http-proxy-middleware');
8989

90-
module.exports = function(app) {
90+
module.exports = function (app) {
9191
// ...
9292
};
9393
```
@@ -97,7 +97,7 @@ You can now register proxies as you wish! Here's an example using the above `htt
9797
```js
9898
const { createProxyMiddleware } = require('http-proxy-middleware');
9999

100-
module.exports = function(app) {
100+
module.exports = function (app) {
101101
app.use(
102102
'/api',
103103
createProxyMiddleware({

docusaurus/website/docusaurus.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*/
7+
'use strict';
78

89
const siteConfig = {
910
title: 'Create React App',

docusaurus/website/src/css/custom.css

+4-5
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,30 @@
3232
max-width: 100%;
3333
}
3434

35-
3635
/* Announcement banner */
3736

3837
:root {
3938
--docusaurus-announcement-bar-height: auto !important;
4039
}
4140

42-
div[class^="announcementBar"][role="banner"] {
41+
div[class^='announcementBar'][role='banner'] {
4342
border-bottom-color: var(--deepdark);
4443
}
4544

46-
div[class^="announcementBarContent"] {
45+
div[class^='announcementBarContent'] {
4746
line-height: 40px;
4847
font-size: 20px;
4948
font-weight: bold;
5049
padding: 8px 30px;
5150
}
5251

53-
div[class^="announcementBarContent"] a {
52+
div[class^='announcementBarContent'] a {
5453
text-decoration: underline;
5554
display: inline-block;
5655
color: var(--ifm-color-primary) !important;
5756
}
5857

59-
div[class^="announcementBarContent"] a:hover {
58+
div[class^='announcementBarContent'] a:hover {
6059
color: var(--brand) !important;
6160
}
6261

docusaurus/website/src/pages/index.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ function Home() {
6868
<div className="container">
6969
<div className="row">
7070
{features.map(({ title, content }, idx) => (
71-
<div
72-
key={idx}
73-
className={clsx('col col--4', styles.feature)}
74-
>
71+
<div key={idx} className={clsx('col col--4', styles.feature)}>
7572
<h2>{title}</h2>
7673
<p>{content}</p>
7774
</div>

package-lock.json

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"alex": "alex .",
1919
"test:integration": "jest test/integration",
2020
"test": "cd packages/react-scripts && node bin/react-scripts.js test",
21-
"format": "prettier --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'"
21+
"eslint": "eslint .",
22+
"prettier": "prettier .",
23+
"format": "npm run prettier -- --write"
2224
},
2325
"devDependencies": {
2426
"@testing-library/jest-dom": "^5.15.1",

packages/babel-plugin-named-asset-import/index.test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
const pluginTester = require('babel-plugin-tester/pure');
24
const namedAssetImport = require('./index');
35

@@ -39,8 +41,7 @@ pluginTester.default({
3941
'import { ReactComponent as logo } from "@svgr/webpack?-svgo!logo.svg";',
4042
},
4143
svgMultipleImport: {
42-
code:
43-
'import logo, { logoUrl , ReactComponent as Logo } from "logo.svg";',
44+
code: 'import logo, { logoUrl , ReactComponent as Logo } from "logo.svg";',
4445
output:
4546
'import logo from "logo.svg";\n' +
4647
'import { logoUrl } from "logo.svg";\n' +

packages/react-dev-utils/ModuleScopePlugin.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ class ModuleScopePlugin {
1515
constructor(appSrc, allowedFiles = []) {
1616
this.appSrcs = Array.isArray(appSrc) ? appSrc : [appSrc];
1717
this.allowedFiles = new Set(allowedFiles);
18-
this.allowedPaths = [...allowedFiles].map(path.dirname).filter(p => path.relative(p, process.cwd()) !== '');
18+
this.allowedPaths = [...allowedFiles]
19+
.map(path.dirname)
20+
.filter(p => path.relative(p, process.cwd()) !== '');
1921
}
2022

2123
apply(resolver) {
@@ -54,9 +56,11 @@ class ModuleScopePlugin {
5456
if (this.allowedFiles.has(requestFullPath)) {
5557
return callback();
5658
}
57-
if (this.allowedPaths.some((allowedFile) => {
58-
return requestFullPath.startsWith(allowedFile);
59-
})) {
59+
if (
60+
this.allowedPaths.some(allowedFile => {
61+
return requestFullPath.startsWith(allowedFile);
62+
})
63+
) {
6064
return callback();
6165
}
6266
// Find path from src to the requested file

packages/react-dev-utils/evalSourceMapMiddleware.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function base64SourceMap(source) {
1515

1616
function getSourceById(server, id) {
1717
const module = Array.from(server._stats.compilation.modules).find(
18-
(m) => server._stats.compilation.chunkGraph.getModuleId(m) == id,
18+
m => server._stats.compilation.chunkGraph.getModuleId(m) == id
1919
);
2020
return module.originalSource();
2121
}

packages/react-dev-utils/getProcessForPort.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ function isProcessAReactApp(processCommand) {
2626
}
2727

2828
function getProcessIdOnPort(port) {
29-
return execFileSync('lsof', ['-i:' + port, '-P', '-t', '-sTCP:LISTEN'], execOptions)
29+
return execFileSync(
30+
'lsof',
31+
['-i:' + port, '-P', '-t', '-sTCP:LISTEN'],
32+
execOptions
33+
)
3034
.split('\n')[0]
3135
.trim();
3236
}

0 commit comments

Comments
 (0)