Skip to content

feat(eslint-plugin): add rule for restricting asset imports#3989

Open
tido64 wants to merge 2 commits intomainfrom
tido/eslint/restricted-imports
Open

feat(eslint-plugin): add rule for restricting asset imports#3989
tido64 wants to merge 2 commits intomainfrom
tido/eslint/restricted-imports

Conversation

@tido64
Copy link
Member

@tido64 tido64 commented Feb 23, 2026

Description

Added a rule for restricting asset imports.

Test plan

CI should pass.

image

@github-actions github-actions bot added the feature: eslint This is related to ESLint label Feb 23, 2026
@tido64 tido64 force-pushed the tido/eslint/restricted-imports branch from ca5f2d6 to a0f104d Compare February 23, 2026 15:31
@tido64 tido64 changed the title feat(eslint-plugin): add rule for restricting import statements feat(eslint-plugin): add rule for restricting asset imports Feb 23, 2026
@tido64 tido64 force-pushed the tido/eslint/restricted-imports branch 2 times, most recently from 3f618c5 to bfae9b5 Compare February 23, 2026 17:35
* @param {string} relativeTo
* @returns {string | undefined}
*/
function realpath(p, relativeTo, fs = nodefs) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be good to put in tools-filesystem as it is one of these subtle issues that isn't obvious.

Also, I believe on Windows you can call fs.realpath.native(), though this routine is still necessary on macOS.

Copy link
Member Author

@tido64 tido64 Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I've read, fs.realpath.native() has the side effect of resolving symlinks. I don't think it's what we want in this case.

I can move this tool but we'll have to come up with a different name. The real realpath is supposed to return the canonicalized absolute pathname. And I'm not sure it fits as is because it only looks at the basename part. To be entirely accurate, it would have to look at all the directories leading up to the file as well. We've shortcut it here because I assume it's not necessary. @dannyvv correct me if I'm wrong.

Edit: Moved to tools-filesystem as realname.
Edit 2: Moved back because it created a circular dependency.

@tido64 tido64 force-pushed the tido/eslint/restricted-imports branch from bfae9b5 to 31e89c8 Compare February 26, 2026 13:13
@tido64 tido64 force-pushed the tido/eslint/restricted-imports branch from 31e89c8 to 25e6147 Compare February 26, 2026 13:16
@tido64 tido64 force-pushed the tido/eslint/restricted-imports branch 2 times, most recently from d150668 to 97a84d6 Compare February 26, 2026 13:59
@tido64 tido64 force-pushed the tido/eslint/restricted-imports branch from 97a84d6 to 3ac4780 Compare February 26, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: eslint This is related to ESLint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants