Skip to content

Commit fd50c08

Browse files
authored
ci: refactor lint CI task and fix lint issues (#2004)
1 parent 9cfa3ff commit fd50c08

17 files changed

+155
-48
lines changed

.github/workflows/ci.yml

+22-20
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@ jobs:
2929
run: npm ci
3030
- name: CI Node Engine Check
3131
run: npm run ci:checkNodeEngine
32-
# check-lint:
33-
# name: Lint
34-
# timeout-minutes: 15
35-
# runs-on: ubuntu-18.04
36-
# steps:
37-
# - uses: actions/checkout@v2
38-
# - name: Use Node.js ${{ env.NODE_VERSION }}
39-
# uses: actions/setup-node@v1
40-
# with:
41-
# node-version: ${{ env.node-version }}
42-
# - name: Cache Node.js modules
43-
# uses: actions/cache@v2
44-
# with:
45-
# path: ~/.npm
46-
# key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
47-
# restore-keys: |
48-
# ${{ runner.os }}-node-${{ env.NODE_VERSION }}-
49-
# - name: Install dependencies
50-
# run: npm ci
51-
# - run: npm run lint
32+
check-lint:
33+
name: Lint
34+
timeout-minutes: 15
35+
runs-on: ubuntu-18.04
36+
steps:
37+
- uses: actions/checkout@v2
38+
- name: Use Node.js ${{ env.NODE_VERSION }}
39+
uses: actions/setup-node@v1
40+
with:
41+
node-version: ${{ env.node-version }}
42+
- name: Cache Node.js modules
43+
uses: actions/cache@v2
44+
with:
45+
path: ~/.npm
46+
key: ${{ runner.os }}-node-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
47+
restore-keys: |
48+
${{ runner.os }}-node-${{ env.NODE_VERSION }}-
49+
- name: Install dependencies
50+
run: npm ci
51+
- run: npm run lint
5252
check-circular:
5353
name: Circular Dependencies
5454
timeout-minutes: 5
@@ -147,6 +147,8 @@ jobs:
147147
- name: Install dependencies (Node >= 10)
148148
run: npm ci
149149
if: ${{ steps.node.outputs.node_major >= 10 }}
150+
- name: Tests
151+
run: npm test
150152
- name: Test bundles
151153
run: ./scripts/before_script.sh
152154
env:

jsconfig.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"typeAcquisition": {
3+
"include": [
4+
"jest"
5+
]
6+
},
7+
"exclude": ["node_modules"]
8+
}

package-lock.json

+91-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "parse-dashboard",
3-
"version": "4.1.0-beta.1",
3+
"version": "4.0.0-alpha.19",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/ParsePlatform/parse-dashboard"
@@ -89,6 +89,7 @@
8989
"@semantic-release/github": "7.2.3",
9090
"@semantic-release/npm": "7.1.3",
9191
"@semantic-release/release-notes-generator": "9.0.3",
92+
"@types/jest": "27.4.0",
9293
"all-node-versions": "8.0.0",
9394
"babel-eslint": "10.1.0",
9495
"babel-loader": "8.2.3",
@@ -127,7 +128,6 @@
127128
"build": "webpack --node-env=production --config webpack/production.config.js && webpack --config webpack/PIG.config.js",
128129
"test": "jest",
129130
"lint": "eslint . --ignore-path .gitignore --cache",
130-
"pretest": "npm run lint",
131131
"generate": "node scripts/generate.js",
132132
"prepare": "webpack --config webpack/publish.config.js --progress",
133133
"start": "node ./Parse-Dashboard/index.js",
@@ -148,6 +148,9 @@
148148
"transform": {
149149
".*": "<rootDir>/testing/preprocessor.js"
150150
},
151+
"moduleNameMapper": {
152+
"\\.(css|less)$": "<rootDir>/testing/styleMock.js"
153+
},
151154
"unmockedModulePathPatterns": [
152155
"react",
153156
"react-dom",

release.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function config() {
2626
// Get branch
2727
const branch = ref.split('/').pop();
2828
console.log(`Running on branch: ${branch}`);
29-
29+
3030
// Set changelog file
3131
const changelogFile = `./changelogs/CHANGELOG_${branch}.md`;
3232
console.log(`Changelog file output to: ${changelogFile}`);
@@ -96,7 +96,7 @@ async function config() {
9696
['@semantic-release/github', {
9797
successComment: getReleaseComment(),
9898
labels: ['type:ci'],
99-
releasedLabels: ['state:released<%= nextRelease.channel ? `-\${nextRelease.channel}` : "" %>']
99+
releasedLabels: ['state:released<%= nextRelease.channel ? `-${nextRelease.channel}` : "" %>']
100100
}],
101101
],
102102
};

src/components/Markdown/Markdown.react.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* the root directory of this source tree.
77
*/
88
import CodeSnippet from 'components/CodeSnippet/CodeSnippet.react';
9-
import marked from 'marked';
9+
import { marked } from 'marked';
1010
import PropTypes from 'lib/PropTypes';
1111
import React from 'react';
1212
import ReactDOMServer from 'react-dom/server';

src/components/Pill/Pill.react.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
*/
88
import React from 'react';
99
import styles from 'components/Pill/Pill.scss';
10-
import Icon from "components/Icon/Icon.react";
10+
import Icon from 'components/Icon/Icon.react';
1111

1212
//TODO: refactor, may want to move onClick outside or need to make onClick able to handle link/button a11y
1313
let Pill = ({ value, onClick, fileDownloadLink, followClick = false, shrinkablePill = false }) => (
1414
<span
1515
className={[
1616
styles.pill,
1717
!followClick && onClick ? styles.action : void 0
18-
].join(" ")}
18+
].join(' ')}
1919
onClick={!followClick && onClick ? onClick : null}
2020
>
2121
<span className={!followClick && fileDownloadLink ? styles.content : shrinkablePill ? styles.pillText : ''}>{value}</span>

src/components/PushPreview/PushPreview.react.js

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* This source code is licensed under the license found in the LICENSE file in
66
* the root directory of this source tree.
77
*/
8-
import PropTypes from 'lib/PropTypes';
9-
import ParseApp from 'lib/ParseApp';
108
import React from 'react';
119
import SegmentSelect from 'components/SegmentSelect/SegmentSelect.react';
1210
import styles from 'components/PushPreview/PushPreview.scss';

src/components/Sidebar/Pin.react.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from "react";
1+
import React from 'react';
22

3-
import Icon from "components/Icon/Icon.react";
4-
import styles from "components/Sidebar/Sidebar.scss";
3+
import Icon from 'components/Icon/Icon.react';
4+
import styles from 'components/Sidebar/Sidebar.scss';
55

66
const Pin = ({ onClick }) => (
77
<div className={styles.pinContainer} onClick={onClick}>

src/dashboard/Data/Browser/Browser.react.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ class Browser extends DashboardView {
402402
if (name === 'objectId' || this.state.isUnique && name !== this.state.uniqueField) {
403403
return;
404404
}
405-
if (!!required) {
405+
if (required) {
406406
requiredCols.push(name);
407407
}
408408
if (className === '_User' && (name === 'username' || name === 'password')) {
@@ -419,7 +419,7 @@ class Browser extends DashboardView {
419419
for (let idx = 0; idx < requiredCols.length; idx++) {
420420
const name = requiredCols[idx];
421421
if (obj.get(name) == null) {
422-
this.showNote("Please enter all required fields", true);
422+
this.showNote('Please enter all required fields', true);
423423
this.setState({
424424
markRequiredFieldRow: -1
425425
});
@@ -461,7 +461,7 @@ class Browser extends DashboardView {
461461
if (msg) {
462462
msg = msg[0].toUpperCase() + msg.substr(1);
463463
}
464-
obj.set(attr, prev);
464+
obj.revert();
465465
this.setState({ data: this.state.data });
466466
this.showNote(msg, true);
467467
}
@@ -506,7 +506,7 @@ class Browser extends DashboardView {
506506
if (name === 'objectId' || this.state.isUnique && name !== this.state.uniqueField) {
507507
return;
508508
}
509-
if (!!required) {
509+
if (required) {
510510
requiredCols.push(name);
511511
}
512512
if (className === '_User' && (name === 'username' || name === 'password')) {
@@ -523,7 +523,7 @@ class Browser extends DashboardView {
523523
for (let idx = 0; idx < requiredCols.length; idx++) {
524524
const name = requiredCols[idx];
525525
if (obj.get(name) == null) {
526-
this.showNote("Please enter all required fields", true);
526+
this.showNote('Please enter all required fields', true);
527527
this.setState({
528528
markRequiredFieldRow: rowIndex
529529
});

src/dashboard/Data/Browser/BrowserToolbar.react.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ let BrowserToolbar = ({
326326
{editCloneRows && editCloneRows.length > 0 && (
327327
<BrowserMenu title="Clone" icon="clone-icon">
328328
<MenuItem
329-
text={"Cancel all pending rows"}
329+
text={'Cancel all pending rows'}
330330
onClick={onCancelPendingEditRows}
331331
/>
332332
</BrowserMenu>

src/dashboard/Data/Browser/DataBrowser.react.js

+1
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ export default class DataBrowser extends React.Component {
257257
getNextVisibleColumnIndex(distance = 1, min = 0, max = 0) {
258258
if (distance === 0) { return this.state.current.col; }
259259
let newIndex = this.state.current.col + distance;
260+
// eslint-disable-next-line no-constant-condition
260261
while (true) {
261262
if (this.state.order[newIndex]?.visible) { return newIndex; }
262263
if (newIndex <= min) { return min; }

src/dashboard/Data/Browser/ExportSelectedRowsDialog.react.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default class ExportSelectedRowsDialog extends React.Component {
2727
<Modal
2828
type={Modal.Types.INFO}
2929
icon='warn-outline'
30-
title={this.props.selection['*'] ? 'Export all rows?' : (selectionLength === 1 ? `Export 1 selected row?` : `Export ${selectionLength} selected rows?`)}
30+
title={this.props.selection['*'] ? 'Export all rows?' : (selectionLength === 1 ? 'Export 1 selected row?' : `Export ${selectionLength} selected rows?`)}
3131
subtitle={this.props.selection['*'] ? 'Note: Exporting is limited to the first 10,000 rows.' : ''}
3232
disabled={!this.valid()}
3333
confirmText={'Yes export'}

src/lib/tests/BrowserCell.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* the root directory of this source tree.
77
*/
88
jest.dontMock('../../components/BrowserCell/BrowserCell.react');
9+
jest.mock('idb-keyval');
910

1011
import React from 'react';
1112
import renderer from 'react-test-renderer';

0 commit comments

Comments
 (0)