Have attempted to extend the webpack config in next.config.js to use the eslint-loader (to give warnings and/or errors during dev or build, much the same as Create React App does.
What I've tried:
/* next.config.js */
module.exports = {
webpack: config => {
config.module.rules.push(
{
test: /\.js$/,
enforce: 'pre',
exclude: /node_modules/,
loader: 'eslint-loader',
},
);
return config;
},
};
/* pages/index.js */
import React from 'react';
// This line should produce an eslint error, 'foo' is assigned a variable but never used
const foo = 'bar';
function Page() {
return <h1>Welcome to next.js!</h1>
};
export default Page;
What happens:
dev and build both run without incident.
What I expect to happen:
dev and build to either fail entirely, or to produce an error in the browser, the browser console, or the CLI.
What I've already found:
I found this issue already, which I believe might have been prematurely closed - a user referenced a way to configure the loader, which the OP had presumably already done.
Has anybody got any idea how I can configure nextjs to either fail-on-error or to emit some kind of error/warning message, in a similar way to CRA?
Have attempted to extend the webpack config in
next.config.jsto use theeslint-loader(to give warnings and/or errors duringdevorbuild, much the same as Create React App does.What I've tried:
What happens:
devandbuildboth run without incident.What I expect to happen:
devandbuildto either fail entirely, or to produce an error in the browser, the browser console, or the CLI.What I've already found:
I found this issue already, which I believe might have been prematurely closed - a user referenced a way to configure the loader, which the OP had presumably already done.
Has anybody got any idea how I can configure nextjs to either fail-on-error or to emit some kind of error/warning message, in a similar way to CRA?