Questions tagged [eslint-config-airbnb]

Use this tag for the NPM package that provides Airbnb's .eslintrc as an extensible shared config

Relevant links

https://www.npmjs.com/package/eslint-config-airbnb

https://github.com/airbnb/javascript

https://eslint.org/docs/rules/

288 questions
152
votes
8 answers

JSX not allowed in files with extension ' .js' with eslint-config-airbnb

I've installed eslint-config-airbnb that is supposed to pre configure ESLINT for React: Our default export contains all of our ESLint rules, including ECMAScript 6+ and React. It requires eslint, eslint-plugin-import, eslint-plugin-react, and…
Mendes
  • 17,489
  • 35
  • 150
  • 263
111
votes
12 answers

How can I fix this violation of this 'react/no-unescaped-entitie' of an ESLint rule?

This is my code: const func = () => { return (
you're free
)} Somehow ESLint flags the line "you're free" with error error HTML entities must be escaped react/no-unescaped-entities However, from what I can see,…
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
104
votes
4 answers

describe is not defined when installing jest

I installed jest v24.7.1in my project with: npm install jest -D Then I start writing some test files, However I got these eslint errors: 'describe' is not defined. eslint (no-undef) 'it' is not defined. eslint (no-undef) 'expect' is not defined.…
Slim
  • 5,527
  • 13
  • 45
  • 81
59
votes
5 answers

ESLint Definition for rule 'import/extensions' was not found

I'm getting the following two errors on all TypeScript files using ESLint in VS Code: Definition for rule 'import/extensions' was not found.eslint(import/extensions) Definition for rule 'import/no-extraneous-dependencies' was not…
56
votes
3 answers

ESLint: Parsing error: This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (2:9)

I am trying to use ESLint in WebStrom, but it doesn't work and displays an error: ESLint: Parsing error: This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (2:9). Here is my .eslintrc and…
53
votes
1 answer

Solving linter error no-undef for document

I am using airbnb extension for linting my React Project. Now, in my index.js I have: import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; ReactDOM.render( , document.getElementById('root'), ); linter…
FacundoGFlores
  • 7,858
  • 12
  • 64
  • 94
52
votes
5 answers

Prettier + Airbnb's ESLint config

Recently, I've started using Visual Studio Code for my editor and found the Prettier - JavaScript formatter. I think it's a great plugin because it helps me keep my code looking nice. I set up Airbnb's ESLint config and have found that to be super…
47
votes
5 answers

Struggling with TypeScript, React, Eslint and simple Arrow Functions components

I have been struggling all morning with this issue and couldn't find the solution anywhere. I am new to typescript, and I am trying to set it up properly with Eslint and Prettier to ensure the code is properly formated. So, the issue I am facing…
47
votes
1 answer

Caught between two no-restricted-syntax violations

This is my original code: const buildTableContent = (settings) => { const entries = []; for (const key in settings) { for (const subkey in env[key]) { settings is basically a dictionary of dictionary { 'env': {'name': 'prod'}, …
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
43
votes
2 answers

ESLint "Unexpected tab character" when "indent" rule set to "tab"

I'm using ESLint with the Airbnb plugin (eslint-config-airbnb) and Babel parser. I've just added the extra rule of using Tab characters for indentation instead of spaces. Here is my .eslintrc: { "parser": "babel-eslint", "extends":…
R01010010
  • 5,670
  • 11
  • 47
  • 77
42
votes
1 answer

Must use destructuring props assignment (react/destructuring-assignment)

I've applied eslint airbnb standard to my code, so now this code: handleSubmit = (event) => { event.preventDefault(); this.props.onSearch(this.query.value); event.target.blur(); } causes this error: [eslint] Must use destructuring props…
Dominik Domanski
  • 1,023
  • 2
  • 10
  • 18
38
votes
6 answers

React linter airbnb proptypes array

I have the following PropTypes: SmartTable.propTypes = { name: React.PropTypes.string.isRequired, cols: React.PropTypes.array.isRequired, rows: React.PropTypes.array.isRequired, }; but the linter says me: Prop type "array" is forbidden, how…
FacundoGFlores
  • 7,858
  • 12
  • 64
  • 94
32
votes
5 answers

How do you disable no-plusplus when using eslint?

When using eslint in Visual Studio Code, AirBnB style Ubuntu Linux, no-plusplus is enabled as default so using ++ for example in a for loop will error: [eslint] Unary operator '++' used. (no-plusplus) How do you disable that setting?
Leigh Mathieson
  • 1,658
  • 2
  • 17
  • 25
28
votes
9 answers

How to work around jsx-a11y/no-static-element-interactions restriction?

I used the following jsx to construct an entry in a FAQ table:
  • Anthony Kong
    • 37,791
    • 46
    • 172
    • 304
  • 25
    votes
    8 answers

    Unable to resolve path to module 'react'. (import/no-unresolved)

    Seems like i am missing something here, it should work without errors but eslint keeps throwing the following: Unable to resolve path to module 'react'. (import/no-unresolved) Missing file extension for "react" (import/extensions) when trying to…
    Jalal
    • 3,308
    • 4
    • 35
    • 43
    1
    2 3
    19 20