Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Explain eslint rule requiring file extensions in imports #15528

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/framework/contributing/code-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -1160,3 +1160,14 @@ import AlignmentEditing from './alignmentediting';
```

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

### Mandatory file extensions in imports: `ckeditor5-rules/require-file-extensions-in-imports`

As required by the [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) standard, all imports must include a file extension. If the import doesn't include it, this rule will try to automatically detect the correct file extension, but in two cases this is not possible:

* the imported file has an extension other than `.ts`, `.js` or `.json`,
* the imported file doesn't exist in the file system.

The second case is common in documentation, because its pieces are in different directories and repositories. These pieces are merged during the build step, but before that the imports are technically invalid.

In such cases, the file extension must be added manually. Imports with file extensions are not validated.