Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

V13 rule promotion #4752

Merged
merged 2 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 25 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,17 @@ if no error diagnostics are emitted.

- [`noDuplicateParameters`](https://docs.rome.tools/lint/rules/noduplicateparameters/): enhanced rule to manage constructor parameters.

#### BREAKING CHANGES
#### Removed rules

- Remove `lint/complexity/noExtraSemicolon` ([#4553](https://github.com/rome/tools/issues/4553))
- Remove `complexity/noExtraSemicolon` ([#4553](https://github.com/rome/tools/issues/4553))

The _Rome_ formatter takes care of removing extra semicolons.
Thus, there is no need for this rule.

- Remove `useCamelCase`

Use [`useNamingConvention`](https://docs.rome.tools/lint/rules/useCamelCase/) instead.

#### New rules

- Add [`noFallthroughSwitchClause`](https://docs.rome.tools/lint/rules/noFallthroughSwitchClause/)
Expand Down Expand Up @@ -176,6 +180,25 @@ if no error diagnostics are emitted.

This rule proposes using `Array.isArray()` instead of `instanceof Array`.

#### Promoted rules

New rules are promoted, please check [#4750](https://github.com/rome/tools/discussions/4750) for more details:

- [`a11y/useHeadingContent`](https://docs.rome.tools/lint/rules/useHeadingContent/)
- [`complexity/noForEach`](https://docs.rome.tools/lint/rules/noForEach/)
- [`complexity/useLiteralKeys`](https://docs.rome.tools/lint/rules/useLiteralKeys/)
- [`complexity/useSimpleNumberKeys`](https://docs.rome.tools/lint/rules/useSimpleNumberKeys/)
- [`correctness/useIsNan`](https://docs.rome.tools/lint/rules/useIsNan/)
- [`suspicious/noConsoleLog`](https://docs.rome.tools/lint/rules/noConsoleLog/)
- [`suspicious/noDuplicateJsxProps`](https://docs.rome.tools/lint/rules/noDuplicateJsxProps/)

The following rules are now recommended:

- [`noUselessFragments`](https://docs.rome.tools/lint/rules/noUselessFragments/)
- [`noRedundantUseStrict`](https://docs.rome.tools/lint/rules/noRedundantUseStrict/)
- [`useExponentiationOperator`](https://docs.rome.tools/lint/rules/useExponentiationOperator/)


#### Other changes

- Add new TypeScript globals (`AsyncDisposable`, `Awaited`, `DecoratorContext`, and others) [4643](https://github.com/rome/tools/issues/4643).
Expand Down
11 changes: 1 addition & 10 deletions crates/rome_cli/tests/commands/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2168,16 +2168,7 @@ fn should_not_enable_nursery_rules() {
fs.insert(configuration_path.into(), configuration.as_bytes());

let file_path = Path::new("fix.ts");
fs.insert(
file_path.into(),
r#"const bannedType: Boolean = true;

if (true) {
const obj = {};
obj["useLiteralKey"];
}
"#,
);
fs.insert(file_path.into(), r#"const bannedType: Boolean = true;"#);

let result = run_cli(
DynRef::Borrowed(&mut fs),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,38 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━

# Emitted Messages

```block
fix.ts:5:6 lint/complexity/useLiteralKeys FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× The computed expression can be simplified without the use of a string literal.

3 │ if (true) {
4 │ const obj = {};
> 5 │ obj["useLiteralKey"];
│ ^^^^^^^^^^^^^^^
6 │ }
7 │

i Suggested fix: Use a literal key instead.

3 3 │ if (true) {
4 4 │ const obj = {};
5 │ - → obj["useLiteralKey"];
5 │ + → obj.useLiteralKey;
6 6 │ }
7 7 │


```

```block
fix.ts lint ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

× Fixes applied to the file, but there are still diagnostics to address.


```

```block
fix.ts format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ expression: content

```ts
const bannedType: Boolean = true;

if (true) {
const obj = {};
obj["useLiteralKey"];
}

```

# Emitted Messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ rome.json:6:13 deserialize ━━━━━━━━━━━━━━━━━
- noUnusedVariables
- noVoidElementsWithChildren
- noVoidTypeReturn
- useIsNan
- useValidForDirection
- useYield

Expand Down
15 changes: 7 additions & 8 deletions crates/rome_diagnostics_categories/src/categories.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ define_categories! {
"lint/a11y/useAnchorContent": "https://docs.rome.tools/lint/rules/useAnchorContent",
"lint/a11y/useAriaPropsForRole": "https://docs.rome.tools/lint/rules/useAriaPropsForRole",
"lint/a11y/useButtonType": "https://docs.rome.tools/lint/rules/useButtonType",
"lint/a11y/useHeadingContent": "https://docs.rome.tools/lint/rules/useHeadingContent",
"lint/a11y/useHtmlLang": "https://docs.rome.tools/lint/rules/useHtmlLang",
"lint/a11y/useIframeTitle": "https://docs.rome.tools/lint/rules/useIframeTitle",
"lint/a11y/useKeyWithClickEvents": "https://docs.rome.tools/lint/rules/useKeyWithClickEvents",
Expand All @@ -34,6 +35,7 @@ define_categories! {

// complexity
"lint/complexity/noExtraBooleanCast": "https://docs.rome.tools/lint/rules/noExtraBooleanCast",
"lint/complexity/noForEach": "https://docs.rome.tools/lint/rules/noForEach",
"lint/complexity/noMultipleSpacesInRegularExpressionLiterals": "https://docs.rome.tools/lint/rules/noMultipleSpacesInRegularExpressionLiterals",
"lint/complexity/noUselessCatch": "https://docs.rome.tools/lint/rules/noUselessCatch",
"lint/complexity/noUselessConstructor": "https://docs.rome.tools/lint/rules/noUselessConstructor",
Expand All @@ -44,7 +46,9 @@ define_categories! {
"lint/complexity/noUselessTypeConstraint": "https://docs.rome.tools/lint/rules/noUselessTypeConstraint",
"lint/complexity/noWith": "https://docs.rome.tools/lint/rules/noWith",
"lint/complexity/useFlatMap": "https://docs.rome.tools/lint/rules/useFlatMap",
"lint/complexity/useLiteralKeys": "https://docs.rome.tools/lint/rules/useLiteralKeys",
"lint/complexity/useOptionalChain": "https://docs.rome.tools/lint/rules/useOptionalChain",
"lint/complexity/useSimpleNumberKeys": "https://docs.rome.tools/lint/rules/useSimpleNumberKeys",
"lint/complexity/useSimplifiedLogicExpression": "https://docs.rome.tools/lint/rules/useSimplifiedLogicExpression",

// correctness
Expand All @@ -55,6 +59,7 @@ define_categories! {
"lint/correctness/noGlobalObjectCalls": "https://docs.rome.tools/lint/rules/noGlobalObjectCalls",
"lint/correctness/noInnerDeclarations": "https://docs.rome.tools/lint/rules/noInnerDeclarations",
"lint/correctness/noInvalidConstructorSuper": "https://docs.rome.tools/lint/rules/noInvalidConstructorSuper",
"lint/correctness/useIsNan": "https://docs.rome.tools/lint/rules/useIsNan",
"lint/correctness/noNewSymbol": "https://docs.rome.tools/lint/rules/noNewSymbol",
"lint/correctness/noPrecisionLoss": "https://docs.rome.tools/lint/rules/noPrecisionLoss",
"lint/correctness/noRenderReturnValue": "https://docs.rome.tools/lint/rules/noRenderReturnValue",
Expand All @@ -79,14 +84,11 @@ define_categories! {
"lint/nursery/noAriaUnsupportedElements": "https://docs.rome.tools/lint/rules/noAriaUnsupportedElements",
Conaclos marked this conversation as resolved.
Show resolved Hide resolved
"lint/nursery/noBannedTypes":"https://docs.rome.tools/lint/rules/noBannedTypes",
"lint/nursery/noConfusingArrow": "https://docs.rome.tools/lint/rules/noConfusingArrow",
"lint/nursery/noConsoleLog": "https://docs.rome.tools/lint/rules/noConsoleLog",
"lint/nursery/noConstantCondition": "https://docs.rome.tools/lint/rules/noConstantCondition",
"lint/nursery/noControlCharactersInRegex": "https://docs.rome.tools/lint/rules/noControlCharactersInRegex",
"lint/nursery/noDuplicateJsonKeys": "https://docs.rome.tools/lint/rules/noDuplicateJsonKeys",
"lint/nursery/noDuplicateJsxProps": "https://docs.rome.tools/lint/rules/noDuplicateJsxProps",
"lint/nursery/noExcessiveComplexity": "https://docs.rome.tools/lint/rules/noExcessiveComplexity",
"lint/nursery/noFallthroughSwitchClause": "https://docs.rome.tools/lint/rules/noFallthroughSwitchClause",
"lint/nursery/noForEach": "https://docs.rome.tools/lint/rules/noForEach",
"lint/nursery/noGlobalIsFinite": "https://docs.rome.tools/lint/rules/noGlobalIsFinite",
"lint/nursery/noGlobalIsNan": "https://docs.rome.tools/lint/rules/noGlobalIsNan",
"lint/nursery/noNoninteractiveTabindex": "https://docs.rome.tools/lint/rules/noNoninteractiveTabindex",
Expand All @@ -99,18 +101,13 @@ define_categories! {
"lint/nursery/noVoid": "https://docs.rome.tools/lint/rules/noVoid",
"lint/nursery/useAriaPropTypes": "https://docs.rome.tools/lint/rules/useAriaPropTypes",
"lint/nursery/useArrowFunction": "https://docs.rome.tools/lint/rules/useArrowFunction",
"lint/nursery/useCamelCase": "https://docs.rome.tools/lint/rules/useCamelCase",
"lint/nursery/useExhaustiveDependencies": "https://docs.rome.tools/lint/rules/useExhaustiveDependencies",
"lint/nursery/useGroupedTypeImport": "https://docs.rome.tools/lint/rules/useGroupedTypeImport",
"lint/nursery/useHeadingContent": "https://docs.rome.tools/lint/rules/useHeadingContent",
"lint/nursery/useHookAtTopLevel": "https://docs.rome.tools/lint/rules/useHookAtTopLevel",
"lint/nursery/useImportRestrictions": "https://docs.rome.tools/lint/rules/useImportRestrictions",
"lint/nursery/useIsArray": "https://docs.rome.tools/lint/rules/useIsArray",
"lint/nursery/useIsNan": "https://docs.rome.tools/lint/rules/useIsNan",
"lint/nursery/useLiteralEnumMembers": "https://docs.rome.tools/lint/rules/useLiteralEnumMembers",
"lint/nursery/useLiteralKeys": "https://docs.rome.tools/lint/rules/useLiteralKeys",
"lint/nursery/useNamingConvention": "https://docs.rome.tools/lint/rules/useNamingConvention",
"lint/nursery/useSimpleNumberKeys": "https://docs.rome.tools/lint/rules/useSimpleNumberKeys",
// nursery end

// performance
Expand Down Expand Up @@ -157,11 +154,13 @@ define_categories! {
"lint/suspicious/noCommentText": "https://docs.rome.tools/lint/rules/noCommentText",
"lint/suspicious/noCompareNegZero": "https://docs.rome.tools/lint/rules/noCompareNegZero",
"lint/suspicious/noConfusingLabels": "https://docs.rome.tools/lint/rules/noConfusingLabels",
"lint/suspicious/noConsoleLog": "https://docs.rome.tools/lint/rules/noConsoleLog",
"lint/suspicious/noConstEnum": "https://docs.rome.tools/lint/rules/noConstEnum",
"lint/suspicious/noDebugger": "https://docs.rome.tools/lint/rules/noDebugger",
"lint/suspicious/noDoubleEquals": "https://docs.rome.tools/lint/rules/noDoubleEquals",
"lint/suspicious/noDuplicateCase": "https://docs.rome.tools/lint/rules/noDuplicateCase",
"lint/suspicious/noDuplicateClassMembers": "https://docs.rome.tools/lint/rules/noDuplicateClassMembers",
"lint/suspicious/noDuplicateJsxProps": "https://docs.rome.tools/lint/rules/noDuplicateJsxProps",
"lint/suspicious/noDuplicateObjectKeys":"https://docs.rome.tools/lint/rules/noDuplicateObjectKeys",
"lint/suspicious/noDuplicateParameters": "https://docs.rome.tools/lint/rules/noDuplicateParameters",
"lint/suspicious/noEmptyInterface": "https://docs.rome.tools/lint/rules/noEmptyInterface",
Expand Down
2 changes: 2 additions & 0 deletions crates/rome_js_analyze/src/analyzers/a11y.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions crates/rome_js_analyze/src/analyzers/complexity.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions crates/rome_js_analyze/src/analyzers/nursery.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ declare_rule! {
pub(crate) UseExponentiationOperator {
version: "11.0.0",
name: "useExponentiationOperator",
recommended: false,
recommended: true,
}
}

Expand Down
2 changes: 2 additions & 0 deletions crates/rome_js_analyze/src/analyzers/suspicious.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ declare_rule! {
pub(crate) NoRedundantUseStrict {
version: "11.0.0",
name: "noRedundantUseStrict",
recommended: false,
recommended: true,
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ declare_rule! {
pub(crate) NoUselessFragments {
version: "0.10.0",
name: "noUselessFragments",
recommended: false,
recommended: true,
}
}

Expand Down
2 changes: 2 additions & 0 deletions crates/rome_js_analyze/src/semantic_analyzers/correctness.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions crates/rome_js_analyze/src/semantic_analyzers/nursery.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.