Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linting error in imports

I am getting various error regarding linting. All the errors are shown in first line of code. The importing way is not incorrect but still getting linting error. How should I fix the following errors?

1:1 error Definition for rule 'import/no-named-default' was not found import/no-named-default

1:1 error Definition for rule 'react/jsx-tag-spacing' was not found react/jsx-tag-spacing

1:1 error Definition for rule 'react/no-array-index-key' was not found react/no-array-index-key

1:1 error Definition for rule 'react/require-default-props' was not found react/require-default-props

import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from './reducers';

const enhancers = [applyMiddleware(thunk)];

// If Redux DevTools Extension is installed use it, otherwise use Redux compose
/* eslint-disable no-underscore-dangle */
const composeEnhancers = process.env.NODE_ENV === 'development' && typeof window === 'object' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
  ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
  : compose;

export default(initialState) => createStore(rootReducer, initialState, composeEnhancers(...enhancers));

here is eslint source

{
  "parser": "babel-eslint",
  "extends": "airbnb",
  "env": {
    "browser": true,
    "node": true,
    "jest": true,
    "es6": true
  },
  "plugins": [
    "react",
    "jsx-a11y"
  ],
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    }
  },
  "rules": {
    "import/imports-first": 0,
    "import/newline-after-import": 0,
    "import/no-dynamic-require": 0,
    "import/no-extraneous-dependencies": 0,
    "import/no-named-as-default": 0,
    "import/no-unresolved": 2,
    "import/prefer-default-export": 0,
    "indent": [
      2,
      2,
      {
        "SwitchCase": 1
      }
    ],
    "jsx-a11y/aria-props": 2,
    "jsx-a11y/heading-has-content": 0,
    "jsx-a11y/href-no-hash": 2,
    "jsx-a11y/label-has-for": 2,
    "jsx-a11y/mouse-events-have-key-events": 2,
    "jsx-a11y/role-has-required-aria-props": 2,
    "jsx-a11y/role-supports-aria-props": 2,
    "max-len": 0,
    "newline-per-chained-call": 0,
    "no-confusing-arrow": 0,
    "no-console": 1,
    "no-use-before-define": 0,
    "prefer-template": 2,
    "class-methods-use-this": 0,
    "react/forbid-prop-types": 0,
    "react/jsx-first-prop-new-line": [
      2,
      "multiline"
    ],
    "react/jsx-filename-extension": 0,
    "react/jsx-no-target-blank": 0,
    "react/require-extension": 0,
    "react/self-closing-comp": 0,
    "require-yield": 0,
    "import/no-webpack-loader-syntax": 0
  },
  "settings": {}
}
like image 300
pythonBeginner Avatar asked May 20 '17 04:05

pythonBeginner


2 Answers

I think you forgot to add plugins eslint-plugin-react and eslint-plugin-import to your project or to your eslint config.

EDIT:

In your .eslintrc plugins field should be like this:

"plugins": [
  "react",
  "jsx-a11y",
  "import"
],
like image 72
GProst Avatar answered Nov 07 '22 01:11

GProst


Your .eslintrc rules field should have something like this:

"rules":{
"react/no-array-index-key":"off",
}

This will fix react/no-array-index error. Make sure you have eslint-plugin-react installed.

like image 30
Akash Verma Avatar answered Nov 07 '22 01:11

Akash Verma