Skip to content

Commit

Permalink
fix(eslint): add rules to enforce consistent type imports and import …
Browse files Browse the repository at this point in the history
…sort orders
  • Loading branch information
bjoerge committed Feb 12, 2024
1 parent 95890c6 commit 1ec2c39
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
23 changes: 21 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@ const config = {
'@sanity/eslint-config-i18n',
],
parser: '@typescript-eslint/parser',
plugins: ['boundaries', 'import', '@typescript-eslint', 'prettier', 'react', 'tsdoc'],
plugins: [
'boundaries',
'import',
'simple-import-sort',
'unused-imports',
'@typescript-eslint',
'prettier',
'react',
'tsdoc',
],
ignorePatterns: [
'**/etc/*',
'**/.sanity/*',
Expand All @@ -48,7 +57,6 @@ const config = {
'import/no-named-as-default-member': 'off',
'import/no-unresolved': 'off',
'prettier/prettier': 'error',
'sort-imports': 'off', // prefer import/order
'tsdoc/syntax': 'error',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': [
Expand All @@ -72,6 +80,17 @@ const config = {
'@typescript-eslint/no-dupe-class-members': ['error'],
'@typescript-eslint/no-shadow': ['error'],
'@typescript-eslint/no-unused-vars': ['warn'],
'@typescript-eslint/consistent-type-imports': ['error', {prefer: 'type-imports'}],
'unused-imports/no-unused-imports': 'error',
'unused-imports/no-unused-vars': ['warn'],
'import/no-duplicates': ['error', {'prefer-inline': true}],
'import/first': 'error',
'import/newline-after-import': 'error',
'import/consistent-type-specifier-style': ['error', 'prefer-inline'],
'import/order': 'off', // handled by simple-import-sort
'sort-imports': 'off', // handled by simple-import-sort
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'boundaries/element-types': [
'error',
{
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^11.0.0",
"eslint-plugin-tsdoc": "^0.2.17",
"eslint-plugin-unused-imports": "^3.0.0",
"execa": "^2.0.0",
"glob": "^7.2.0",
"globby": "^10.0.0",
Expand Down
23 changes: 20 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7804,6 +7804,11 @@ eslint-plugin-react@^7.32.2, eslint-plugin-react@^7.33.2:
semver "^6.3.1"
string.prototype.matchall "^4.0.8"

eslint-plugin-simple-import-sort@^11.0.0:
version "11.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-11.0.0.tgz#06693fd7a19cecc30cb042fb49fed38b3f1c21b0"
integrity sha512-3zxeF/0piwHA7/JlbpOmMJ1/1tc1dSRiir4DwpEnP747alKwZbj5xX+ZxroShMBU6LNDkpquo7FsXHCBc0HgCA==

eslint-plugin-tsdoc@^0.2.17:
version "0.2.17"
resolved "https://registry.yarnpkg.com/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.17.tgz#27789495bbd8778abbf92db1707fec2ed3dfe281"
Expand All @@ -7812,6 +7817,18 @@ eslint-plugin-tsdoc@^0.2.17:
"@microsoft/tsdoc" "0.14.2"
"@microsoft/tsdoc-config" "0.16.2"

eslint-plugin-unused-imports@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-3.0.0.tgz#d25175b0072ff16a91892c3aa72a09ca3a9e69e7"
integrity sha512-sduiswLJfZHeeBJ+MQaG+xYzSWdRXoSw61DpU13mzWumCkR0ufD0HmO4kdNokjrkluMHpj/7PJeN35pgbhW3kw==
dependencies:
eslint-rule-composer "^0.3.0"

eslint-rule-composer@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz#79320c927b0c5c0d3d3d2b76c8b4a488f25bbaf9"
integrity sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==

[email protected]:
version "5.1.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c"
Expand Down Expand Up @@ -8177,9 +8194,9 @@ [email protected], fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==

fast-diff@^1.1.2:
version "1.2.0"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.2.0.tgz#73ee11982d86caaf7959828d519cfe927fac5f03"
integrity sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==
version "1.3.0"
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0"
integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==

fast-fifo@^1.1.0, fast-fifo@^1.2.0, fast-fifo@^1.3.2:
version "1.3.2"
Expand Down

0 comments on commit 1ec2c39

Please sign in to comment.