Skip to content

Commit a8dc416

Browse files
committed
chore(lint): lint on ci
1 parent 2b19769 commit a8dc416

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@
6161
"cy:open": "yarn cy:wait; yarn cypress open",
6262
"cy:run": "yarn cy:wait; yarn cypress run --spec \"test/integration/**/*.cy.js\"",
6363
"cy:wait": "wait-on http-get://127.0.0.1:6060/#",
64-
"lint": "npm-run-all lint:js lint:ts lint:staged",
64+
"lint": "npm-run-all lint:js lint:ts lint:ci",
6565
"lint:js": "eslint --max-warnings=0 .",
6666
"lint:ts": "tsc",
67-
"lint:css": "stylelint \"src/**/*.scss\" --syntax scss",
68-
"lint:staged": "lint-staged -c scripts/lint-staged.config.js",
67+
"lint:ci": "./scripts/lint.sh",
6968
"prebuild:es": "npm-run-all copy:styles ts:defs copy:flow",
7069
"release": "yarn release:beta",
7170
"release:beta": "DIST=beta BRANCH=master ./scripts/release.sh",
@@ -97,7 +96,7 @@
9796
},
9897
"husky": {
9998
"hooks": {
100-
"pre-commit": "yarn lint:staged",
99+
"pre-commit": "lint-staged -c scripts/lint-staged.config.js",
101100
"pre-push": "scripts/prepush.sh",
102101
"commit-msg": "commitlint -e"
103102
}

scripts/lint.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
3+
lint(){
4+
local fix_flag=$1
5+
local eslint_cmd="eslint --max-warnings 0"
6+
local stylelint_cmd="stylelint --max-warnings 0"
7+
local prettier_cmd="prettier --check"
8+
local exit_code=0
9+
local color="\033[1;34m"
10+
local no_color="\033[0m"
11+
12+
if [ "$fix_flag" == "--fix" ]; then
13+
eslint_cmd="eslint --fix --max-warnings 0"
14+
stylelint_cmd="stylelint --fix --max-warnings 0"
15+
prettier_cmd="prettier --write"
16+
fi
17+
18+
echo -e "${color}Running: $prettier_cmd --parser=flow src/**/*.js${no_color}"
19+
$prettier_cmd --parser=flow src/**/*.js --ignore-path .gitignore || exit_code=$?
20+
21+
echo -e "${color}Running: $prettier_cmd --parser=typescript src/**/*.{ts,tsx}${no_color}"
22+
$prettier_cmd --parser=typescript src/**/*.{ts,tsx} --ignore-path .gitignore || exit_code=$?
23+
24+
echo -e "${color}Running: $eslint_cmd src/**/*.{js,ts,tsx}${no_color}"
25+
$eslint_cmd src/**/*.{js,ts,tsx} || exit_code=$?
26+
27+
echo -e "${color}Running: $prettier_cmd --parser=markdown ./**/*.md${no_color}"
28+
$prettier_cmd --parser=markdown ./**/*.md --ignore-path .gitignore || exit_code=$?
29+
30+
echo -e "${color}Running: $prettier_cmd --parser=json ./**/*.json${no_color}"
31+
$prettier_cmd --parser=json ./**/*.json --ignore-path .gitignore || exit_code=$?
32+
33+
echo -e "${color}Running: $prettier_cmd --parser=html ./**/*.html${no_color}"
34+
$prettier_cmd --parser=html ./**/*.html --ignore-path .gitignore || exit_code=$?
35+
36+
echo -e "${color}Running: $prettier_cmd --parser=scss src/**/*.scss${no_color}"
37+
$prettier_cmd --parser=scss src/**/*.scss --ignore-path .gitignore || exit_code=$?
38+
39+
echo -e "${color}Running: $stylelint_cmd --syntax scss '**/*.scss'${no_color}"
40+
$stylelint_cmd --syntax scss "**/*.scss" --ignore-path .gitignore || exit_code=$?
41+
42+
echo -e "${color}Running: $prettier_cmd --parser=css ./**/*.css${no_color}"
43+
$prettier_cmd --parser=css ./**/*.css --ignore-path .gitignore || exit_code=$?
44+
45+
echo -e "${color}Running: $stylelint_cmd --syntax css '**/*.css'${no_color}"
46+
$stylelint_cmd --syntax css "**/*.css" --ignore-path .gitignore || exit_code=$?
47+
48+
return $exit_code
49+
};
50+
51+
lint $1

src/elements/content-preview/ContentPreview.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ class ContentPreview extends React.PureComponent<Props, State> {
829829
skipServerUpdate: true,
830830
useHotkeys: false,
831831
};
832+
832833
const { Preview } = global.Box;
833834
this.preview = new Preview();
834835
this.preview.addListener('load', this.onPreviewLoad);

0 commit comments

Comments
 (0)