Questions tagged [eslintrc]

For issues relating to .eslintrc.* configuration files.

Files of type .eslintrc.* are used to configure eslint.
Supported file formats are JavaScript (*.js), JSON (*.json) and YAML (*.yaml or *.yml).

Note that the config file .eslintrc (without extension) is deprecated in favor of .eslintrc.* files.
See: .eslintrc without file extension is deprecated.

[For] configuration files - use a JavaScript, JSON, or YAML file to specify configuration information for an entire directory and all of its subdirectories.

480 questions
16
votes
2 answers

typescript-eslint config: .eslintrc file 'module' is not defined

I am setting up a new project as described in the typescript-eslint getting started docs. However, in my .eslintrc.js file I am getting an error: 'module' is not defined.eslint(no-undef) Now, if I remove eslint:recommended from the extends of the…
Phil Lucks
  • 2,704
  • 6
  • 31
  • 57
16
votes
4 answers

How can I define tab size to 4 in ESLint?

I'm experimenting with ESLint in my workspace and I got little confused by the indent rule. Here is my rule for indent setting: "rules": { "indent": [ "error", "tab" ] } The documentation only says that there are only two options: a…
Louie Albarico
  • 230
  • 1
  • 3
  • 11
15
votes
1 answer

eslint – how to know where a rule is "defined"

Given a project with its node's package.json installing eslint and a few plugins, how can I know where a particular rule is set? I see a rule being applied (space-before-function-paren) but I cannot find it either in any of the .eslintrc files in…
Pipetus
  • 1,068
  • 1
  • 11
  • 28
15
votes
1 answer

Is the config file .eslintrc deprecated in favor of .eslintrc.* files?

I am updating some repos and would like to migrate from 5.x to 7.x eslint. But we use the file .eslintrc in all our repos. According to eslints's official configuration docs it seems to be deprecated, now. What format should we use instead? I…
Helge Drews
  • 459
  • 1
  • 4
  • 11
14
votes
7 answers

Vue 3 on Vite.js with Eslint — Unable to resolve path to module eslint(import/no-unresolved)

I use Vue 3 on Vite.js with Eslint + Airbnb config. Airbnb config has a rule eslint(import/no-unresolved), which is good, but Eslint doesn't know how to resolve alias path. I want to use aliases for paths — example: import TableComponent from…
Delicious Bacon
  • 435
  • 1
  • 4
  • 12
14
votes
6 answers

ESLint - Only Allow Absolute Import Paths Not Relative

I'm working in an Angular 11 project. A lot of the imports in this project are using a relative path or an absolute path. I have ESLint set-up for this project, I want to prevent relative import paths, and only allow absolute paths. But I'm not…
ineedtoknow
  • 1,283
  • 5
  • 28
  • 46
14
votes
1 answer

Turning eslint rule off in eslintrc.json

I am trying to disable jsx-a11y/anchor-is-valid in eslintrc.json. According to the docs, the relevant rule block looks like this: { "rules": { "jsx-a11y/anchor-is-valid": [ "error", { "components": [ "Link" ], …
Poh Zi How
  • 1,489
  • 3
  • 16
  • 38
13
votes
1 answer

How to resolve the no-undef error for setTimeout

My code componentDidMount() { // we add a hidden class to the card and after 700 ms we delete it and the transition appears this.timeOutFunction = setTimeout( function () { this.setState({cardAnimaton: ""}); …
Kim Stacks
  • 10,202
  • 35
  • 151
  • 282
12
votes
3 answers

Getting warning in 'eslint-plugin-react-settings' while running eslint

Getting the: warning: React version specified in eslint-plugin-react-settings must be a valid semver version, or "detect"; got “latest”' while running eslint. What is the reason behind this and how to resolve it? Screenshot of the issue
12
votes
5 answers

How to get rid of Delete `··` (prettier/prettier) errors in a Vue JS project

I am trying to get rid of the error in relation to @vue/prettier. I have tried a few things, but it seems to throw up even more errors. My .eslintrc.js is as follows: module.exports = { root: true, env: { node: true }, extends:…
Al-76
  • 1,738
  • 6
  • 22
  • 40
12
votes
5 answers

ESLint rule conflicts with Prettier rule

I am totally new to VSCode and this is my first setting. I know that this is a very common problem but I couldn't find a suitable solution for it. This is my understanding so far. Please correct me if I am wrong. I want to use ESLint for finding…
Reza
  • 3,473
  • 4
  • 35
  • 54
10
votes
4 answers

eslint indent rule indents decorated members

In order to enable indents for chained methods: await PostModel .findOne({ author: user.user, _id: id, }) .populate('tickets', 'title status'); I have added the following MemberExpression to my eslintrc, as per eslint docs indent":…
user776686
  • 7,933
  • 14
  • 71
  • 124
10
votes
2 answers

ESLint error: '@storybook/react' should be listed in the project's dependencies, not devDependencies

After installing Storybook into a React.js app with ESLint, the VSCode linter wasn't picking up the @storybook/react imports in the examples .stories.js files. It is giving me the following error: '@storybook/react' should be listed in the project's…
Ian
  • 1,746
  • 1
  • 15
  • 28
10
votes
2 answers

How can you set ESLint CLI settings in configuration file?

I'm trying to set max-warnings in my .eslintrc.js file. But the documentation discusses it as a Command Line Interface option. Is there a way to set this within my configuration file as opposed to the CLI option?
Charlie Fish
  • 18,491
  • 19
  • 86
  • 179
10
votes
2 answers

'number' is never reassigned. Use 'const' instead. (prefer-const)

Why in this case eslint 4.17.0 i have error number is never reassigned. Use 'const' instead. (prefer-const). Why i need to use const? Please, explain me i can't understand. let test = { 'number': 1, 'string': 'asd', }; test.number =…
Oto_Shan
  • 113
  • 1
  • 1
  • 5
1 2
3
31 32