eslint-plugin-no-relative-import-paths icon indicating copy to clipboard operation
eslint-plugin-no-relative-import-paths copied to clipboard

Add option to remove slash after '@' prefix in import paths

Open Giozar opened this issue 6 months ago • 4 comments

Add option to remove slash after '@' prefix in import paths

Description:

This pull request introduces a new configuration option for the no-relative-import-paths ESLint rule that allows users to remove the slash (/) that follows the @ prefix in import paths.

Key Features:

  • New Option: noSlashAfterAt (boolean)
    • When set to true, import paths prefixed with @ will omit the slash after the prefix.
    • Example:
      • Input: import ActionCard from '../../components/ActionCard';
      • Output: import ActionCard from '@components/ActionCard';

Backward Compatibility:

  • The existing functionality remains unchanged if the new option is not used.
  • Default behavior ensures that existing users of the plugin are not affected by this change.

Usage:

To activate this feature, add the following to your ESLint configuration:

{
  "rules": {
    "no-relative-import-paths/no-relative-import-paths": [
      "warn",
      {
        "allowSameFolder": true,
        "rootDir": "src",
        "prefix": "@",
        "noSlashAfterAt": true
      }
    ]
  }
}

Giozar avatar Aug 15 '24 07:08 Giozar