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

feat(linter): implement @typescript-eslint/prefer-namespace-keyword #3881

Conversation

Copy link

graphite-app bot commented Jun 24, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@github-actions github-actions bot added the A-linter Area - Linter label Jun 24, 2024
Copy link

codspeed-hq bot commented Jun 24, 2024

CodSpeed Performance Report

Merging #3881 will not alter performance

Comparing kaykdm:typescript-eslint/prefer-namespace-keyword (09a844a) with main (2045c92)

Summary

✅ 28 untouched benchmarks

@DonIsaac DonIsaac added the C-enhancement Category - New feature or request label Jun 24, 2024
fn prefer_namespace_keyword_diagnostic(span0: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("typescript-eslint(prefer-namespace-keyword): Use 'namespace' instead of 'module' to declare custom TypeScript modules.")
.with_help("'Require using `namespace` keyword over `module` keyword to declare custom TypeScript modules")
.with_labels([span0.into()])
Copy link
Contributor

Choose a reason for hiding this comment

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

prefer with_label when only labelling a single span


ctx.diagnostic_with_fix(prefer_namespace_keyword_diagnostic(decl.span), |fixer| {
// replace `module` with `namespace`
fixer.replace(Span::new(id.span.start - 7, id.span.start - 1), "namespace")
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like it will break if there is more than once space between module and the identifier. Is there no span for the module keyword?

@Boshen
Copy link
Member

Boshen commented Jun 26, 2024

Extending "plugin:@typescript-eslint/stylistic" in an ESLint configuration enables this rule.

This appears to be a stylistic rule, which we don't accept. Let me make a note of this so we don't accept more stylistic rules.

@Boshen Boshen closed this Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants