linting error in imports
Solution 1
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"
],
Solution 2
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.
pythonBeginner
Updated on June 13, 2022Comments
-
pythonBeginner almost 2 years
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": {} }
-
pythonBeginner almost 7 yearsI have installed these packages "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^4.0.0", "eslint-plugin-react": "^6.10.3", "eslint": "^3.19.0",
-
GProst almost 7 years
-
Mnebuerquo about 4 yearsThis won't work because reducers probably are not an installed package, but a relative path. Importing from 'reducers' will look for a package of that name, while './reducers' will look for the path.