Skip to content

Commit aa48107

Browse files
Skip eslint in build step
1 parent 654baeb commit aa48107

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

docs-site/config-overrides.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,35 @@ const ModuleScopePlugin = require("react-dev-utils/ModuleScopePlugin");
44
module.exports = function override(config, env) {
55
config.resolve.alias["react-datepicker"] = path.resolve(__dirname, "..");
66
config.resolve.alias["react"] = path.resolve(__dirname, "node_modules/react");
7-
//do stuff with the webpack config...
7+
8+
// Add raw-loader for specific example files
89
config.module.rules.push({
910
test: /\.js/,
1011
include: path.resolve(__dirname, "src/examples"),
1112
use: "raw-loader",
1213
});
14+
15+
// Remove ModuleScopePlugin to allow imports outside of 'src'
1316
config.resolve.plugins = config.resolve.plugins.filter(
1417
(plugin) => !(plugin instanceof ModuleScopePlugin),
1518
);
16-
// Enable it, so that our custom .eslintrc for the examples will work
17-
for (let i = 0; i < config.module.rules.length; i++) {
18-
if (Array.isArray(config.module.rules[i].use)) {
19-
for (let j = 0; j < config.module.rules[i].use.length; j++) {
20-
if (config.module.rules[i].use[j].loader.includes("eslint-loader")) {
21-
config.module.rules[i].use[j].options.useEslintrc = true;
22-
break;
23-
}
19+
20+
// Remove ESLint plugin if it exists
21+
config.plugins = config.plugins.filter(
22+
(plugin) => plugin.constructor.name !== "ESLintWebpackPlugin",
23+
);
24+
25+
// Skip ESLint loader by removing the eslint-loader rules
26+
config.module.rules = config.module.rules.filter((rule) => {
27+
if (rule.use) {
28+
if (Array.isArray(rule.use)) {
29+
return !rule.use.some(
30+
({ loader }) => loader && loader.includes("eslint-loader"),
31+
);
2432
}
2533
}
26-
}
34+
return true;
35+
});
36+
2737
return config;
2838
};

eslint.config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,20 @@ module.exports = [
4343
},
4444
},
4545
{
46-
files: ["src/examples/**/*.{js,jsx,ts,tsx}"],
46+
files: ["src/examples/*.js"],
4747
plugins: {
4848
react,
4949
},
50-
50+
rules: {
51+
"no-unused-expressions": "off",
52+
"react/react-in-jsx-scope": "off",
53+
"react/jsx-no-undef": [
54+
"error",
55+
{
56+
allowGlobals: true,
57+
},
58+
],
59+
},
5160
languageOptions: {
5261
globals: {
5362
useState: "readonly",

0 commit comments

Comments
 (0)