Skip to content

Commit e52d8ea

Browse files
authored
Updating import ordering (#1539)
* Updating eslint, prettier, and ts for imports - DID NOT RUN A `lint:fix` - Enforcing the use of absolute paths - added new plugin `eslint-plugin-no-relative-import-paths` - Using `import type` where appropriate - ordering config - DID NOT RUN A `format:fix` - Now handles sorting import statements - added new plugin `@ianvs/prettier-plugin-sort-imports` - Set the `baseUrl` back to default - Ran script to add `src/` to all internal imports - Manually fixed ones that were missed - Update the `lazy` `import` calls for the `Routes` * Need to make settings a CJS * Running a `format:fix` for initial import sorting * Running a `lint:fix` to enforce absolute path and `import type` use * Running a `format:fix` now that `lint` forced all the `import type`
1 parent 3f5b381 commit e52d8ea

File tree

1,093 files changed

+8201
-5912
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,093 files changed

+8201
-5912
lines changed

Diff for: .eslintrc.cjs

+18-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
module.exports = {
22
extends: [
3-
'eslint-config-kentcdodds',
3+
'eslint-config-kentcdodds/import',
44
'eslint-config-kentcdodds/jsx-a11y',
55
'eslint-config-kentcdodds/react',
66
],
77
ignorePatterns: ['vite.config.ts', '__mocks__', 'playwright-tests/'],
8+
plugins: ['formatjs', 'unused-imports', 'no-relative-import-paths'],
89
parserOptions: {
910
project: './tsconfig.json',
10-
tsconfigRootDir: __dirname,
1111
},
12-
plugins: ['formatjs', 'unused-imports', 'import'],
1312
rules: {
14-
// Want to make sure imports and exports are always formatted correctly
15-
'unused-imports/no-unused-imports': 'error',
16-
'import/first': 'error',
17-
'import/newline-after-import': 'error',
18-
'import/no-duplicates': 'error',
19-
2013
// Only turning off right now to see more actual issues
2114
'@typescript-eslint/no-explicit-any': 'off',
2215
'@typescript-eslint/no-unsafe-argument': 'off',
@@ -26,6 +19,9 @@ module.exports = {
2619
'@typescript-eslint/no-unsafe-call': 'off',
2720
'@typescript-eslint/no-unsafe-member-access': 'off',
2821

22+
// These really help with managing circular deps that don't matter
23+
'@typescript-eslint/consistent-type-imports': 'error',
24+
2925
// Helpful for dev... maybe make different settings for "final code"?
3026
'no-console': 'off',
3127

@@ -49,6 +45,7 @@ module.exports = {
4945
// We should never have these unless commented and explained
5046
'react-hooks/exhaustive-deps': 'error',
5147

48+
// --------------------------IMPORTS --------------------------
5249
// Original LoadingButton can cause issues with Google Translate
5350
// https://github.com/mui/material-ui/issues/27853
5451
// https://github.com/facebook/react/issues/11538
@@ -69,5 +66,16 @@ module.exports = {
6966
message: 'Please use @supabase/postgrest-js',
7067
},
7168
],
69+
70+
// Absolute paths just makes moving files so much easier
71+
'no-relative-import-paths/no-relative-import-paths': [
72+
'error',
73+
{ allowSameFolder: false },
74+
],
75+
76+
'unused-imports/no-unused-imports': 'error',
77+
'import/first': 'error',
78+
'import/newline-after-import': 'error',
79+
'import/no-duplicates': 'error',
7280
},
73-
};
81+
};

Diff for: .prettierrc

-17
This file was deleted.

Diff for: .prettierrc.cjs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module.exports = {
2+
plugins: ['@ianvs/prettier-plugin-sort-imports'],
3+
arrowParens: 'always',
4+
bracketSameLine: false,
5+
bracketSpacing: true,
6+
embeddedLanguageFormatting: 'auto',
7+
insertPragma: false,
8+
jsxSingleQuote: false,
9+
printWidth: 80,
10+
proseWrap: 'preserve',
11+
quoteProps: 'consistent',
12+
requirePragma: false,
13+
semi: true,
14+
singleQuote: true,
15+
tabWidth: 4,
16+
trailingComma: 'es5',
17+
useTabs: false,
18+
importOrderTypeScriptVersion: '4.9.4',
19+
importOrder: [
20+
'<TYPES>',
21+
'',
22+
'^(react/(.*)$)|^(react$)',
23+
'^(use-*|react-use/(.*)$)',
24+
'',
25+
'^(@mui/(.*)$)|^(@mui)',
26+
'',
27+
'^(@jsonforms/(.*)$)|^(@jsonforms)',
28+
'^(zustand/(.*)$)|^(zustand)',
29+
'',
30+
'<THIRD_PARTY_MODULES>',
31+
'',
32+
'^(src/(.*)$)|^(src)',
33+
'',
34+
'.(png|svg|css)$',
35+
],
36+
};

Diff for: __mocks__/zustand/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { act } from '@testing-library/react';
21
import * as zustand from 'zustand';
32

3+
import { act } from '@testing-library/react';
4+
45
const { create: actualCreate, createStore: actualCreateStore } =
56
await vi.importActual<typeof zustand>('zustand');
67

0 commit comments

Comments
 (0)