Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESLint 9 #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 39 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,59 @@ The Jared Wilcurt's strict ESLint rules for importing files.

## Using this

1. `npm install --save-dev eslint-plugin-import eslint-config-tjw-import`
1. In your `.eslitrc.js` add `tjw-import` to your `extends` like so:
1. `npm install --save-dev eslint eslint-plugin-import eslint-config-tjw-import`
1. In your `eslint.config.js`:
```js
module.exports = {
extends: [
'tjw-import'
]
};
import importPlugin from 'eslint-plugin-import';
import tjwImport from 'eslint-config-tjw-import';

export default [
importPlugin.flatConfigs.recommended,
tjwImport,
{
// Then project specific rules/settings
}
];
```


## Vite/Webpack aliases
## Vite aliases

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.
You may want to add in an import resolver if you use **Vite** for aliasing.

`npm install --save-dev eslint-import-resolver-webpack`
`npm install --save-dev eslint-import-resolver-vite`

```js
// .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')
// eslint.config.js
import path from 'node:path';

import importPlugin from 'eslint-plugin-import';
import tjwImport from 'eslint-config-tjw-import';

const __dirname = import.meta.dirname;

export default [
importPlugin.flatConfigs.recommended,
tjwImport,
{
// Project specific rules/settings
settings: {
'import/resolver': {
vite: {
viteConfig: {
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'@@': path.resolve(__dirname, 'tests'),
'@@@': path.resolve(__dirname, 'docs')
}
}
}
}
}
}
}
};
];
```


Expand Down
26 changes: 21 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
module.exports = {
extends: [
'plugin:import/errors',
'plugin:import/warnings'
],
export default {
rules: {
'import/default': 'error',
'import/dynamic-import-chunkname': 'off',
Expand Down Expand Up @@ -142,6 +138,26 @@ module.exports = {
group: 'object',
position: 'before'
},
{
pattern: '@@@/helpers/**',
group: 'object',
position: 'before'
},
{
pattern: '@@@/mixins/**',
group: 'object',
position: 'before'
},
{
pattern: '@/**/*.vue',
group: 'object',
position: 'before'
},
{
pattern: '@@@/**/*.vue',
group: 'object',
position: 'before'
},
{
pattern: '**/*.vue',
group: 'object',
Expand Down
Loading