import-sort-style-segment
raw JSON → 1.1.0 verified Sat Apr 25 auth: no javascript maintenance
A style configuration for the import-sort Prettier plugin, enforcing Segment's convention: third-party imports first, then absolute, followed by relative, with React always on top. Version 1.1.0 is stable but no longer actively maintained; releases are infrequent. This package is part of the legacy import-sort ecosystem (deprecated in favor of @ianvs/prettier-plugin-sort-imports). It provides a single predefined style function, not a plugin itself, so developers must also install import-sort-style-eslint or similar.
Common errors
error Cannot find module 'import-sort-style-segment' ↓
cause The package is not installed, or the import path is incorrect.
fix
Run 'npm install import-sort-style-segment --save-dev' and ensure no typos in import statements.
error Invalid style: must be a string or a function ↓
cause Using a full package name (e.g., 'import-sort-style-segment') instead of the short style name 'segment' in configuration.
fix
Change the style value to 'segment' in .importsortrc.
Warnings
deprecated This package is part of the deprecated import-sort ecosystem. The import-sort project has been superseded by @ianvs/prettier-plugin-sort-imports. ↓
fix Migrate to @ianvs/prettier-plugin-sort-imports with the '@ianvs/segment' import order.
gotcha The style name in configuration is 'segment' not the full package name 'import-sort-style-segment'. ↓
fix Set style to "segment" in .importsortrc.
gotcha This package only provides a style function; you must also install import-sort and optionally import-sort-style-eslint for ESLint integration. ↓
fix Install import-sort as a devDependency and configure your toolchain accordingly.
Install
npm install import-sort-style-segment yarn add import-sort-style-segment pnpm add import-sort-style-segment Imports
- segmentStyle wrong
const segmentStyle = require('import-sort-style-segment')correctimport segmentStyle from 'import-sort-style-segment' - import-sort-style-segment (named import attempt) wrong
import { segmentStyle } from 'import-sort-style-segment'correctimport segmentStyle from 'import-sort-style-segment' - style (in .importsortrc) wrong
{ "style": "import-sort-style-segment", "parser": "typescript" }correct{ "style": "segment", "parser": "typescript", "options": {} }
Quickstart
// .importsortrc
{
"style": "segment",
"parser": "typescript",
"options": {}
}
// Then run: import-sort --write 'src/**/*.{ts,tsx}'