You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current base import-x/order configuration in @metamask/eslint-config isn't correctly implementing the intended "outermost inward" pattern for imports. Instead, it's grouping 'parent', 'sibling', and 'index' imports together and sorting them alphabetically, which results in unexpected ordering where local imports can appear before parent/sibling imports.
Screencast shows the current order using yarn lint:fix vs the proposed ordering
eslint.bug720.mov
Current Behavior
With the current configuration from @metamask/eslint-config:
Imports should follow an "outermost inward" pattern (from most distant to closest paths):
importtype{Meta,StoryObj}from'@storybook/react';importReactfrom'react';import{AvatarBaseSize,AvatarBaseShape}from'../../types';// Parent imports firstimport{Icon,IconName,IconSize}from'../Icon';// Then sibling importsimport{TextColor}from'../Text';import{AvatarBase}from'./AvatarBase';// Then local importsimport{SAMPLE_AVATARBASE_URIS}from'./AvatarBase.dev';importREADMEfrom'./README.mdx';
Proposed Solution
Update the import-x/order configuration to explicitly separate parent, sibling, and local imports into distinct groups:
'import-x/order': ['error',{'newlines-between': 'always',groups: [// External libraries first['builtin','external'],// Then parent imports (../../)['parent'],// Then sibling imports (../)['sibling'],// Then local imports (./) including index['index','internal'],],alphabetize: {order: 'asc',caseInsensitive: true,},},],
Impact
This change would improve code readability by organizing imports in a more logical hierarchical structure, creating a consistent pattern that better reflects the code's dependency structure from external to internal. The current configuration can lead to confusing import ordering where local imports appear before parent imports, which doesn't match the expected mental model of dependency organization.
Description
The current base import-x/order configuration in
@metamask/eslint-configisn't correctly implementing the intended "outermost inward" pattern for imports. Instead, it's grouping 'parent', 'sibling', and 'index' imports together and sorting them alphabetically, which results in unexpected ordering where local imports can appear before parent/sibling imports.Screencast shows the current order using
yarn lint:fixvs the proposed orderingeslint.bug720.mov
Current Behavior
With the current configuration from @metamask/eslint-config:
This produces imports like:
Expected Behavior
Imports should follow an "outermost inward" pattern (from most distant to closest paths):
Proposed Solution
Update the import-x/order configuration to explicitly separate parent, sibling, and local imports into distinct groups:
Impact
This change would improve code readability by organizing imports in a more logical hierarchical structure, creating a consistent pattern that better reflects the code's dependency structure from external to internal. The current configuration can lead to confusing import ordering where local imports appear before parent imports, which doesn't match the expected mental model of dependency organization.