Skip to content

Commit

Permalink
feat(eslint-config): add support for import resolvers
Browse files Browse the repository at this point in the history
  • Loading branch information
harshcut committed Jul 31, 2022
1 parent a254c15 commit 6cf5c25
Show file tree
Hide file tree
Showing 7 changed files with 291 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-zoos-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@styx-ui/eslint-config': minor
---

Add support for import resolvers for Node and TypeScript.
5 changes: 5 additions & 0 deletions .changeset/curly-toes-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@styx-ui/eslint-config': minor
---

Extend recommended rules for `import` with support for TypeScript.
5 changes: 5 additions & 0 deletions .changeset/sour-mails-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@styx-ui/eslint-config': minor
---

Enforce a convention in the order of import statements.
5 changes: 5 additions & 0 deletions .changeset/stale-wolves-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@styx-ui/eslint-config': minor
---

Map file extensions for `import/parsers` and `import/resolver`.
20 changes: 20 additions & 0 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ module.exports = {
},
extends: [
'eslint:recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
'plugin:jsx-a11y/recommended',
Expand All @@ -37,6 +39,13 @@ module.exports = {
'no-console': 'error',
'no-inline-comments': 'warn',
'no-var': 'error',
'import/no-anonymous-default-export': 'warn',
'import/order': [
'warn',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object', 'type'],
},
],
'react/display-name': 'off',
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',
Expand Down Expand Up @@ -66,5 +75,16 @@ module.exports = {
react: {
version: 'detect',
},
'import/parsers': {
[require.resolve('@typescript-eslint/parser')]: ['.ts', '.tsx', '.d.ts'],
},
'import/resolver': {
[require.resolve('eslint-import-resolver-node')]: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
[require.resolve('eslint-import-resolver-typescript')]: {
alwaysTryTypes: true,
},
},
},
}
3 changes: 3 additions & 0 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"@rushstack/eslint-patch": "^1.1.3",
"@typescript-eslint/parser": "^5.29.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-node": "^0.3.6",
"eslint-import-resolver-typescript": "^3.3.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.30.1",
Expand Down
Loading

0 comments on commit 6cf5c25

Please sign in to comment.