Skip to content

Commit 75718b7

Browse files
hiroppyevilebottnawi
authored andcommitted
refactor(eslint): make global-require to off (#2137)
1 parent a478595 commit 75718b7

22 files changed

+5
-43
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"no-underscore-dangle": "off",
1616
"prefer-destructuring": ["error", { "object": false, "array": false }],
1717
"prefer-rest-params": "off",
18-
"strict": ["error", "safe"]
18+
"strict": ["error", "safe"],
19+
"global-require": "off"
1920
}
2021
}

bin/options.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
/* eslint-disable
4-
global-require,
54
multiline-ternary,
65
space-before-function-paren
76
*/

client-src/default/utils/reloadApp.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ function reloadApp(
1313
}
1414
if (hot) {
1515
log.info('[WDS] App hot update...');
16-
// eslint-disable-next-line global-require
1716
const hotEmitter = require('webpack/hot/emitter');
1817
hotEmitter.emit('webpackHotUpdate', currentHash);
1918
if (typeof self !== 'undefined' && self.window) {

client-src/live/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
/* eslint import/no-extraneous-dependencies: off, global-require: off */
3+
/* eslint import/no-extraneous-dependencies: off */
44

55
const $ = require('jquery');
66
const stripAnsi = require('strip-ansi');

examples/general/proxy-hot-reload/webpack.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
/* eslint global-require: off */
43
const fs = require('fs');
54
// our setup function adds behind-the-scenes bits to the config that all of our
65
// examples need

lib/Server.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,6 @@ class Server {
665665
// The relevant issues are:
666666
// https://github.com/spdy-http2/node-spdy/issues/350
667667
// https://github.com/webpack/webpack-dev-server/issues/1592
668-
// eslint-disable-next-line global-require
669668
this.listeningApp = require('spdy').createServer(
670669
this.options.https,
671670
this.app

lib/servers/SockJSServer.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ const BaseServer = require('./BaseServer');
1111
// sockjs will remove Origin header, however Origin header is required for checking host.
1212
// See https://github.com/webpack/webpack-dev-server/issues/1604 for more information
1313
{
14-
// eslint-disable-next-line global-require
1514
const SockjsSession = require('sockjs/lib/transport').Session;
1615
const decorateConnection = SockjsSession.prototype.decorateConnection;
1716
SockjsSession.prototype.decorateConnection = function(req) {

lib/utils/getSocketClientPath.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ function getSocketClientPath(options) {
77
case 'string':
88
// could be 'sockjs', 'ws', or a path that should be required
99
if (options.clientMode === 'sockjs') {
10-
// eslint-disable-next-line global-require
1110
ClientImplementation = require('../../client/clients/SockJSClient');
1211
} else if (options.clientMode === 'ws') {
13-
// eslint-disable-next-line global-require
1412
ClientImplementation = require('../../client/clients/WebsocketClient');
1513
} else {
1614
try {
17-
// eslint-disable-next-line global-require, import/no-dynamic-require
15+
// eslint-disable-next-line import/no-dynamic-require
1816
ClientImplementation = require(options.clientMode);
1917
} catch (e) {
2018
clientImplFound = false;

lib/utils/getSocketServerImplementation.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ function getSocketServerImplementation(options) {
77
case 'string':
88
// could be 'sockjs', in the future 'ws', or a path that should be required
99
if (options.serverMode === 'sockjs') {
10-
// eslint-disable-next-line global-require
1110
ServerImplementation = require('../servers/SockJSServer');
1211
} else if (options.serverMode === 'ws') {
13-
// eslint-disable-next-line global-require
1412
ServerImplementation = require('../servers/WebsocketServer');
1513
} else {
1614
try {
17-
// eslint-disable-next-line global-require, import/no-dynamic-require
15+
// eslint-disable-next-line import/no-dynamic-require
1816
ServerImplementation = require(options.serverMode);
1917
} catch (e) {
2018
serverImplFound = false;

lib/utils/getVersions.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict';
22

3-
/* eslint-disable global-require */
4-
53
function getVersions() {
64
return (
75
`webpack-dev-server ${require('../../package.json').version}\n` +

lib/utils/runBonjour.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
function runBonjour(options) {
4-
// eslint-disable-next-line global-require
54
const bonjour = require('bonjour')();
65

76
bonjour.publish({

test/client/index.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
/* eslint-disable
4-
global-require,
54
no-undefined
65
*/
76
/* global self */

test/client/socket-helper.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ describe('socket', () => {
88

99
it('should default to SockJSClient when no __webpack_dev_server_client__ set', () => {
1010
jest.mock('../../client/clients/SockJSClient');
11-
// eslint-disable-next-line global-require
1211
const socket = require('../../client/socket');
13-
// eslint-disable-next-line global-require
1412
const SockJSClient = require('../../client/clients/SockJSClient');
1513

1614
const mockHandler = jest.fn();
@@ -38,9 +36,7 @@ describe('socket', () => {
3836

3937
it('should use __webpack_dev_server_client__ when set', () => {
4038
jest.mock('../../client/clients/SockJSClient');
41-
// eslint-disable-next-line global-require
4239
const socket = require('../../client/socket');
43-
// eslint-disable-next-line global-require
4440
global.__webpack_dev_server_client__ = require('../../client/clients/SockJSClient');
4541

4642
const mockHandler = jest.fn();

test/client/utils/createSocketUrl.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ describe('createSocketUrl', () => {
2121
() => () => url
2222
);
2323

24-
// eslint-disable-next-line global-require
2524
const createSocketUrl = require('../../../client-src/default/utils/createSocketUrl');
2625

2726
test(`should return the url when __resourceQuery is ${url}`, () => {

test/client/utils/log.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ describe('log', () => {
66

77
beforeEach(() => {
88
jest.mock('loglevel');
9-
// eslint-disable-next-line global-require
109
logMock = require('loglevel');
1110
logMock.getLogger.mockImplementation(() => {
1211
return {
@@ -17,7 +16,6 @@ describe('log', () => {
1716
};
1817
});
1918

20-
// eslint-disable-next-line global-require
2119
setLogLevel = require('../../../client-src/default/utils/log').setLogLevel;
2220
});
2321

test/client/utils/reloadApp.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ describe('reloadApp', () => {
1515

1616
jest.mock('loglevel');
1717

18-
// eslint-disable-next-line global-require
1918
log = require('loglevel');
2019
log.getLogger.mockImplementation(() => {
2120
return {
@@ -24,7 +23,6 @@ describe('reloadApp', () => {
2423
};
2524
});
2625

27-
// eslint-disable-next-line global-require
2826
reloadApp = require('../../../client-src/default/utils/reloadApp');
2927
});
3028

@@ -47,7 +45,6 @@ describe('reloadApp', () => {
4745

4846
test('should run hot', () => {
4947
jest.mock('webpack/hot/emitter');
50-
// eslint-disable-next-line global-require
5148
const emitter = require('webpack/hot/emitter');
5249
emitter.emit = jest.fn();
5350

test/e2e/Progress.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ describe('client progress', () => {
2222
processStderrMock = jest
2323
.spyOn(process.stderr, 'write')
2424
.mockImplementation();
25-
// eslint-disable-next-line global-require
2625
testServer = require('../helpers/test-server');
2726

2827
fs.writeFileSync(

test/server/Server.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ describe('Server', () => {
137137
it('should be present', () => {
138138
expect(process.env.WEBPACK_DEV_SERVER).toBeUndefined();
139139

140-
// eslint-disable-next-line global-require
141140
require('../../lib/Server');
142141

143142
expect(process.env.WEBPACK_DEV_SERVER).toBe(true);

test/server/clientMode-option.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ describe('clientMode option', () => {
2929
describe('is passed to getSocketClientPath correctly', () => {
3030
beforeEach(() => {
3131
jest.mock('../../lib/utils/getSocketClientPath');
32-
// eslint-disable-next-line global-require
3332
getSocketClientPath = require('../../lib/utils/getSocketClientPath');
3433
});
3534

@@ -42,7 +41,6 @@ describe('clientMode option', () => {
4241

4342
clientModes.forEach((data) => {
4443
it(data.title, (done) => {
45-
// eslint-disable-next-line global-require
4644
mockedTestServer = require('../helpers/test-server');
4745
mockedTestServer.start(
4846
config,
@@ -67,7 +65,6 @@ describe('clientMode option', () => {
6765
describe('passed to server', () => {
6866
beforeAll(() => {
6967
jest.unmock('../../lib/utils/getSocketClientPath');
70-
// eslint-disable-next-line global-require
7168
testServer = require('../helpers/test-server');
7269
});
7370

test/server/http2-option.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ describe('http2 option', () => {
2727
semver.gte(process.version, '8.8.0') &&
2828
semver.lt(process.version, '10.0.0')
2929
) {
30-
/* eslint-disable global-require */
3130
const http2 = require('http2');
32-
/* eslint-enable global-require */
3331
describe('http2 works with https', () => {
3432
beforeAll((done) => {
3533
server = testServer.start(

test/server/serverMode-option.test.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ describe('serverMode option', () => {
5757
describe('is passed to getSocketServerImplementation correctly', () => {
5858
beforeEach(() => {
5959
jest.mock('../../lib/utils/getSocketServerImplementation');
60-
// eslint-disable-next-line global-require
6160
getSocketServerImplementation = require('../../lib/utils/getSocketServerImplementation');
6261
getSocketServerImplementation.mockImplementation(() => {
6362
return class MockServer {
@@ -76,7 +75,6 @@ describe('serverMode option', () => {
7675

7776
serverModes.forEach((data) => {
7877
it(data.title, (done) => {
79-
// eslint-disable-next-line global-require
8078
mockedTestServer = require('../helpers/test-server');
8179
mockedTestServer.start(
8280
config,
@@ -102,7 +100,6 @@ describe('serverMode option', () => {
102100
describe('passed to server', () => {
103101
beforeAll(() => {
104102
jest.unmock('../../lib/utils/getSocketServerImplementation');
105-
// eslint-disable-next-line global-require
106103
testServer = require('../helpers/test-server');
107104
});
108105

@@ -410,9 +407,7 @@ describe('serverMode option', () => {
410407
let MockSockJSServer;
411408
beforeEach((done) => {
412409
jest.mock('../../lib/servers/SockJSServer');
413-
// eslint-disable-next-line global-require
414410
mockedTestServer = require('../helpers/test-server');
415-
// eslint-disable-next-line global-require
416411
MockSockJSServer = require('../../lib/servers/SockJSServer');
417412

418413
server = mockedTestServer.start(

test/server/utils/updateCompiler.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ describe('updateCompiler', () => {
77
describe('simple config, inline', () => {
88
let compiler;
99
beforeAll(() => {
10-
// eslint-disable-next-line global-require
1110
const webpackConfig = require('../../fixtures/simple-config/webpack.config');
1211
compiler = webpack(webpackConfig);
1312
});
@@ -44,7 +43,6 @@ describe('updateCompiler', () => {
4443
describe('simple config, hot and inline', () => {
4544
let compiler;
4645
beforeAll(() => {
47-
// eslint-disable-next-line global-require
4846
const webpackConfig = require('../../fixtures/simple-config/webpack.config');
4947
compiler = webpack(webpackConfig);
5048
});
@@ -81,7 +79,6 @@ describe('updateCompiler', () => {
8179
describe('simple config with HMR already, hot and inline', () => {
8280
let compiler;
8381
beforeAll(() => {
84-
// eslint-disable-next-line global-require
8582
const webpackConfig = require('../../fixtures/simple-config/webpack.config');
8683
webpackConfig.plugins = [new webpack.HotModuleReplacementPlugin()];
8784
compiler = webpack(webpackConfig);
@@ -119,7 +116,6 @@ describe('updateCompiler', () => {
119116
describe('multi compiler config, hot and inline', () => {
120117
let multiCompiler;
121118
beforeAll(() => {
122-
// eslint-disable-next-line global-require
123119
const webpackConfig = require('../../fixtures/multi-compiler-2-config/webpack.config');
124120
webpackConfig[1].plugins = [new webpack.HotModuleReplacementPlugin()];
125121
multiCompiler = webpack(webpackConfig);

0 commit comments

Comments
 (0)