@dilatorily/oxlint-plugin-alias
v1.0.0
Published
An Oxlint plugin that autofixes import aliases
Maintainers
Readme
@dilatorily/oxlint-plugin-alias
An Oxlint plugin that autofixes and enforces the use of import aliases instead of relative imports.
Description
This plugin provides the prefer-alias rule, which helps maintain a clean and consistent project structure by replacing deep relative imports (e.g., ../../utils/helper) with pre-configured aliases (e.g., utils/helper). It supports automatic fixes to streamline the transition to an alias-based import system.
Installation
Install the plugin via npm:
npm install --save-dev @dilatorily/oxlint-plugin-aliasUsage
Add the plugin to your Oxlint configuration:
{
"jsPlugins": [{ "name": "@dilatorily/oxlint-plugin-alias", "specifier": "alias" }],
"rules": {
"alias/prefer-alias": {
"alias": {
"@": "./src",
"@utils": "./src/utils"
}
}
}
}Examples
Valid
import { Button } from '@/components/Button';
import { someFunction } from 'some-package';Invalid (Autofixable)
// Original
import { helper } from '../utils/helper';
// Fixed
import { helper } from '@utils';Contribute
Contributions are welcome! Please see the GitHub issues or submit a pull request.
