Skip to content

Commit

Permalink
Skip eslint in build step
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnrusschen committed Oct 18, 2024
1 parent 654baeb commit aa48107
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
30 changes: 20 additions & 10 deletions docs-site/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,35 @@ const ModuleScopePlugin = require("react-dev-utils/ModuleScopePlugin");
module.exports = function override(config, env) {
config.resolve.alias["react-datepicker"] = path.resolve(__dirname, "..");
config.resolve.alias["react"] = path.resolve(__dirname, "node_modules/react");
//do stuff with the webpack config...

// Add raw-loader for specific example files
config.module.rules.push({
test: /\.js/,
include: path.resolve(__dirname, "src/examples"),
use: "raw-loader",
});

// Remove ModuleScopePlugin to allow imports outside of 'src'
config.resolve.plugins = config.resolve.plugins.filter(
(plugin) => !(plugin instanceof ModuleScopePlugin),
);
// Enable it, so that our custom .eslintrc for the examples will work
for (let i = 0; i < config.module.rules.length; i++) {
if (Array.isArray(config.module.rules[i].use)) {
for (let j = 0; j < config.module.rules[i].use.length; j++) {
if (config.module.rules[i].use[j].loader.includes("eslint-loader")) {
config.module.rules[i].use[j].options.useEslintrc = true;
break;
}

// Remove ESLint plugin if it exists
config.plugins = config.plugins.filter(
(plugin) => plugin.constructor.name !== "ESLintWebpackPlugin",
);

// Skip ESLint loader by removing the eslint-loader rules
config.module.rules = config.module.rules.filter((rule) => {
if (rule.use) {
if (Array.isArray(rule.use)) {
return !rule.use.some(
({ loader }) => loader && loader.includes("eslint-loader"),
);
}
}
}
return true;
});

return config;
};
13 changes: 11 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,20 @@ module.exports = [
},
},
{
files: ["src/examples/**/*.{js,jsx,ts,tsx}"],
files: ["src/examples/*.js"],
plugins: {
react,
},

rules: {
"no-unused-expressions": "off",
"react/react-in-jsx-scope": "off",
"react/jsx-no-undef": [
"error",
{
allowGlobals: true,
},
],
},
languageOptions: {
globals: {
useState: "readonly",
Expand Down

0 comments on commit aa48107

Please sign in to comment.