eslint-plugin-prefer-import
ESLint plugin to prefer ES6 import statements when importing files.
Installation
Install the npm package
# If eslint is installed globally
npm install -g eslint-plugin-prefe-import
# If eslint is installed locally
npm install -D eslint-plugin-prefe-importAdd the plugin to the plugins section and the rule to the rules section in your .eslintrc
"plugins": [
"prefer-import"
],
"rules": {
"prefer-import/prefer-import-over-require": ["error"]
}Rules
prefer-import-over-require: Checks for anyrequirecalls and prefer the usage ofimportstatements instead.