You need to use eslint-plugin-import
: https://github.com/benmosher/eslint-plugin-import
And configure your eslint settings in .eslintrc
module.exports = {
...
"settings": {
"import/resolver": {
"node": {
"paths": ["src"]
}
},
},
}
Then, you can use import from src
folder.
Example, if you have src/components/MyComponent.jsx
, you will write this:
import MyComponent from 'components/MyComponent.jsx';
Related Contents:
- Trying to use fetch and pass in mode: no-cors
- where is create-react-app webpack config and files?
- The create-react-app imports restriction outside of src directory
- ‘React’ refers to a UMD global, but the current file is a module
- Home does not contain an export named Home
- Development server of create-react-app does not auto refresh
- Where’s the connection between index.html and index.js in a Create-React-App application?
- Can’t build create-react-app project with custom PUBLIC_URL
- How is ESLint integrated into Create React App?
- npm start error with create-react-app
- Best way to polyfill ES6 features in React app that uses create-react-app
- ‘command not found: jest’
- How to use create-react-app with an older React version?
- Service Worker registration error: Unsupported MIME type (‘text/html’)
- How to make an import shortcut/alias in create-react-app?
- create-react-app is showing all my code in production, how to hide it?
- Warning: validateDOMNesting(…): cannot appear as a descendant of
- How to use jest.config.js with create-react-app
- Migrating create-react-app from javascript to typescript
- Jest – SyntaxError: Cannot use import statement outside a module
- How to use React without unsafe inline JavaScript/CSS code?
- Best way to create new React component using create-react-app
- What is “npm run build” in create-react-app?
- What Does Eject do in Create React App?
- React fragment shorthand failing to compile
- “ReferenceError: document is not defined” when trying to test a create-react-app project
- React still showing errors after catching with ErrorBoundary
- How to update webpack config for a react project created using create-react-app?
- Error “Your cache folder contains root-owned files, due to a bug in previous versions of npm” while “npx create-react-app example_app”
- What is the difference between state and props in React?
- How can I update state.item[1] in state using setState?
- react-router scroll to top on every transition
- What is {this.props.children} and when you should use it?
- react-testing-library why is toBeInTheDocument() not a function
- How to Set port in next.js
- React Router v4 vs benefits
- How to use JQuery with ReactJS
- import * as React from ‘react’; vs import React from ‘react’;
- Using styled-components with props and TypeScript
- How to add custom html attributes in JSX
- How to Call a Function inside a Render in React/Jsx
- !important inline styles in react
- React.js — How to pass properties object to child component?
- How target DOM with react useRef in map
- React suspense/lazy delay?
- Arrow functions and the use of parentheses () or {} or ({})
- Redux TypeError: Cannot read property ‘apply’ of undefined
- Using JQuery plugins that transform the DOM in React Components?
- How to set state of response from axios in react
- React: useEffect vs useMemo vs useState