Skip to content

Commit 6785e57

Browse files
committed
fix lint
1 parent 26b9258 commit 6785e57

File tree

4 files changed

+41
-25
lines changed

4 files changed

+41
-25
lines changed

src/index.js

+23-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
import { validate } from 'schema-utils';
44

55
import schema from './plugin-options.json';
6-
import { MODULE_TYPE, compareModulesByIdentifier, provideLoaderContext } from './utils';
6+
import {
7+
MODULE_TYPE,
8+
compareModulesByIdentifier,
9+
provideLoaderContext,
10+
} from './utils';
711

812
export const pluginName = 'mini-css-extract-plugin';
913
export const pluginSymbol = Symbol(pluginName);
@@ -31,8 +35,8 @@ const cssDependencyCache = new WeakMap();
3135
class MiniCssExtractPlugin {
3236
static getCssModule(webpack) {
3337
/**
34-
* Prevent creation of multiple CssModule classes to allow other integrations to get the current CssModule.
35-
*/
38+
* Prevent creation of multiple CssModule classes to allow other integrations to get the current CssModule.
39+
*/
3640
if (cssModuleCache.has(webpack)) {
3741
return cssModuleCache.get(webpack);
3842
}
@@ -149,9 +153,9 @@ class MiniCssExtractPlugin {
149153
super.deserialize(context);
150154
}
151155
}
152-
156+
153157
cssModuleCache.set(webpack, CssModule);
154-
158+
155159
if (
156160
webpack.util &&
157161
webpack.util.serialization &&
@@ -200,8 +204,8 @@ class MiniCssExtractPlugin {
200204

201205
static getCssDependency(webpack) {
202206
/**
203-
* Prevent creation of multiple CssDependency classes to allow other integrations to get the current CssDependency.
204-
*/
207+
* Prevent creation of multiple CssDependency classes to allow other integrations to get the current CssDependency.
208+
*/
205209
if (cssDependencyCache.has(webpack)) {
206210
return cssDependencyCache.get(webpack);
207211
}
@@ -385,10 +389,15 @@ class MiniCssExtractPlugin {
385389
const CssModule = MiniCssExtractPlugin.getCssModule(webpack);
386390
const CssDependency = MiniCssExtractPlugin.getCssDependency(webpack);
387391

388-
provideLoaderContext(compiler, `${pluginName} loader context`, (loaderContext)=>{
389-
// eslint-disable-next-line no-param-reassign
390-
loaderContext[pluginSymbol] = true;
391-
}, false)
392+
provideLoaderContext(
393+
compiler,
394+
`${pluginName} loader context`,
395+
(loaderContext) => {
396+
// eslint-disable-next-line no-param-reassign
397+
loaderContext[pluginSymbol] = true;
398+
},
399+
false
400+
);
392401

393402
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
394403
class CssModuleFactory {
@@ -1126,7 +1135,9 @@ class MiniCssExtractPlugin {
11261135

11271136
if (typeof chunkGroup[moduleIndexFunctionName] === 'function') {
11281137
// Store dependencies for modules
1129-
const moduleDependencies = new Map(modulesList.map((m) => [m, new Set()]));
1138+
const moduleDependencies = new Map(
1139+
modulesList.map((m) => [m, new Set()])
1140+
);
11301141
const moduleDependenciesReasons = new Map(
11311142
modulesList.map((m) => [m, new Map()])
11321143
);

src/loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { validate } from 'schema-utils';
66
import { findModuleById, evalModuleCode, provideLoaderContext } from './utils';
77
import schema from './loader-options.json';
88

9-
import MiniCssExtractPlugin, {pluginName, pluginSymbol} from './index';
9+
import MiniCssExtractPlugin, { pluginName, pluginSymbol } from './index';
1010

1111
function hotLoader(content, context) {
1212
const accept = context.locals

src/utils.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,24 @@ function compareModulesByIdentifier(a, b) {
4949
return compareIds(a.identifier(), b.identifier());
5050
}
5151

52-
function provideLoaderContext(compiler, name, handler, thisCompilation = true){
53-
const NormalModule = compiler.webpack && compiler.webpack.NormalModule
54-
? compiler.webpack.NormalModule
55-
: // eslint-disable-next-line global-require
56-
require('webpack/lib/NormalModule');
57-
58-
compiler.hooks[thisCompilation ? 'thisCompilation': 'compilation'].tap(
52+
function provideLoaderContext(compiler, name, handler, thisCompilation = true) {
53+
const NormalModule =
54+
compiler.webpack && compiler.webpack.NormalModule
55+
? compiler.webpack.NormalModule
56+
: // eslint-disable-next-line global-require
57+
require('webpack/lib/NormalModule');
58+
59+
compiler.hooks[thisCompilation ? 'thisCompilation' : 'compilation'].tap(
5960
name,
6061
(compilation) => {
6162
const normalModuleHook =
6263
typeof NormalModule.getCompilationHooks !== 'undefined'
6364
? NormalModule.getCompilationHooks(compilation).loader
6465
: compilation.hooks.normalModuleLoader;
6566

66-
normalModuleHook.tap(name, (loaderContext, module) => handler(loaderContext, module, compilation));
67+
normalModuleHook.tap(name, (loaderContext, module) =>
68+
handler(loaderContext, module, compilation)
69+
);
6770
}
6871
);
6972
}

test/api.test.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import webpack from 'webpack';
33
import MiniCssExtractPlugin from '../src';
44

55
describe('API', () => {
6-
76
it('should return the same CssModule when same webpack instance provided', () => {
8-
expect(MiniCssExtractPlugin.getCssModule(webpack)).toEqual(MiniCssExtractPlugin.getCssModule(webpack));
7+
expect(MiniCssExtractPlugin.getCssModule(webpack)).toEqual(
8+
MiniCssExtractPlugin.getCssModule(webpack)
9+
);
910
});
1011

1112
it('should return the same CssDependency when same webpack instance provided', () => {
12-
expect(MiniCssExtractPlugin.getCssDependency(webpack)).toEqual(MiniCssExtractPlugin.getCssDependency(webpack));
13+
expect(MiniCssExtractPlugin.getCssDependency(webpack)).toEqual(
14+
MiniCssExtractPlugin.getCssDependency(webpack)
15+
);
1316
});
14-
1517
});

0 commit comments

Comments
 (0)