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

[eslint-plugin] Add new import-related rules to the ESLint plugin #4889

Merged
merged 7 commits into from
Aug 14, 2024

Conversation

D4N14L
Copy link
Member

@D4N14L D4N14L commented Aug 14, 2024

Summary

  • Adds 4 new rules to @rushstack/eslint-plugin
  • Update @rushstack/heft-lint-plugin to disable --fix mode when running in --production mode

Details

Adds the following new rules to the @rushstack/eslint-plugin package and consume them in Rushstack:

  • @rushstack/no-backslash-imports
    • Rationale: Backslashes are platform-specific and will cause breaks on non-Windows platforms.
    • Default mode in Rushstack: error
  • @rushstack/no-external-local-imports
    • Rationale: Avoid consuming dependencies which would not otherwise be present when the package is published.
    • Default mode in Rushstack: error
  • @rushstack/no-transitive-dependency-imports
    • Rationale: Consumption of transitive dependencies can be problematic when the dependency is updated or removed from the parent package. Enforcing consumption of only direct dependencies ensures that the package is exactly what we expect it to be.
    • Default mode in Rushstack: warn
  • @rushstack/normalized-imports
    • Rationale: Using the simplest possible import syntax is preferred and makes it easier to understand where the dependency is coming from.
    • Default mode in Rushstack: warn

This PR also sets fix mode to false regardless of any provided settings when running in --production mode. This is logged to the user as standard text to avoid producing errors/warnings when the value is set in the Heft configuration for the plugin.

How it was tested

  • Added unit tests
  • Tested in Rushstack
  • Tested in large internal monorepo

Impacted documentation

May require updates to external lint config documentation

@D4N14L D4N14L changed the title [eslint-plugin] User/danade/lint tweaks [eslint-plugin] Add new rules to the ESLint plugin and consume them in @rushstack/eslint-config Aug 14, 2024
@D4N14L D4N14L changed the title [eslint-plugin] Add new rules to the ESLint plugin and consume them in @rushstack/eslint-config [eslint-plugin] Add new import-related rules to the ESLint plugin Aug 14, 2024
@D4N14L D4N14L merged commit 0381a02 into microsoft:main Aug 14, 2024
4 checks passed
@iclanton iclanton deleted the user/danade/LintTweaks branch August 26, 2024 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants