diff --git a/.changeset/early-mugs-drop.md b/.changeset/early-mugs-drop.md new file mode 100644 index 0000000..2f87eac --- /dev/null +++ b/.changeset/early-mugs-drop.md @@ -0,0 +1,5 @@ +--- +'@commencis/eslint-config': minor +--- + +improve existing eslint sorting rules and add new ones diff --git a/packages/eslint-config/src/rules/importSortRules.ts b/packages/eslint-config/src/rules/importSortRules.ts index 0bc78ba..243a062 100644 --- a/packages/eslint-config/src/rules/importSortRules.ts +++ b/packages/eslint-config/src/rules/importSortRules.ts @@ -5,20 +5,35 @@ export const importSortRules: Linter.RulesRecord = { 'error', { groups: [ - // External package imports - ['^\\w', '^@\\w'], - // @commencis package imports - ['^@commencis'], - // Config, util imports - ['(@/config|@/util)'], - // Type imports - ['@/type'], - // Absolute imports + // Side effect imports. + ['^\\u0000'], + // Main frameworks & libraries + [ + '^react', + '^next', + '^vue', + '^nuxt', + '^@angular(/.*|$)', + '^expo', + '^node', + ], + // External packages + ['^@commencis', '^@?\\w'], ['^@/'], - // Relative imports - ['^\\.\\./', '^\\./'], - // Style imports - ['^.+\\.s?css$'], + // Internal imports + [ + '^@?/?(configs(s?)|types(s?)|constants(s?)|helpers(s?)|utils(s?)|lib(s?)|providers(s?))(/.*|$)', + ], + // Project folders + ['((.*)/)?(layouts|pages|modules|features|components)/'], + // Parent imports. Put `..` last. + ['^\\.\\.(?!/?$)', '^\\.\\./?$'], + // Other relative imports. Put same-folder imports and `.` last. + ['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'], + // Styles + ['^.+\\.(s?css|(style(s)?)\\..+)$'], + // Images + ['(asset(s?)|public|static|images)(/.*|$)', '^.+\\.svg$', '^.+\\.png$'], ], }, ],