Skip to content

Commit 8be5307

Browse files
chore: eslint migration
1 parent e07dd41 commit 8be5307

Some content is hidden

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

45 files changed

+3643
-1199
lines changed

.eslintignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/nodejs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ jobs:
103103
run: |
104104
rm package-lock.json
105105
npm install --ignore-engines
106-
if: matrix.node-version == '12.x' || matrix.node-version == '14.x' || matrix.node-version == '16.x'
106+
if: matrix.node-version == '12.x' || matrix.node-version == '14.x' || matrix.node-version == '16.x' || matrix.node-version == '18.x'
107107

108108
- name: Install dependencies
109109
run: npm ci
110-
if: matrix.node-version == '18.x' || matrix.node-version == '20.x' || matrix.node-version == '22.x' || matrix.node-version == '24.x'
110+
if: matrix.node-version == '20.x' || matrix.node-version == '22.x' || matrix.node-version == '24.x'
111111

112112
- name: Install webpack ${{ matrix.webpack-version }}
113113
if: matrix.webpack-version != 'latest'
@@ -158,11 +158,11 @@ jobs:
158158
run: |
159159
rm package-lock.json
160160
npm install --ignore-engines
161-
if: matrix.node-version == '12.x' || matrix.node-version == '14.x' || matrix.node-version == '16.x'
161+
if: matrix.node-version == '12.x' || matrix.node-version == '14.x' || matrix.node-version == '16.x' || matrix.node-version == '18.x'
162162

163163
- name: Install dependencies
164164
run: npm ci
165-
if: matrix.node-version == '18.x' || matrix.node-version == '20.x' || matrix.node-version == '22.x' || matrix.node-version == '24.x'
165+
if: matrix.node-version == '20.x' || matrix.node-version == '22.x' || matrix.node-version == '24.x'
166166

167167
- name: Run tests for webpack version latest with experimentalUseImportModule
168168
run: npm run test:coverage -- --ci

README.md

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ Allows to override default behavior and insert styles at any position.
201201

202202
```js
203203
new MiniCssExtractPlugin({
204-
insert: function (linkTag) {
205-
var reference = document.querySelector("#some-element");
204+
insert(linkTag) {
205+
const reference = document.querySelector("#some-element");
206206
if (reference) {
207207
reference.parentNode.insertBefore(linkTag, reference);
208208
}
@@ -217,7 +217,7 @@ A new `<link>` tag will be inserted before the element with the ID `some-element
217217
Type:
218218

219219
```ts
220-
type attributes = Record<string, string>};
220+
type attributes = Record<string, string>;
221221
```
222222

223223
Default: `{}`
@@ -483,9 +483,8 @@ module.exports = {
483483
{
484484
loader: MiniCssExtractPlugin.loader,
485485
options: {
486-
publicPath: (resourcePath, context) => {
487-
return path.relative(path.dirname(resourcePath), context) + "/";
488-
},
486+
publicPath: (resourcePath, context) =>
487+
`${path.relative(path.dirname(resourcePath), context)}/`,
489488
},
490489
},
491490
"css-loader",
@@ -620,6 +619,7 @@ For `development` mode (including `webpack-dev-server`) you can use [style-loade
620619

621620
```js
622621
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
622+
623623
const devMode = process.env.NODE_ENV !== "production";
624624

625625
module.exports = {
@@ -638,7 +638,7 @@ module.exports = {
638638
},
639639
],
640640
},
641-
plugins: [].concat(devMode ? [] : [new MiniCssExtractPlugin()]),
641+
plugins: [devMode ? [] : [new MiniCssExtractPlugin()]].flat(),
642642
};
643643
```
644644

@@ -702,7 +702,7 @@ module.exports = {
702702
**index.js**
703703

704704
```js
705-
import { fooBaz, bar } from "./styles.css";
705+
import { bar, fooBaz } from "./styles.css";
706706

707707
console.log(fooBaz, bar);
708708
```
@@ -767,12 +767,11 @@ module.exports = {
767767
{
768768
loader: MiniCssExtractPlugin.loader,
769769
options: {
770-
publicPath: (resourcePath, context) => {
770+
publicPath: (resourcePath, context) =>
771771
// publicPath is the relative path of the resource to the context
772772
// e.g. for ./css/admin/main.css the publicPath will be ../../
773773
// while for ./css/main.css the publicPath will be ../
774-
return path.relative(path.dirname(resourcePath), context) + "/";
775-
},
774+
`${path.relative(path.dirname(resourcePath), context)}/`,
776775
},
777776
},
778777
"css-loader",
@@ -797,8 +796,9 @@ You should not use `HotModuleReplacementPlugin` plugin if you are using a `webpa
797796
**webpack.config.js**
798797

799798
```js
800-
const webpack = require("webpack");
801799
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
800+
const webpack = require("webpack");
801+
802802
const devMode = process.env.NODE_ENV !== "production";
803803

804804
const plugins = [
@@ -848,8 +848,8 @@ You should not use `HotModuleReplacementPlugin` plugin if you are using a `webpa
848848
**webpack.config.js**
849849

850850
```js
851-
const webpack = require("webpack");
852851
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
852+
const webpack = require("webpack");
853853

854854
const plugins = [
855855
new MiniCssExtractPlugin({
@@ -890,8 +890,8 @@ To minify the output, use a plugin like [css-minimizer-webpack-plugin](https://g
890890
**webpack.config.js**
891891

892892
```js
893-
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
894893
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
894+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
895895

896896
module.exports = {
897897
plugins: [
@@ -992,17 +992,13 @@ module.exports = {
992992
fooStyles: {
993993
type: "css/mini-extract",
994994
name: "styles_foo",
995-
chunks: (chunk) => {
996-
return chunk.name === "foo";
997-
},
995+
chunks: (chunk) => chunk.name === "foo",
998996
enforce: true,
999997
},
1000998
barStyles: {
1001999
type: "css/mini-extract",
10021000
name: "styles_bar",
1003-
chunks: (chunk) => {
1004-
return chunk.name === "bar";
1005-
},
1001+
chunks: (chunk) => chunk.name === "bar",
10061002
enforce: true,
10071003
},
10081004
},
@@ -1129,7 +1125,7 @@ module.exports = {
11291125
{
11301126
loader: "sass-loader",
11311127
options: {
1132-
additionalData: `@use 'dark-theme/vars' as vars;`,
1128+
additionalData: "@use 'dark-theme/vars' as vars;",
11331129
},
11341130
},
11351131
],
@@ -1141,7 +1137,7 @@ module.exports = {
11411137
{
11421138
loader: "sass-loader",
11431139
options: {
1144-
additionalData: `@use 'light-theme/vars' as vars;`,
1140+
additionalData: "@use 'light-theme/vars' as vars;",
11451141
},
11461142
},
11471143
],
@@ -1163,7 +1159,7 @@ module.exports = {
11631159

11641160
**src/index.js**
11651161

1166-
```js
1162+
```
11671163
import "./style.scss";
11681164
11691165
let theme = "light";
@@ -1172,7 +1168,6 @@ const themes = {};
11721168
themes[theme] = document.querySelector("#theme");
11731169
11741170
async function loadTheme(newTheme) {
1175-
// eslint-disable-next-line no-console
11761171
console.log(`CHANGE THEME - ${newTheme}`);
11771172
11781173
const themeElement = document.querySelector("#theme");
@@ -1182,7 +1177,6 @@ async function loadTheme(newTheme) {
11821177
}
11831178
11841179
if (themes[newTheme]) {
1185-
// eslint-disable-next-line no-console
11861180
console.log(`THEME ALREADY LOADED - ${newTheme}`);
11871181
11881182
document.head.appendChild(themes[newTheme]);
@@ -1191,13 +1185,11 @@ async function loadTheme(newTheme) {
11911185
}
11921186
11931187
if (newTheme === "dark") {
1194-
// eslint-disable-next-line no-console
11951188
console.log(`LOADING THEME - ${newTheme}`);
11961189
11971190
import(/* webpackChunkName: "dark" */ "./style.scss?dark").then(() => {
11981191
themes[newTheme] = document.querySelector("#theme");
11991192
1200-
// eslint-disable-next-line no-console
12011193
console.log(`LOADED - ${newTheme}`);
12021194
});
12031195
}
@@ -1275,7 +1267,7 @@ MiniCssExtractPlugin.getCompilationHooks(compilation).beforeTagInsert.tap(
12751267
Template.asString([
12761268
source,
12771269
`${varNames.tag}.setAttribute("href", "https://github.com/webpack-contrib/mini-css-extract-plugin");`,
1278-
])
1270+
]),
12791271
);
12801272
```
12811273

eslint.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineConfig, globalIgnores } from "eslint/config";
2+
import configs from "eslint-config-webpack/configs.js";
3+
4+
export default defineConfig([
5+
globalIgnores([
6+
"test/**/cases/**/*",
7+
"test/manual/**/*",
8+
"!test/cases/webpack.config.js",
9+
"test/js/**/*",
10+
]),
11+
{
12+
extends: [configs["recommended-dirty"]],
13+
},
14+
]);

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = {
2+
prettierPath: require.resolve("prettier-2"),
23
transformIgnorePatterns: ["/node_modules/", "<rootDir>/dist/"],
34
watchPathIgnorePatterns: ["<rootDir>/test/js"],
45
setupFilesAfterEnv: ["<rootDir>/setupTest.js"],

0 commit comments

Comments
 (0)