1- module . exports = ( { tsconfigRootDir } ) => ( {
1+ module . exports = ( { tsconfigRootDir, optimizeImports } ) => ( {
22 root : true ,
33 extends : [
44 'airbnb' ,
@@ -11,7 +11,7 @@ module.exports = ({ tsconfigRootDir }) => ({
1111 'plugin:prettier/recommended' ,
1212 // 'plugin:lodash/recommended',
1313 ] ,
14- plugins : [ 'react' , '@typescript-eslint' , 'react-compiler' ] ,
14+ plugins : [ 'react' , '@typescript-eslint' , 'react-compiler' , ... ( optimizeImports ? [ 'unused-imports' ] : [ ] ) ] ,
1515 ignorePatterns : [ '*.js' ] ,
1616 env : {
1717 browser : true ,
@@ -68,7 +68,47 @@ module.exports = ({ tsconfigRootDir }) => ({
6868 'import/no-webpack-loader-syntax' : 'off' , // Disable to allow webpack file-loaders syntax
6969 'import/no-unresolved' : 'off' , // Disable to allow webpack file-loaders syntax
7070 'import/prefer-default-export' : 'off' ,
71- 'import/order' : 'error' ,
71+ ...( optimizeImports ? {
72+ 'import/order' : [
73+ 1 ,
74+ {
75+ groups : [ [ 'builtin' , 'external' ] , 'internal' , [ 'sibling' , 'parent' ] ] ,
76+ pathGroups : [
77+ {
78+ pattern : 'react*' ,
79+ group : 'external' ,
80+ position : 'before' ,
81+ } ,
82+ { pattern : 'src/**' , group : 'internal' , position : 'after' } ,
83+ ] ,
84+ pathGroupsExcludedImportTypes : [ 'internal' , 'react' ] ,
85+ 'newlines-between' : 'always' ,
86+ alphabetize : { order : 'asc' } ,
87+ } ,
88+ ] ,
89+ 'sort-imports' : [
90+ 1 ,
91+ {
92+ ignoreCase : false ,
93+ ignoreDeclarationSort : true , // don't want to sort import lines, use eslint-plugin-import instead
94+ ignoreMemberSort : false ,
95+ memberSyntaxSortOrder : [ 'none' , 'all' , 'multiple' , 'single' ] ,
96+ allowSeparatedGroups : true ,
97+ } ,
98+ ] ,
99+ 'unused-imports/no-unused-imports' : 'error' ,
100+ 'unused-imports/no-unused-vars' : [
101+ 'warn' ,
102+ {
103+ vars : 'all' ,
104+ varsIgnorePattern : '^_' ,
105+ args : 'after-used' ,
106+ argsIgnorePattern : '^_' ,
107+ } ,
108+ ] ,
109+ } : {
110+ 'import/order' : 'error' ,
111+ } ) ,
72112 'prefer-destructuring' : [ 'warn' , { object : true , array : false } ] ,
73113 'prefer-promise-reject-errors' : 'warn' ,
74114 'prefer-spread' : 'warn' ,
0 commit comments