Unofficial example
Ask the ESLint docs
The Ask this site box, reading eslint.org/docs/latest. Type a question and it answers from those pages, with links.
Loading the box…
An unofficial example. Ask this site is not affiliated with or endorsed by the ESLint project. The ESLint docs belong to their authors and are read here under their MIT licence.
Questions it answered
Real answers from this box.
How do I disable a rule for one line?
To disable a specific rule on a single line, use a line or block comment naming the rule. Any of these forms works:
- Trailing line comment: put
// eslint-disable-line no-alertafter the code on the same line. - Next-line comment: put
// eslint-disable-next-line no-alerton the line above the code. - Block comment forms:
/* eslint-disable-line no-alert */after the code, or/* eslint-disable-next-line no-alert */before it.
To disable all rules on a line, use the same comments without a rule name, for example
// eslint-disable-lineor// eslint-disable-next-line. To disable several rules, list them separated by commas, such as// eslint-disable-line no-alert, quotes, semi. These methods also work for plugin rules, where you combine the plugin name and rule name, for exampleexample/rule-name.You can explain why the rule is disabled by adding a description after the configuration, separated from it by two or more consecutive
-characters, for example// eslint-disable-next-line no-console -- reason here.Inline disabling should be used with caution and only for a clear, valid reason, not as the default way to resolve linting errors. If the disable is a temporary measure, create a follow-up task to address the underlying problem. Where possible, prefer configuration files over disable comments, since they give consistent, project-wide rule handling.
Answered from Configure Rules — Use configuration comments, Configure Rules — Comment descriptions
- Trailing line comment: put
How do I ignore files?
You can ignore files in two ways: in your configuration file, or on the command line.
eslint.config.jswithglobalIgnores(): Pass glob patterns to theglobalIgnores()helper, for exampleglobalIgnores([".config/*"]).--ignore-patternon the command line: Pass a pattern such asnpx eslint. --ignore-pattern '.config/*'.
Your patterns are added after ESLint's default ignores, which are
**/node_modules/and.git/. By default ESLint lints**/*.js,**/*.cjs, and**/*.mjs, and you can exclude these withglobalIgnores()if needed.Directory patterns work differently from
.gitignore. A pattern like.config/only matches the directory in the same folder as the configuration file. To ignore every directory with that name, use**/.config/.When you pass directories to the CLI, ignored files are skipped silently. If you pass a specific ignored file, ESLint warns that it was skipped. Use
--no-ignoreto turn off the ignore settings, including--ignore-patternand theignoresproperty.You can also name the ignore config by adding a second argument to
globalIgnores(), which helps with debugging.Answered from Ignore Files, Ignore Files — Ignore Files, Ignore Files — Ignore Directories, Ignore Files — Ignored File Warnings, Command Line Interface Reference — Ignore Files, Ignore Files — Name the Global Ignores Config
How do I extend a shared config?
To extend a shared config, import the shareable config package inside your
eslint.config.jsfile and add it to theextendsarray of a configuration object. The shareable config is an npm package that should be installed as a dependency in your project first. Theextendskey is an array, and each element can be a string naming a configuration in a plugin, a configuration object, or a configuration array. A configuration array can be inserted directly intoextends, whether the shareable config exports an object or an array.You can limit the shared config to a subset of files by setting the
fileskey on the configuration object that containsextends.You can override settings from the shared config by adding them directly into your
eslint.config.jsfile after importing it, for example in arulesblock in the same configuration object.If a package exports several configs, you can import the additional ones by their file path within the package and list them together in the
extendsarray.Answered from Share Configurations — Use a Shareable Config, Configuration Files — Use a Shareable Configuration Package, Configuration Files — Extending Configurations, Combine Configs — Apply a Config Array, Combine Configs — Apply a Config Object, Share Configurations — Sharing Multiple Configs
Add this to your own docs
Paste your docs address to try it, free and without signing up. Then it is one line of code.
DocusaurusGitBookMintlifyWordPressReadMeMkDocsVitePressStarlightSphinxHugoJekyllNext.jsGhostWebflow