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

refactor: migrate TSLint rules to ESLint equivalents #4158

Merged
merged 17 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
various lint fixes
  • Loading branch information
adidahiya committed May 27, 2020
commit 6e291e675ac33bfbe2770c5584bb978ef78ddd8f
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ generated/
lib/
dist/
/site/
*.scss
2 changes: 1 addition & 1 deletion packages/core/src/blueprint-hi-contrast.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*

Copyright 2019-present Palantir Technologies, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/blueprint.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*

Copyright 2015-present Palantir Technologies, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0.
Expand Down
1 change: 1 addition & 0 deletions packages/datetime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@blueprintjs/core": "^3.28.1",
"classnames": "^2.2",
"react-day-picker": "7.3.2",
"react-lifecycles-compat": "^3.0.4",
"tslib": "~1.10.0"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/datetime/src/blueprint-datetime.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*

Copyright 2015-present Palantir Technologies, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0.
Expand Down
5 changes: 3 additions & 2 deletions packages/datetime/src/dateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export interface IDateInputProps extends IDatePickerBaseProps, IDateFormatProps,
* Props to pass to the `Popover`.
* Note that `content`, `autoFocus`, and `enforceFocus` cannot be changed.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
popoverProps?: Partial<IPopoverProps> & object;

/**
Expand Down Expand Up @@ -265,8 +266,8 @@ export class DateInput extends AbstractPureComponent2<IDateInputProps, IDateInpu
);
}

public componentDidUpdate(prevProps: IDateInputProps, prevState: IDateInputState, snapshot?: {}) {
super.componentDidUpdate(prevProps, prevState, snapshot);
public componentDidUpdate(prevProps: IDateInputProps, prevState: IDateInputState) {
super.componentDidUpdate(prevProps, prevState);
if (prevProps.value !== this.props.value) {
this.setState({ value: this.props.value });
}
Expand Down
4 changes: 2 additions & 2 deletions packages/datetime/src/datePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ export class DatePicker extends AbstractPureComponent2<IDatePickerProps, IDatePi
);
}

public componentDidUpdate(prevProps: IDatePickerProps, prevState: IDatePickerState, snapshot?: {}) {
super.componentDidUpdate(prevProps, prevState, snapshot);
public componentDidUpdate(prevProps: IDatePickerProps, prevState: IDatePickerState) {
super.componentDidUpdate(prevProps, prevState);
const { value } = this.props;
if (value === prevProps.value) {
// no action needed
Expand Down
4 changes: 2 additions & 2 deletions packages/datetime/src/dateRangeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ export class DateRangeInput extends AbstractPureComponent2<IDateRangeInputProps,
};
}

public componentDidUpdate(prevProps: IDateRangeInputProps, prevState: IDateRangeInputState, snapshot?: {}) {
super.componentDidUpdate(prevProps, prevState, snapshot);
public componentDidUpdate(prevProps: IDateRangeInputProps, prevState: IDateRangeInputState) {
super.componentDidUpdate(prevProps, prevState);
const { isStartInputFocused, isEndInputFocused, shouldSelectAfterUpdate } = this.state;

const startInputRef = getRef(this.startInputRef);
Expand Down
4 changes: 2 additions & 2 deletions packages/datetime/src/dateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ export class DateRangePicker extends AbstractPureComponent2<IDateRangePickerProp
);
}

public componentDidUpdate(prevProps: IDateRangePickerProps, prevState: IDateRangePickerState, snapshot?: {}) {
super.componentDidUpdate(prevProps, prevState, snapshot);
public componentDidUpdate(prevProps: IDateRangePickerProps, prevState: IDateRangePickerState) {
super.componentDidUpdate(prevProps, prevState);

if (
!DateUtils.areRangesEqual(prevProps.value, this.props.value) ||
Expand Down
2 changes: 1 addition & 1 deletion packages/datetime/test/dateInputTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import * as React from "react";
import * as sinon from "sinon";

import { Classes as CoreClasses, InputGroup, Intent, Keys, Popover, Position } from "@blueprintjs/core";
import { Months } from "../src/common/months";
import { Classes, DateInput, DatePicker, IDateInputProps, TimePicker, TimePrecision } from "../src";
import { Months } from "../src/common/months";
import { DATE_FORMAT } from "./common/dateFormat";
import * as DateTestUtils from "./common/dateTestUtils";

Expand Down
2 changes: 1 addition & 1 deletion packages/datetime/test/datePickerCaptionTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import * as sinon from "sinon";

import { HTMLSelect } from "@blueprintjs/core";
import { ClassNames } from "react-day-picker";
import { DatePickerCaption, IDatePickerCaptionProps } from "../src/datePickerCaption";
import { Classes, IDatePickerLocaleUtils } from "../src";
import { DatePickerCaption, IDatePickerCaptionProps } from "../src/datePickerCaption";

describe("<DatePickerCaption>", () => {
const LOCALE_UTILS: IDatePickerLocaleUtils = {
Expand Down
2 changes: 1 addition & 1 deletion packages/datetime/test/datePickerTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import * as sinon from "sinon";
import { Button, Classes as CoreClasses, HTMLSelect, Menu, MenuItem } from "@blueprintjs/core";
import { expectPropValidationError } from "@blueprintjs/test-commons";

import { Classes, DatePicker, IDatePickerModifiers, IDatePickerProps, TimePicker, TimePrecision } from "../src";
import * as DateUtils from "../src/common/dateUtils";
import * as Errors from "../src/common/errors";
import { Months } from "../src/common/months";
import { IDatePickerState } from "../src/datePicker";
import { Classes, DatePicker, IDatePickerModifiers, IDatePickerProps, TimePicker, TimePrecision } from "../src";
import { IDatePickerShortcut, Shortcuts } from "../src/shortcuts";
import { assertDatesEqual, assertDayDisabled, assertDayHidden } from "./common/dateTestUtils";

Expand Down
2 changes: 2 additions & 0 deletions packages/datetime/test/dateRangeInputTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2320,6 +2320,7 @@ describe("<DateRangeInput>", () => {
});

it("Clicking a start date causes focus to move to end field", () => {
// eslint-disable-next-line prefer-const
let controlledRoot: WrappedComponentRoot;

const onChange = (nextValue: DateRange) => controlledRoot.setProps({ value: nextValue });
Expand All @@ -2334,6 +2335,7 @@ describe("<DateRangeInput>", () => {
});

it("Typing in a field while hovering over a date shows the typed date, not the hovered date", () => {
// eslint-disable-next-line prefer-const
let controlledRoot: WrappedComponentRoot;

const onChange = (nextValue: DateRange) => controlledRoot.setProps({ value: nextValue });
Expand Down
10 changes: 5 additions & 5 deletions packages/datetime/test/dateRangePickerTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ import * as sinon from "sinon";

import { expectPropValidationError } from "@blueprintjs/test-commons";

import * as DateUtils from "../src/common/dateUtils";
import * as Errors from "../src/common/errors";
import { Months } from "../src/common/months";
import { DatePickerNavbar } from "../src/datePickerNavbar";
import { IDateRangePickerState } from "../src/dateRangePicker";
import {
Classes as DateClasses,
DateRange,
Expand All @@ -37,6 +32,11 @@ import {
TimePicker,
TimePrecision,
} from "../src";
import * as DateUtils from "../src/common/dateUtils";
import * as Errors from "../src/common/errors";
import { Months } from "../src/common/months";
import { DatePickerNavbar } from "../src/datePickerNavbar";
import { IDateRangePickerState } from "../src/dateRangePicker";
import { IDateRangeShortcut, Shortcuts } from "../src/shortcuts";
import { assertDayDisabled } from "./common/dateTestUtils";

Expand Down
2 changes: 1 addition & 1 deletion packages/datetime/test/dateTimePickerTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { mount } from "enzyme";
import * as React from "react";
import * as sinon from "sinon";

import { DateTimePicker } from "../src/dateTimePicker";
import { Classes, DatePicker, TimePicker } from "../src";
import { DateTimePicker } from "../src/dateTimePicker";

describe("<DateTimePicker>", () => {
it("renders a DatePicker and a TimePicker", () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/docs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@blueprintjs/table": "^3.8.8",
"@blueprintjs/test-commons": "^0.10.3",
"@blueprintjs/timezone": "^3.6.6",
"@types/downloadjs": "^1.4.1",
"@documentalist/client": "~2.5.0",
"chroma-js": "^2.1.0",
"classnames": "^2.2",
"dom4": "^2.1.5",
Expand All @@ -42,6 +42,7 @@
"@blueprintjs/node-build-scripts": "^1.3.1",
"@blueprintjs/webpack-build-scripts": "^1.0.0",
"@types/chroma-js": "^1.4.1",
"@types/downloadjs": "^1.4.1",
"copy-webpack-plugin": "^5.1.1",
"npm-run-all": "^4.1.5",
"webpack-cli": "^3.3.11",
Expand Down
4 changes: 2 additions & 2 deletions packages/docs-app/src/components/colorPalettes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ function getHexCode(color: string) {
// @see http://stackoverflow.com/a/12043228/6342931
function getLuminance(hex: string) {
const rgb = parseInt(hex.substring(1), 16); // convert rrggbb to decimal
// eslint-disable no-bitwise
/* eslint-disable no-bitwise */
const red = (rgb >> 16) & 0xff;
const green = (rgb >> 8) & 0xff;
const blue = (rgb >> 0) & 0xff;
// eslint-enable
/* eslint-enable */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: specify which rule is being enabled

const luma = 0.2126 * red + 0.7152 * green + 0.0722 * blue; // per ITU-R BT.709
return luma;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

/* eslint-disable max-classes-per-file */

import * as React from "react";

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { Example, IExampleProps } from "@blueprintjs/docs-theme";
/**
* This component uses the imperative ContextMenu API.
*/
class GraphNode extends React.PureComponent<{}, { isContextMenuOpen: boolean }> {
class GraphNode extends React.PureComponent<any, { isContextMenuOpen: boolean }> {
public state = { isContextMenuOpen: false };

public render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

/* eslint-disable max-classes-per-file */

import * as React from "react";

import { Button, H5, Intent, IPanel, IPanelProps, NumericInput, PanelStack, Switch, UL } from "@blueprintjs/core";
Expand Down
3 changes: 1 addition & 2 deletions packages/docs-app/src/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*

Copyright 2015-present Palantir Technologies, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0.
Expand Down Expand Up @@ -27,7 +27,6 @@ Licensed under the Apache License, Version 2.0.
@import "styles/resources";
@import "styles/welcome";


.docs-releases-menu .#{$ns}-menu {
min-width: 270px;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/docs-theme/src/docs-theme.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*

Copyright 2015-present Palantir Technologies, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0.
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-config/eslint-plugin-rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": false
"devDependencies": [
"**/test/**/*.{ts,tsx}",
"**/*.test.{ts,tsx}"
]
}
],
"import/order": "off",
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"devDependencies": {
"@blueprintjs/node-build-scripts": "^1.3.1",
"@types/dedent": "^0.7.0",
"dedent": "^0.7.0",
"jest-junit": "^10.0.0"
},
"repository": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*
* Copyright 2019 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*
* Copyright 2019 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin/src/rules/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*
* Copyright 2019 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -18,7 +18,7 @@ import { classesConstantsRule } from "./classes-constants";
import { htmlComponentsRule } from "./html-components";
import { iconComponentsRule } from "./icon-components";

// eslint-disable-line import/no-default-export
// eslint-disable-next-line import/no-default-export
export default {
"classes-constants": classesConstantsRule,
"html-components": htmlComponentsRule,
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/utils/createRule.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*
* Copyright 2019 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/rules/utils/fixList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*
* Copyright 2019 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion packages/icons/src/blueprint-icons.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*

Copyright 2017-present Palantir Technologies, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0.
Expand Down
8 changes: 5 additions & 3 deletions packages/landing-app/src/index.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*

Copyright 2015-present Palantir Technologies, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0.
Expand Down Expand Up @@ -129,8 +129,10 @@ footer {
background-image: linear-gradient(
90deg,
rgba($white, 0) 0%,
rgba($white, 0.3) 50%,
rgba($white, 0) 100%
rgba($white, 0.3)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

revert unrelated change

50%,
rgba($white, 0)
100%
);
content: "";
display: block;
Expand Down
2 changes: 1 addition & 1 deletion packages/select/src/blueprint-select.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*

Copyright 2017-present Palantir Technologies, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0.
Expand Down
2 changes: 1 addition & 1 deletion packages/select/src/common/itemListRenderer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*
* Copyright 2017 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion packages/select/src/common/listItemsUtils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*!
/*
* Copyright 2018 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions packages/select/src/components/select/multiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ export interface IMultiSelectProps<T> extends IListItemsProps<T> {
placeholder?: string;

/** Props to spread to `Popover`. Note that `content` cannot be changed. */
// eslint-disable-next-line @typescript-eslint/ban-types
popoverProps?: Partial<IPopoverProps> & object;

/** Controlled selected values. */
selectedItems?: T[];

/** Props to spread to `TagInput`. Use `query` and `onQueryChange` to control the input. */
// eslint-disable-next-line @typescript-eslint/ban-types
tagInputProps?: Partial<ITagInputProps> & object;

/** Custom renderer to transform an item into tag content. */
Expand Down
1 change: 1 addition & 0 deletions packages/select/src/components/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface ISelectProps<T> extends IListItemsProps<T> {
inputProps?: IInputGroupProps & HTMLInputProps;

/** Props to spread to `Popover`. Note that `content` cannot be changed. */
// eslint-disable-next-line @typescript-eslint/ban-types
popoverProps?: Partial<IPopoverProps> & object;

/**
Expand Down
1 change: 1 addition & 0 deletions packages/select/src/components/select/suggest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export interface ISuggestProps<T> extends IListItemsProps<T> {
openOnKeyDown?: boolean;

/** Props to spread to `Popover`. Note that `content` cannot be changed. */
// eslint-disable-next-line @typescript-eslint/ban-types
popoverProps?: Partial<IPopoverProps> & object;

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/select/test/suggestTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import * as React from "react";
import * as sinon from "sinon";

import { IFilm, renderFilm, TOP_100_FILMS } from "../../docs-app/src/examples/select-examples/films";
import { ISuggestProps, ISuggestState, Suggest } from "../src/components/select/suggest";
import { IItemRendererProps, QueryList } from "../src";
import { ISuggestProps, ISuggestState, Suggest } from "../src/components/select/suggest";
import { selectComponentSuite } from "./selectComponentSuite";

describe("Suggest", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/table/src/quadrants/tableQuadrant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export interface ITableQuadrantProps extends IProps {
export class TableQuadrant extends AbstractComponent2<ITableQuadrantProps> {
// we want the user to explicitly pass a quadrantType. define defaultProps as a Partial to avoid
// declaring that and other required props here.
public static defaultProps: Partial<ITableQuadrantProps> & object = {
public static defaultProps: Partial<ITableQuadrantProps> = {
enableRowHeader: true,
};

Expand Down
Loading