Skip to content

eslint-loader doesn't appear to be respected #3241

@ryami333

Description

@ryami333

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions