Skip to content

Commit 70cf5a7

Browse files
authored
chore: reconfigure ESLint build, improve lint speed (#4078)
1 parent 0b526ca commit 70cf5a7

File tree

89 files changed

+1013
-439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+1013
-439
lines changed

.circleci/config.yml

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ aliases:
77
- &docker-node-browsers
88
- image: circleci/node:lts-browsers
99
environment:
10-
CHROME_BIN: "/usr/bin/google-chrome"
10+
CHROME_BIN: "/usr/bin/google-chrome"
1111

1212
- &restore-node-modules-cache
1313
name: Restore node_modules cache
@@ -47,7 +47,7 @@ jobs:
4747
- save_cache: *save-node-modules-cache
4848
- save_cache: *save-yarn-cache
4949
- persist_to_workspace:
50-
root: '.'
50+
root: "."
5151
paths: [packages/*/node_modules]
5252

5353
clean-lockfile:
@@ -63,37 +63,49 @@ jobs:
6363
steps:
6464
- checkout
6565
- restore_cache: *restore-node-modules-cache
66-
- attach_workspace: { at: '.' }
66+
- attach_workspace: { at: "." }
6767
- run: yarn compile
6868
- persist_to_workspace:
69-
root: '.'
69+
root: "."
7070
paths: [packages/*/lib, packages/*/src/generated]
7171

7272
lint:
7373
docker: *docker-node-lts
7474
environment:
7575
JUNIT_REPORT_PATH: reports
76+
NODE_ENV: test
7677
steps:
7778
- checkout
7879
- restore_cache: *restore-node-modules-cache
79-
- attach_workspace: { at: '.' }
80+
- attach_workspace: { at: "." }
8081
- run: mkdir -p ./reports/eslint ./reports/stylelint
8182
# we need to compile the lint rules for blueprint
82-
- run: yarn compile --scope "@blueprintjs/{eslint-plugin-blueprint,tslint-config}"
83+
- run: yarn compile --scope "@blueprintjs/eslint-plugin"
8384
- run: yarn lint
8485
- store_test_results: { path: ./reports }
8586
- store_artifacts: { path: ./reports }
8687

88+
format-check:
89+
docker: *docker-node-lts
90+
environment:
91+
JUNIT_REPORT_PATH: reports
92+
NODE_ENV: test
93+
steps:
94+
- checkout
95+
- restore_cache: *restore-node-modules-cache
96+
- attach_workspace: { at: "." }
97+
- run: yarn format-check
98+
8799
dist:
88100
docker: *docker-node-lts
89101
resource_class: large
90102
steps:
91103
- checkout
92104
- restore_cache: *restore-node-modules-cache
93-
- attach_workspace: { at: '.' }
105+
- attach_workspace: { at: "." }
94106
- run: yarn dist
95107
- persist_to_workspace:
96-
root: '.'
108+
root: "."
97109
paths: [packages/*/lib, packages/*/dist]
98110

99111
test-jest:
@@ -104,7 +116,7 @@ jobs:
104116
steps:
105117
- checkout
106118
- restore_cache: *restore-node-modules-cache
107-
- attach_workspace: { at: '.' }
119+
- attach_workspace: { at: "." }
108120
- run: mkdir ./reports
109121
- run: yarn lerna run test:jest-ci
110122
- store_test_results: { path: ./reports }
@@ -118,21 +130,21 @@ jobs:
118130
steps:
119131
- checkout
120132
- restore_cache: *restore-node-modules-cache
121-
- attach_workspace: { at: '.' }
133+
- attach_workspace: { at: "." }
122134
- run: mkdir ./reports
123135
- run:
124136
# split karma tests into containers because they can take up a lot of memory
125137
# running them in one container caused Karma to time out frequently
126138
# see https://github.com/palantir/blueprint/issues/3616
127139
command: |
128-
case $CIRCLE_NODE_INDEX in \
129-
0) yarn lerna run --parallel test:typeCheck ;; \
130-
1) yarn lerna run --scope "@blueprintjs/core" test:karma ;; \
131-
2) yarn lerna run --scope "@blueprintjs/datetime" test:karma ;; \
132-
3) yarn lerna run --scope "@blueprintjs/select" test:karma ;; \
133-
4) yarn lerna run --scope "@blueprintjs/table" test:karma ;; \
134-
5) yarn lerna run --scope "@blueprintjs/timezone" test:karma ;; \
135-
esac
140+
case $CIRCLE_NODE_INDEX in \
141+
0) yarn lerna run --parallel test:typeCheck ;; \
142+
1) yarn lerna run --scope "@blueprintjs/core" test:karma ;; \
143+
2) yarn lerna run --scope "@blueprintjs/datetime" test:karma ;; \
144+
3) yarn lerna run --scope "@blueprintjs/select" test:karma ;; \
145+
4) yarn lerna run --scope "@blueprintjs/table" test:karma ;; \
146+
5) yarn lerna run --scope "@blueprintjs/timezone" test:karma ;; \
147+
esac
136148
when: always
137149
- store_test_results: { path: ./reports }
138150
- store_artifacts: { path: ./reports }
@@ -151,7 +163,7 @@ jobs:
151163
steps:
152164
- checkout
153165
- restore_cache: *restore-node-modules-cache
154-
- attach_workspace: { at: '.' }
166+
- attach_workspace: { at: "." }
155167
- run: mkdir ./reports
156168
- run: yarn lerna run --parallel test:iso
157169
- store_test_results: { path: ./reports }
@@ -169,7 +181,7 @@ jobs:
169181
steps:
170182
- checkout
171183
- restore_cache: *restore-node-modules-cache
172-
- attach_workspace: { at: '.' }
184+
- attach_workspace: { at: "." }
173185
- store_artifacts: { path: packages/docs-app/dist }
174186
- store_artifacts: { path: packages/landing-app/dist }
175187
- store_artifacts: { path: packages/table-dev-app/dist }
@@ -182,7 +194,7 @@ jobs:
182194
steps:
183195
- checkout
184196
- restore_cache: *restore-node-modules-cache
185-
- attach_workspace: { at: '.' }
197+
- attach_workspace: { at: "." }
186198
- run: ./scripts/publish-npm-semver-tagged
187199

188200
workflows:
@@ -196,6 +208,8 @@ workflows:
196208
requires: [checkout-code]
197209
- lint:
198210
requires: [checkout-code]
211+
- format-check:
212+
requires: [checkout-code]
199213
- dist:
200214
requires: [compile]
201215
- test-jest:
@@ -211,7 +225,15 @@ workflows:
211225
- deploy-preview:
212226
requires: [dist]
213227
- deploy-npm:
214-
requires: [dist, lint, test-react-15, test-react-16, test-iso-react-15, test-iso-react-16]
228+
requires:
229+
[
230+
dist,
231+
lint,
232+
test-react-15,
233+
test-react-16,
234+
test-iso-react-15,
235+
test-iso-react-16,
236+
]
215237
filters:
216238
branches:
217239
only:

.eslintrc.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"root": true,
3-
"extends": [
4-
"./packages/eslint-config"
5-
],
6-
"ignorePatterns": [
7-
"node_modules",
8-
"dist",
9-
"lib",
10-
"fixtures",
11-
"coverage",
12-
"__snapshots__",
13-
"src/generated"
14-
]
2+
"root": true,
3+
"extends": [
4+
"./packages/eslint-config"
5+
],
6+
"ignorePatterns": [
7+
"node_modules",
8+
"dist",
9+
"lib",
10+
"fixtures",
11+
"coverage",
12+
"__snapshots__",
13+
"generated"
14+
]
1515
}

.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
generated/
3+
lib/
4+
dist/
5+
/site/

.prettierrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 4,
4+
"trailingComma": "all",
5+
"arrowParens": "avoid"
6+
}

README.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ Blueprint is a React-based UI toolkit for the web.
66

77
It is optimized for building complex, data-dense web interfaces for _desktop applications_ which run in modern browsers and IE11. This is not a mobile-first UI toolkit.
88

9-
109
[**Read the introductory blog post ▸**](https://medium.com/@palantir/scaling-product-design-with-blueprint-25492827bb4a)
1110

1211
[**View the full documentation ▸**](http://blueprintjs.com/docs)
@@ -33,36 +32,36 @@ This repository contains multiple projects in the `packages/` directory that fal
3332

3433
These are the component libraries we publish to NPM.
3534

36-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/core.svg?label=@blueprintjs/core)](https://www.npmjs.com/package/@blueprintjs/core) – Core styles & components.
37-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/datetime.svg?label=@blueprintjs/datetime)](https://www.npmjs.com/package/@blueprintjs/datetime) – Components for interacting with dates and times.
38-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/icons.svg?label=@blueprintjs/icons)](https://www.npmjs.com/package/@blueprintjs/icons) – Components for generating and displaying icons.
39-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/select.svg?label=@blueprintjs/select)](https://www.npmjs.com/package/@blueprintjs/select) – Components for selecting items from a list.
40-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/table.svg?label=@blueprintjs/table)](https://www.npmjs.com/package/@blueprintjs/table) – Scalable interactive table component.
41-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/timezone.svg?label=@blueprintjs/timezone)](https://www.npmjs.com/package/@blueprintjs/timezone) – Components for picking timezones.
35+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/core.svg?label=@blueprintjs/core)](https://www.npmjs.com/package/@blueprintjs/core) – Core styles & components.
36+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/datetime.svg?label=@blueprintjs/datetime)](https://www.npmjs.com/package/@blueprintjs/datetime) – Components for interacting with dates and times.
37+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/icons.svg?label=@blueprintjs/icons)](https://www.npmjs.com/package/@blueprintjs/icons) – Components for generating and displaying icons.
38+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/select.svg?label=@blueprintjs/select)](https://www.npmjs.com/package/@blueprintjs/select) – Components for selecting items from a list.
39+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/table.svg?label=@blueprintjs/table)](https://www.npmjs.com/package/@blueprintjs/table) – Scalable interactive table component.
40+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/timezone.svg?label=@blueprintjs/timezone)](https://www.npmjs.com/package/@blueprintjs/timezone) – Components for picking timezones.
4241

4342
### Applications
4443

4544
These are hosted on GitHub Pages as static web applications:
4645

47-
- `docs-app` – Documentation site at blueprintjs.com/docs
48-
- `landing-app` – Landing page at blueprintjs.com
46+
- `docs-app` – Documentation site at blueprintjs.com/docs
47+
- `landing-app` – Landing page at blueprintjs.com
4948

5049
These are used as development playground environments:
5150

52-
- `table-dev-app` – demo page that supports manual testing of all table features
51+
- `table-dev-app` – demo page that supports manual testing of all table features
5352

5453
### Build tooling
5554

5655
These packages define development dependencies and contain build configuration. They adhere to the standard NPM package layout, which allows us to keep clear API boundaries for build configuration and isolate groups of `devDependencies`. They are published to NPM in order to allow other Blueprint-related projects to use this infrastructure outside this monorepo.
5756

58-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/docs-theme.svg?label=@blueprintjs/docs-theme)](https://www.npmjs.com/package/@blueprintjs/docs-theme) – Documentation theme for [Documentalist](https://github.com/palantir/documentalist) data.
59-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/eslint-config.svg?label=@blueprintjs/eslint-config)](https://www.npmjs.com/package/@blueprintjs/eslint-config) – ESLint configuration used in this repo and recommended for Blueprint-related projects
60-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/eslint-plugin-blueprint.svg?label=@blueprintjs/eslint-plugin-blueprint)](https://www.npmjs.com/package/@blueprintjs/eslint-plugin-blueprint) – implementations for custom ESLint rules which enforce best practices for Blueprint usage
61-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/karma-build-scripts.svg?label=@blueprintjs/karma-build-scripts)](https://www.npmjs.com/package/@blueprintjs/karma-build-scripts)
62-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/node-build-scripts.svg?label=@blueprintjs/node-build-scripts)](https://www.npmjs.com/package/@blueprintjs/node-build-scripts) – various utility scripts for linting, working with CSS variables, and building icons
63-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/test-commons.svg?label=@blueprintjs/test-commons)](https://www.npmjs.com/package/@blueprintjs/test-commons) – various utility functions used in Blueprint test suites
64-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/tslint-config.svg?label=@blueprintjs/tslint-config)](https://www.npmjs.com/package/@blueprintjs/tslint-config) – TSLint configuration used in this repo and recommended for Blueprint-related projects (should be installed by `@blueprintjs/eslint-config`, not directly)
65-
- [![npm](https://img.shields.io/npm/v/@blueprintjs/webpack-build-scripts.svg?label=@blueprintjs/webpack-build-scripts)](https://www.npmjs.com/package/@blueprintjs/webpack-build-scripts)
57+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/docs-theme.svg?label=@blueprintjs/docs-theme)](https://www.npmjs.com/package/@blueprintjs/docs-theme) – Documentation theme for [Documentalist](https://github.com/palantir/documentalist) data.
58+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/eslint-config.svg?label=@blueprintjs/eslint-config)](https://www.npmjs.com/package/@blueprintjs/eslint-config) – ESLint configuration used in this repo and recommended for Blueprint-related projects
59+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/eslint-plugin.svg?label=@blueprintjs/eslint-plugin)](https://www.npmjs.com/package/@blueprintjs/eslint-plugin) – implementations for custom ESLint rules which enforce best practices for Blueprint usage
60+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/karma-build-scripts.svg?label=@blueprintjs/karma-build-scripts)](https://www.npmjs.com/package/@blueprintjs/karma-build-scripts)
61+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/node-build-scripts.svg?label=@blueprintjs/node-build-scripts)](https://www.npmjs.com/package/@blueprintjs/node-build-scripts) – various utility scripts for linting, working with CSS variables, and building icons
62+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/test-commons.svg?label=@blueprintjs/test-commons)](https://www.npmjs.com/package/@blueprintjs/test-commons) – various utility functions used in Blueprint test suites
63+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/tslint-config.svg?label=@blueprintjs/tslint-config)](https://www.npmjs.com/package/@blueprintjs/tslint-config) – TSLint configuration used in this repo and recommended for Blueprint-related projects (should be installed by `@blueprintjs/eslint-config`, not directly)
64+
- [![npm](https://img.shields.io/npm/v/@blueprintjs/webpack-build-scripts.svg?label=@blueprintjs/webpack-build-scripts)](https://www.npmjs.com/package/@blueprintjs/webpack-build-scripts)
6665

6766
## Contributing
6867

@@ -75,7 +74,7 @@ then [check out the "help wanted" label](https://github.com/palantir/blueprint/l
7574
[Lerna](https://lerna.js.org/) manages inter-package dependencies in this monorepo.
7675
Builds are orchestrated via `lerna run` and NPM scripts.
7776

78-
__Prerequisites__: Node.js v10+, Yarn v1.18+
77+
**Prerequisites**: Node.js v10+, Yarn v1.18+
7978

8079
### One-time setup
8180

@@ -85,17 +84,17 @@ After cloning this repo, run:
8584
1. If running on Windows:
8685
1. `npm install -g windows-build-tools` to install build tools globally
8786
1. Ensure `bash` is your configured script-shell by running:<br />
88-
`npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"`
87+
`npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"`
8988
1. `yarn verify` to ensure you have all the build tooling working properly.
9089

9190
### Incorporating upstream changes
9291

9392
If you were previously in a working state and have just pulled new code from `develop`:
9493

95-
- If there were package dependency changes, run `yarn` at the root.
96-
- This command is very quick if there are no new things to install.
97-
- Run `yarn compile` to get the latest built versions of the library packages in this repo.
98-
- This command is quicker than `yarn verify` since it doesn't build the application packages (`docs-app`, `landing-app`, etc.) or run tests
94+
- If there were package dependency changes, run `yarn` at the root.
95+
- This command is very quick if there are no new things to install.
96+
- Run `yarn compile` to get the latest built versions of the library packages in this repo.
97+
- This command is quicker than `yarn verify` since it doesn't build the application packages (`docs-app`, `landing-app`, etc.) or run tests
9998

10099
### Developing libraries
101100

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
"dist:libs": "lerna run dist --parallel --scope \"@blueprintjs/{core,datetime,docs-theme,icons,select,table,timezone}\"",
2525
"dist:apps": "lerna run dist --parallel --scope \"@blueprintjs/{docs-app,landing-app,table-dev-app}\"",
2626
"docs-data": "lerna run compile --scope \"@blueprintjs/docs-data\"",
27-
"lint": "lerna run --parallel lint",
28-
"lint-fix": "lerna run --parallel lint-fix",
27+
"format": "prettier --write \"./**/*.{ts,tsx}\"",
28+
"format-check": "prettier --check \"./**/*.{ts,tsx}\"",
29+
"lint": "NODE_ENV=test lerna run --parallel lint",
30+
"lint-fix": "NODE_ENV=test lerna run --parallel lint-fix",
2931
"serve": "http-server site",
3032
"site": "npm-run-all site:clean -p copy:* -s serve",
3133
"site:clean": "git clean -xdfq site/",
@@ -52,6 +54,7 @@
5254
"http-server": "^0.11.1",
5355
"lerna": "^2.11.0",
5456
"npm-run-all": "^4.1.5",
57+
"prettier": "^1.19.1",
5558
"sinon": "^7.3.2",
5659
"stylelint-config-palantir": "^4.0.0",
5760
"stylelint-scss": "^3.9.2",

packages/core/src/components/collapse/collapse.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,10 @@ export class Collapse extends AbstractPureComponent2<ICollapseProps, ICollapseSt
145145
break;
146146
default:
147147
// need to set an explicit height so that transition can work
148-
return { animationState: AnimationStates.CLOSING_START, height: `${state.heightWhenOpen}px` };
148+
return {
149+
animationState: AnimationStates.CLOSING_START,
150+
height: `${state.heightWhenOpen}px`,
151+
};
149152
}
150153
}
151154

packages/core/src/components/forms/numericInput.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,11 @@ export class NumericInput extends AbstractPureComponent2<HTMLInputProps & INumer
204204
};
205205

206206
public static getDerivedStateFromProps(props: INumericInputProps, state: INumericInputState) {
207-
const nextState = { prevMinProp: props.min, prevMaxProp: props.max, prevValueProp: props.value };
207+
const nextState = {
208+
prevMaxProp: props.max,
209+
prevMinProp: props.min,
210+
prevValueProp: props.value,
211+
};
208212

209213
const didMinChange = props.min !== state.prevMinProp;
210214
const didMaxChange = props.max !== state.prevMaxProp;
@@ -505,7 +509,10 @@ export class NumericInput extends AbstractPureComponent2<HTMLInputProps & INumer
505509
const currValue = this.state.value || NumericInput.VALUE_ZERO;
506510
const nextValue = this.getSanitizedValue(currValue, delta);
507511

508-
this.setState({ shouldSelectAfterUpdate: this.props.selectAllOnIncrement, value: nextValue });
512+
this.setState({
513+
shouldSelectAfterUpdate: this.props.selectAllOnIncrement,
514+
value: nextValue,
515+
});
509516

510517
return nextValue;
511518
}

packages/core/src/components/html-table/htmlTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class HTMLTable extends AbstractPureComponent2<IHTMLTableProps> {
5959
},
6060
className,
6161
);
62-
// eslint-disable-next-line @blueprintjs/blueprint/html-components
62+
// eslint-disable-next-line @blueprintjs/html-components
6363
return <table {...htmlProps} ref={elementRef} className={classes} />;
6464
}
6565
}

0 commit comments

Comments
 (0)