Registry / testing / import-sort-parser-babylon

import-sort-parser-babylon

JSON →
library6.0.0jsnpmunverified

import-sort-parser-babylon is a specialized parser plugin designed for the `import-sort` ecosystem, enabling the sorting of ECMAScript (ES2015+) imports in JavaScript and TypeScript files. Currently at version 6.0.0, this package integrates with the primary `import-sort` library, which is generally used in conjunction with `import-sort-config` and a chosen sorting style (e.g., `import-sort-style-eslint`). It leverages the capabilities of the Babel parser (formerly known as Babylon) to analyze and manipulate import declarations, offering robust support for modern JavaScript syntax, JSX, and TypeScript features. The `import-sort` project, of which this parser is a component, appears to maintain an active development cadence, providing tools for CLI usage, editor integrations, and programmatic sorting. Its key differentiator lies in its use of the battle-tested Babel parsing engine, ensuring broad compatibility with various language features and proposals.

npm install import-sort-parser-babylon
INSTALL
IMPORT
SIG · IMPORT-SORT-PARSER
I
import-sort-parser-babylon
testingjavascriptv6.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import babylonParser from 'import-sort-parser-babylon';
const babylonParser = require('import-sort-parser-babylon');
The primary export is typically a default parser configuration or function, consumed by the 'import-sort' core. While modern configurations prefer ESM, CommonJS `require` might still function in older Node.js environments if the package provides dual exports.
ImportSortParser
import type { ImportSortParser } from 'import-sort-parser-babylon';
This package ships TypeScript types. The type definition for the parser interface is useful for custom integrations or understanding the expected structure.

This configuration snippet for `.importsortrc` or `package.json` demonstrates how to instruct `import-sort` to use the `babylon` parser for various file types and configure Babel parser options for modern syntax support.

{ "importSort": { "language": "javascript", ".js, .jsx, .ts, .tsx": { "parser": "babylon", "style": "eslint", "options": { "parserOptions": { "ecmaVersion": "latest", "sourceType": "module", "plugins": [ "jsx", "typescript", "classProperties", "decorators-legacy", "dynamicImport" ] } } } } }
Debug
Known issues
breakingThe underlying parser 'babylon' was renamed to '@babel/parser'. While 'import-sort-parser-babylon' might abstract this, direct usage or advanced configuration might require referencing '@babel/parser' features or plugins.
fix
Ensure your Babel configuration (if separate) is updated to use `@babel/parser`. If passing `parserOptions` directly to `import-sort`, ensure plugin names align with `@babel/parser`'s expected values. Review `prettier-plugin-sort-imports` migration guides for common parser option changes.
affects: >=5.0.0
gotchaIncorrect or missing Babel parser plugins in your `import-sort` configuration can lead to parsing errors for modern JavaScript or TypeScript syntax (e.g., decorators, class properties).
fix
Always explicitly define necessary Babel plugins within the `parserOptions.plugins` array in your `.importsortrc` or `package.json` configuration, matching the features used in your codebase. Refer to `@babel/parser` documentation for available plugins.
affects: >=1.0.0
gotchaConflicting import sorting rules from other tools like ESLint (`sort-imports`) or Prettier plugins can lead to formatting churn or unexpected behavior.
fix
Disable or remove competing import sorting rules in ESLint or Prettier when `import-sort` is active, allowing `import-sort` to be the single source of truth for import ordering.
affects: >=1.0.0
gotchaWhen using `import-sort` within a broader toolchain (e.g., with Prettier v3.x or pnpm), ensure compatibility and correct plugin resolution, as some users have reported issues with specific package managers or tool versions.
fix
Verify `import-sort` and its parsers are correctly installed and resolvable by your toolchain. Check for any specific setup instructions or known issues related to your package manager (like pnpm) or other formatting tools in the `import-sort` or `prettier-plugin-sort-imports` repositories.
affects: >=6.0.0
Errors
Common errors & fixes
SyntaxError: Unexpected token (X:Y)
The Babel parser used by `import-sort-parser-babylon` did not recognize a specific language feature (e.g., new syntax, TypeScript, JSX) because the corresponding plugin was not enabled in the configuration.
fix
Add the required Babel parser plugin (e.g., `jsx`, `typescript`, `decorators-legacy`) to the `parserOptions.plugins` array in your `importSort` configuration within `package.json` or `.importsortrc`.
parser.parseImports is not a function
The `import-sort` core or integration could not find or correctly load the parser function from `import-sort-parser-babylon`, possibly due to incorrect module resolution or a corrupted installation.
fix
Ensure `import-sort-parser-babylon` is correctly installed and listed in your project dependencies. Verify your `importSort` configuration specifies `'babylon'` as the parser name, and restart any IDE extensions or CLI processes to reload the configuration.
Configuration error: Unknown parser 'babylon'
The `import-sort` tool itself (or its CLI/IDE integration) failed to locate the `import-sort-parser-babylon` package, often due to an incorrect package name in the configuration or an incomplete installation.
fix
Double-check that `import-sort-parser-babylon` is installed in your project and that your `importSort` configuration correctly specifies `parser: 'babylon'` (or similar, depending on the exact `import-sort` configuration structure).
Upgrade
Version history
6.0.0latest on npm
Audit
Dependencies
import-sort-parserrequiredThis package implements the core parser interface required by the import-sort ecosystem.
@babel/parserrequiredProvides the underlying JavaScript/TypeScript parsing capabilities, formerly known as 'babylon'. This package is built on top of it.
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources