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

chore(deps): bump ESLint deps, switch from ts-node -> swc #6339

Merged
merged 12 commits into from
Aug 29, 2023
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
"chai": "^4.3.7",
"cross-env": "^7.0.3",
"dedent": "^0.7.0",
"eslint": "^8.36.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint": "^8.48.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"gh-pages": "^5.0.0",
"http-server": "^14.1.1",
"lerna": "^6.5.1",
Expand Down
16 changes: 8 additions & 8 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"dependencies": {
"@blueprintjs/eslint-plugin": "^3.0.1",
"@blueprintjs/tslint-config": "^4.0.0",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/eslint-plugin-tslint": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"eslint": "^8.41.0",
"eslint-plugin-deprecation": "^1.4.1",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"@typescript-eslint/eslint-plugin-tslint": "^6.5.0",
"@typescript-eslint/parser": "^6.5.0",
"eslint": "^8.48.0",
"eslint-plugin-deprecation": "^1.5.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "~2.26.0",
"eslint-plugin-jsdoc": "^46.2.4",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-import": "~2.28.1",
"eslint-plugin-jsdoc": "^46.5.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0"
},
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"test": "mocha"
},
"dependencies": {
"@typescript-eslint/utils": "^5.55.0",
"eslint": "^8.36.0"
"@typescript-eslint/utils": "^6.5.0",
"eslint": "^8.48.0"
},
"devDependencies": {
"@blueprintjs/node-build-scripts": "^8.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/classes-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const classesConstantsRule = createRule<[], MessageIds>({
meta: {
docs: {
description: "Enforce usage of Classes constants over namespaced string literals.",
recommended: "error",
recommended: "recommended",
requiresTypeChecking: false,
},
fixable: "code",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/html-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const htmlComponentsRule = createRule<[], MessageIds>({
meta: {
docs: {
description: "Enforce usage of Blueprint components over JSX intrinsic elements.",
recommended: "error",
recommended: "recommended",
requiresTypeChecking: false,
},
fixable: "code",
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin/src/rules/icon-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const iconComponentsRule = createRule<Options, MessageIds>({
meta: {
docs: {
description: "Enforce usage of JSX Icon components over IconName string literals (or vice-versa)",
recommended: "error",
recommended: "recommended",
requiresTypeChecking: false,
},
fixable: "code",
Expand All @@ -40,6 +40,7 @@ export const iconComponentsRule = createRule<Options, MessageIds>({
},
schema: [
{
type: "string",
enum: [OPTION_COMPONENT, OPTION_LITERAL],
},
],
Expand Down
4 changes: 4 additions & 0 deletions packages/eslint-plugin/src/rules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
* limitations under the License.
*/

// HACKHACK: workaround to satisfy TS compiler, we need a direct type reference to be able to infer TSESLint.RuleModule
// @ts-expect-error
import type { TSESLint } from "@typescript-eslint/utils";

import { classesConstantsRule } from "./classes-constants";
import { htmlComponentsRule } from "./html-components";
import { iconComponentsRule } from "./icon-components";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function createNoDeprecatedComponentsRule(
docs: {
description: `Reports on usage of deprecated Blueprint components${descriptionFromClause} and recommends migrating to their corresponding non-deprecated API alternatives.`,
requiresTypeChecking: false,
recommended: "error",
recommended: "recommended",
},
messages: {
migration:
Expand All @@ -48,6 +48,7 @@ export function createNoDeprecatedComponentsRule(
},
schema: [
{
type: "string",
enum: ["migration", "migrationWithPropUsage"],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* (c) Copyright 2022 Palantir Technologies Inc. All rights reserved.
*/

import { TSESLint } from "@typescript-eslint/utils";
import { createNoDeprecatedComponentsRule } from "./createNoDeprecatedComponentsRule";
import { coreComponentsMigrationMapping } from "./no-deprecated-core-components";
import { datetimeComponentsMigrationMapping } from "./no-deprecated-datetime-components";
Expand All @@ -14,7 +15,7 @@ import { tableComponentsMigrationMapping } from "./no-deprecated-table-component
* Note that this does not rely on the \@deprecated JSDoc annotation, and is thus distinct/very different from the
* deprecated/deprecated ESLint rule
*/
export const noDeprecatedComponentsRule = createNoDeprecatedComponentsRule(
export const noDeprecatedComponentsRule: TSESLint.RuleModule<string, unknown[]> = createNoDeprecatedComponentsRule(
"no-deprecated-components",
["@blueprintjs/core", "@blueprintjs/datetime", "@blueprintjs/select", "@blueprintjs/table"],
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* (c) Copyright 2022 Palantir Technologies Inc. All rights reserved.
*/

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

export const coreComponentsMigrationMapping = {
Expand All @@ -14,7 +15,7 @@ export const coreComponentsMigrationMapping = {
* of deprecated components from @blueprintjs/core. This is useful for incremental migration to
* newer Blueprint APIs.
*/
export const noDeprecatedCoreComponentsRule = createNoDeprecatedComponentsRule(
export const noDeprecatedCoreComponentsRule: TSESLint.RuleModule<string, unknown[]> = createNoDeprecatedComponentsRule(
"no-deprecated-core-components",
["@blueprintjs/core"],
coreComponentsMigrationMapping,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* (c) Copyright 2022 Palantir Technologies Inc. All rights reserved.
*/

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

export const datetimeComponentsMigrationMapping = {
Expand All @@ -14,7 +15,7 @@ export const datetimeComponentsMigrationMapping = {
* of deprecated components from @blueprintjs/datetime. This is useful for incremental migration to
* newer Blueprint APIs.
*/
export const noDeprecatedDatetimeComponentsRule = createNoDeprecatedComponentsRule(
export const noDeprecatedDatetimeComponentsRule: TSESLint.RuleModule<string, unknown[]> = createNoDeprecatedComponentsRule(
"no-deprecated-datetime-components",
["@blueprintjs/datetime"],
datetimeComponentsMigrationMapping,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* (c) Copyright 2022 Palantir Technologies Inc. All rights reserved.
*/

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

export const selectComponentsMigrationMapping = {
Expand All @@ -13,7 +14,7 @@ export const selectComponentsMigrationMapping = {
* of deprecated components from @blueprintjs/select. This is useful for incremental migration to
* newer Blueprint APIs.
*/
export const noDeprecatedSelectComponentsRule = createNoDeprecatedComponentsRule(
export const noDeprecatedSelectComponentsRule: TSESLint.RuleModule<string, unknown[]> = createNoDeprecatedComponentsRule(
"no-deprecated-select-components",
["@blueprintjs/select"],
selectComponentsMigrationMapping,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* (c) Copyright 2022 Palantir Technologies Inc. All rights reserved.
*/

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

export const tableComponentsMigrationMapping = {
Expand All @@ -15,7 +16,7 @@ export const tableComponentsMigrationMapping = {
* of deprecated components from @blueprintjs/table. This is useful for incremental migration to
* newer Blueprint APIs.
*/
export const noDeprecatedTableComponentsRule = createNoDeprecatedComponentsRule(
export const noDeprecatedTableComponentsRule: TSESLint.RuleModule<string, unknown[]> = createNoDeprecatedComponentsRule(
"no-deprecated-table-components",
["@blueprintjs/table"],
tableComponentsMigrationMapping,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// tslint:disable object-literal-sort-keys

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

import { createRule } from "./utils/createRule";
import { FixList } from "./utils/fixList";
Expand Down Expand Up @@ -193,20 +193,21 @@ export const noDeprecatedTypeReferencesRule = createRule<[], MessageIds>({
description:
"Reports on usage of deprecated Blueprint types and recommends migrating to their corresponding replacements.",
requiresTypeChecking: false,
recommended: "error",
recommended: "recommended",
},
fixable: "code",
messages: {
migration: "Usage of {{ deprecatedTypeName }} is deprecated, migrate to {{ newTypeName }} instead",
},
schema: [
{
type: "string",
enum: ["migration"],
},
],
},
defaultOptions: [],
create: context => {
create: (context: TSESLint.RuleContext<MessageIds, []>) => {
const [deprecatedToNewType, newTypeToPackageName] = getTypeMappings();
const deprecatedImports: Array<
{ namespace: string; type: "namespace" } | { type: "symbol"; symbolName: string; localSymbolName: string }
Expand Down
7 changes: 5 additions & 2 deletions packages/eslint-plugin/src/rules/utils/createRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
* limitations under the License.
*/

import { ESLintUtils } from "@typescript-eslint/utils";
import { ESLintUtils, TSESLint } from "@typescript-eslint/utils";
import { RuleWithMetaAndName } from "@typescript-eslint/utils/eslint-utils";

export type RuleCreator = <TOptions extends readonly unknown[], TMessageIds extends string>(metadata: Readonly<RuleWithMetaAndName<TOptions, TMessageIds>>) => TSESLint.RuleModule<TMessageIds, TOptions>;

/** Create a rule and automatically fill its url based on the rule name. */
export const createRule = ESLintUtils.RuleCreator(
export const createRule: RuleCreator = ESLintUtils.RuleCreator(
name => `https://github.com/palantir/blueprint/tree/develop/packages/eslint-plugin/src/rules/${name}.ts`,
);
6 changes: 3 additions & 3 deletions packages/eslint-plugin/src/rules/utils/getProgram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import { AST_NODE_TYPES, TSESTree } from "@typescript-eslint/utils";
* Return the top level node that is the greatest parent of the current node, if it is a Program.
* Non-program top level parents return undefined.
*/
export function getProgram(node: TSESTree.BaseNode & { type: AST_NODE_TYPES }): TSESTree.Program | undefined {
let curr = node;
export function getProgram(node: TSESTree.BaseNode & TSESTree.NodeOrTokenData): TSESTree.Program | undefined {
let curr: TSESTree.BaseNode | TSESTree.Program = node;
while (curr.parent != null) {
curr = curr.parent;
}
if (curr.type === AST_NODE_TYPES.Program) {
return curr as TSESTree.Program;
return curr as unknown as TSESTree.Program;
}
return undefined;
}
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"lib": ["es6", "dom"],
"module": "commonjs",
"moduleResolution": "node16",
Copy link
Contributor

Choose a reason for hiding this comment

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

this change was required to work with typescript-eslint v6, see typescript-eslint/typescript-eslint#7284

"outDir": "../lib",
"target": "ES2015"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/node-build-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"cross-spawn": "^7.0.3",
"css-select": "^5.1.0",
"dom-serializer": "^2.0.0",
"eslint": "^8.43.0",
"eslint": "^8.48.0",
"eslint-formatter-codeframe": "^7.32.1",
"fs-extra": "^11.1.1",
"glob": "^10.3.3",
Expand Down
Loading