Skip to content

Commit 0646f4e

Browse files
committed
chore: cleanup code and lint files
1 parent 37bc524 commit 0646f4e

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ module.exports = api => {
107107
This plugin accepts a few options that are specifically targeted for advanced users.
108108
The allowed values are as follows:
109109

110-
| Name | Type | Default | Description |
111-
| :-----------------------: | :-------: | :-----: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
112-
| **`disableRefreshCheck`** | `boolean` | `false` | Disables detection of react-refresh's Babel plugin. Useful if you do not parse JS files within `node_modules`, or if you have a Babel setup not entirely controlled by Webpack. |
113-
| **`forceEnable`** | `boolean` | `false` | Enables the plugin forcefully. Useful if you want to use the plugin in production, or if you are using Webpack's `none` mode without `NODE_ENV`, for example. |
114-
| **`useLegacyWDSSockets`** | `boolean` | `false` | Set this to true if you are using a webpack-dev-server version prior to 3.8 as it requires a custom SocketJS implementation. |
110+
| Name | Type | Default | Description |
111+
| :-----------------------: | :-------: | :-----: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
112+
| **`disableRefreshCheck`** | `boolean` | `false` | Disables detection of react-refresh's Babel plugin. Useful if you do not parse JS files within `node_modules`, or if you have a Babel setup not entirely controlled by Webpack. |
113+
| **`forceEnable`** | `boolean` | `false` | Enables the plugin forcefully. Useful if you want to use the plugin in production, or if you are using Webpack's `none` mode without `NODE_ENV`, for example. |
114+
| **`useLegacyWDSSockets`** | `boolean` | `false` | Set this to true if you are using a webpack-dev-server version prior to 3.8 as it requires a custom SocketJS implementation. If you use this, you will also need to install `sockjs-client` as a peer depencency. |
115115

116116
## Related Work
117117

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,16 @@
3131
],
3232
"scripts": {
3333
"lint": "eslint --report-unused-disable-directives \"**/*.js\"",
34-
"lint:fix": "yarn run lint:eslint --fix",
34+
"lint:fix": "yarn lint --fix",
3535
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
36-
"format:heck": "prettier --check \"**/*.{js,jsx,json,md}\""
36+
"format:check": "prettier --check \"**/*.{js,jsx,json,md}\""
3737
},
3838
"dependencies": {
3939
"ansi-html": "^0.0.7",
4040
"error-stack-parser": "^2.0.4",
4141
"html-entities": "^1.2.1",
4242
"lodash.debounce": "^4.0.8",
43-
"react-dev-utils": "^9.1.0",
44-
"sockjs-client": "^1.4.0"
43+
"react-dev-utils": "^9.1.0"
4544
},
4645
"devDependencies": {
4746
"eslint": "^6.7.2",
@@ -53,9 +52,13 @@
5352
},
5453
"peerDependencies": {
5554
"react-refresh": ">= 0.7",
55+
"sockjs-client": "^1.4.0",
5656
"webpack-hot-middleware": "^2.25.0"
5757
},
5858
"peerDependenciesMeta": {
59+
"sockjs-client": {
60+
"optional": true
61+
},
5962
"webpack-hot-middleware": {
6063
"optional": true
6164
}

src/helpers/createRefreshTemplate.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ const { Template } = require('webpack');
99
*/
1010
const beforeModule = `
1111
let cleanup = function NoOp() {};
12-
let check = function (it) {
12+
13+
const check = function(it) {
1314
return it && it.Math == Math && it;
1415
};
1516
16-
let safeThis =
17+
const safeThis =
1718
check(typeof globalThis == 'object' && globalThis) ||
1819
check(typeof window == 'object' && window) ||
1920
check(typeof self == 'object' && self) ||
@@ -37,10 +38,9 @@ const afterModule = `
3738
/**
3839
* Creates a module wrapped by a refresh template.
3940
* @param {string} source The source code of a module.
40-
* @param {import('webpack').compilation.Chunk} chunk A Webpack chunk.
4141
* @returns {string} A refresh-wrapped module.
4242
*/
43-
function createRefreshTemplate(source, chunk) {
43+
function createRefreshTemplate(source) {
4444
const lines = source.split('\n');
4545

4646
// Webpack generates this line whenever the mainTemplate is called

0 commit comments

Comments
 (0)