Skip to content

Commit

Permalink
Merge pull request #14358 from ckeditor/ck/14329
Browse files Browse the repository at this point in the history
Docs: Added documentation for `no-scoped-imports-within-package` ESLint rule. See #14329.
  • Loading branch information
psmyrek committed Jun 19, 2023
2 parents dcc0d53 + c94d4a2 commit b6d7cd9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/framework/contributing/code-style.md
Expand Up @@ -1135,3 +1135,27 @@ export default class Delete extends Plugin {
}
}
```

### Imports within a package: `ckeditor5-rules/no-scoped-imports-within-package`

All imports defined in every package, that point to a file from the same package, must be relative. You cannot use the scoped imports, if the target file is located in the same package as the import declaration. The resolved scoped import points to the package inside the `node_modules`, but not to the current working directory, and the source code in these two places may differ from each other.

👎  Examples of incorrect code for this rule:

```ts
// Assume we edit a file located in the path: `packages/ckeditor5-alignment/src/alignment.ts`.

// Both imports are incorrect.
import { AlignmentEditing } from '@ckeditor/ckeditor5-alignment';
import AlignmentEditing from '@ckeditor/ckeditor5-alignment/src/alignmentediting';
```

👍  Examples of correct code for this rule:

```ts
// Assume we edit a file located in the path: `packages/ckeditor5-alignment/src/alignment.ts`.

import AlignmentEditing from './alignmentediting';
```

[History of the change.](https://github.com/ckeditor/ckeditor5/issues/14329)

0 comments on commit b6d7cd9

Please sign in to comment.