DEV Community

Cover image for eslint command line options supported by next lint (incl. --fix)
Jonas Schumacher
Jonas Schumacher

Posted on

eslint command line options supported by next lint (incl. --fix)

next.js comes with its own CLI for linting your code, next lint, which is basically a preconfigured wrapper around eslint.

What the documentation doesn't tell you though is whether this wrapper accepts the same command line options as eslint. The short answer is: it doesn't. At least not all of them, but a whole lot more than the only one documented by next.js' sparse documentation for this command, the --dir flag.

I found out about this only via this GitHub issue. It links to this file on GitHub, which contains a comment with the full list of supported options

The exact list and place might change in the future, but it should pretty much always stay in that file, which is where you will find the most recent version of the list. Still, for convenience's sake, here's the list as of 2021/07/07:

Options
        Basic configuration:
          -h, --help                     List this help
          -d, --dir Array                Set directory, or directories, to run ESLint - default: 'pages', 'components', and 'lib'
          -c, --config path::String      Use this configuration file, overriding all other config options
          --ext [String]                 Specify JavaScript file extensions - default: .js, .jsx, .ts, .tsx
          --resolve-plugins-relative-to path::String  A folder where plugins should be resolved from, CWD by default
        Specifying rules:
          --rulesdir [path::String]      Use additional rules from this directory
        Fixing problems:
          --fix                          Automatically fix problems
          --fix-type Array               Specify the types of fixes to apply (problem, suggestion, layout)
        Ignoring files:
          --ignore-path path::String     Specify path of ignore file
          --no-ignore                    Disable use of ignore files and patterns
        Handling warnings:
          --quiet                        Report errors only - default: false
          --max-warnings Int             Number of warnings to trigger nonzero exit code - default: -1
        Inline configuration comments:
          --no-inline-config             Prevent comments from changing config or rules
          --report-unused-disable-directives  Adds reported errors for unused eslint-disable directives ("error" | "warn" | "off")
        Caching:
          --cache                        Only check changed files - default: false
          --cache-location path::String  Path to the cache file or directory - default: .eslintcache

        Miscellaneous:
          --no-error-on-unmatched-pattern  Prevent errors when pattern is unmatched - default: false
Enter fullscreen mode Exit fullscreen mode

Top comments (0)