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] feat(no-deprecated-select-components): lint V2 APIs #6475

Merged
merged 1 commit into from
Oct 19, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/eslint-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,11 @@ Ban usage of deprecated components in the current major version of all Blueprint
- DateRangeInput2
- DateRangePicker
- MenuItem2
- MultiSelect2
- Popover2
- ResizeSensor2
- Select2
- Suggest2
- Tooltip2

**Rationale**: There are two reasons why a particular component may be deprecated:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

import type { TSESLint } from "@typescript-eslint/utils";

import { createNoDeprecatedComponentsRule } from "./createNoDeprecatedComponentsRule";
import { createNoDeprecatedComponentsRule, type DeprecatedComponentsConfig } from "./createNoDeprecatedComponentsRule";

export const selectComponentsMigrationMapping = {
// nothing, for now
export const selectComponentsMigrationMapping: DeprecatedComponentsConfig = {
// listed in packages/select/src/components/deprecatedAliases.ts
MultiSelect2: "MultiSelect",
Select2: "Select",
Suggest2: "Suggest",
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,32 @@ const ruleTester = new RuleTester({
ruleTester.run("no-deprecated-select-components", noDeprecatedSelectComponentsRule, {
// N.B. most other deprecated components are tested by no-deprecated-components.test.ts, this suite just tests
// for more specific violations which involve certain syntax
invalid: [],
invalid: [
{
code: dedent`
import { Select2 } from "@blueprintjs/select";

return <Select2<string> />;
`,
errors: [
{
messageId: "migration",
data: {
deprecatedComponentName: "Select2",
newComponentName: "Select",
},
},
],
},
],
valid: [
{
code: dedent`
import { Select } from "@blueprintjs/select";

return <Select<string> />;
`,
},
{
code: dedent`
import { MultiSelect } from "@blueprintjs/select";
Expand Down