The Jared Wilcurt's strict ESLint rules for importing files.
npm install --save-dev eslint-plugin-import eslint-config-tjw-import
- In your
.eslitrc.js
addtjw-import
to yourextends
like so:module.exports = { extends: [ 'tjw-import' ] };
You may optionally want to add in an import resolver if you use Vite or Webpack for aliasing. The below code says "webpack" but works for both.
npm install --save-dev eslint-import-resolver-webpack
// .eslintrc.js
const path = require('path');
module.exports = {
extends: [
'tjw-import'
],
settings: {
'import/resolver': {
webpack: {
config: {
resolve: {
alias: {
'@': path.resolve('src'),
'@@': path.resolve('tests'),
'@@@': path.resolve('docs')
}
}
}
}
}
}
};
See also: