Skip to content

Commit 9a7b4a3

Browse files
committed
chore(wip): lint
1 parent a8dc416 commit 9a7b4a3

File tree

8 files changed

+125
-54
lines changed

8 files changed

+125
-54
lines changed

.circleci/config.yml

+12
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ jobs:
8686
name: Flow
8787
command: yarn --cwd /buie flow check
8888

89+
typescript:
90+
executor: default
91+
steps:
92+
- checkout
93+
- setup-workspace
94+
- run:
95+
name: Flow
96+
command: yarn --cwd /buie tsc
97+
8998
build-unit-tests:
9099
executor: default
91100
steps:
@@ -137,6 +146,9 @@ workflows:
137146
- flow:
138147
requires:
139148
- setup
149+
- typescript:
150+
requires:
151+
- setup
140152
- build-unit-tests:
141153
requires:
142154
- setup

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@
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:ci",
65-
"lint:js": "eslint --max-warnings=0 .",
64+
"lint": "npm-run-all lint:ts lint:ci",
6665
"lint:ts": "tsc",
67-
"lint:ci": "./scripts/lint.sh",
66+
"lint:code": "./scripts/lint-code.sh",
67+
"lint:css": "./scripts/lint-styles.sh",
68+
"lint:misc": "./scripts/lint-misc.sh",
69+
"lint:ci": "./scripts/lint-all.sh",
6870
"prebuild:es": "npm-run-all copy:styles ts:defs copy:flow",
6971
"release": "yarn release:beta",
7072
"release:beta": "DIST=beta BRANCH=master ./scripts/release.sh",

scripts/lint-all.sh

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
lint_all(){
4+
local fix_flag=$1
5+
local exit_code=0
6+
7+
./scripts/lint-code.sh $fix_flag || exit_code=$?
8+
./scripts/lint-styles.sh $fix_flag || exit_code=$?
9+
./scripts/lint-misc.sh $fix_flag || exit_code=$?
10+
11+
return $exit_code
12+
};
13+
14+
lint_all $1

scripts/lint-code.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
lint_code(){
4+
local fix_flag=$1
5+
local eslint_cmd="eslint --max-warnings 0"
6+
local prettier_cmd="prettier --check"
7+
local exit_code=0
8+
local color="\033[1;34m"
9+
local no_color="\033[0m"
10+
11+
if [ "$fix_flag" == "--fix" ]; then
12+
eslint_cmd="eslint --fix --max-warnings 0"
13+
prettier_cmd="prettier --write"
14+
fi
15+
16+
echo -e "${color}Running: $prettier_cmd --parser=flow src/**/*.js${no_color}"
17+
$prettier_cmd --parser=flow "src/**/*.js" --ignore-path .gitignore || exit_code=$?
18+
19+
echo -e "${color}Running: $prettier_cmd --parser=typescript src/**/*.{ts,tsx}${no_color}"
20+
$prettier_cmd --parser=typescript "src/**/*.{ts,tsx}" --ignore-path .gitignore || exit_code=$?
21+
22+
echo -e "${color}Running: $eslint_cmd src/**/*.{js,ts,tsx}${no_color}"
23+
$eslint_cmd "src/**/*.{js,ts,tsx}" || exit_code=$?
24+
25+
return $exit_code
26+
};
27+
28+
lint_code $1

scripts/lint-misc.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
3+
lint_misc(){
4+
local fix_flag=$1
5+
local prettier_cmd="prettier --check"
6+
local exit_code=0
7+
local color="\033[1;34m"
8+
local no_color="\033[0m"
9+
10+
if [ "$fix_flag" == "--fix" ]; then
11+
prettier_cmd="prettier --write"
12+
fi
13+
14+
echo -e "${color}Running: $prettier_cmd --parser=markdown ./**/*.md${no_color}"
15+
$prettier_cmd --parser=markdown "./**/*.md" --ignore-path .gitignore || exit_code=$?
16+
17+
echo -e "${color}Running: $prettier_cmd --parser=json ./**/*.json${no_color}"
18+
$prettier_cmd --parser=json "./**/*.json" --ignore-path .gitignore || exit_code=$?
19+
20+
echo -e "${color}Running: $prettier_cmd --parser=html ./**/*.html${no_color}"
21+
$prettier_cmd --parser=html "./**/*.html" --ignore-path .gitignore || exit_code=$?
22+
23+
return $exit_code
24+
};
25+
26+
lint_misc $1

scripts/lint-styles.sh

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
lint_styles(){
4+
local fix_flag=$1
5+
local stylelint_cmd="stylelint --max-warnings 0"
6+
local prettier_cmd="prettier --check"
7+
local exit_code=0
8+
local color="\033[1;34m"
9+
local no_color="\033[0m"
10+
11+
if [ "$fix_flag" == "--fix" ]; then
12+
stylelint_cmd="stylelint --fix --max-warnings 0"
13+
prettier_cmd="prettier --write"
14+
fi
15+
16+
echo -e "${color}Running: $prettier_cmd --parser=scss src/**/*.scss${no_color}"
17+
$prettier_cmd --parser=scss "src/**/*.scss" --ignore-path .gitignore || exit_code=$?
18+
19+
echo -e "${color}Running: $stylelint_cmd --syntax scss '**/*.scss'${no_color}"
20+
$stylelint_cmd --syntax scss "**/*.scss" --ignore-path .gitignore || exit_code=$?
21+
22+
echo -e "${color}Running: $prettier_cmd --parser=css ./**/*.css${no_color}"
23+
$prettier_cmd --parser=css "./**/*.css" --ignore-path .gitignore || exit_code=$?
24+
25+
echo -e "${color}Running: $stylelint_cmd --syntax css '**/*.css'${no_color}"
26+
$stylelint_cmd --syntax css "**/*.css" --ignore-path .gitignore || exit_code=$?
27+
28+
return $exit_code
29+
};
30+
31+
lint_styles $1

scripts/lint.sh

-51
This file was deleted.

src/elements/content-preview/ContentPreview.js

+9
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,15 @@ class ContentPreview extends React.PureComponent<Props, State> {
830830
useHotkeys: false,
831831
};
832832

833+
834+
835+
836+
837+
838+
839+
840+
841+
833842
const { Preview } = global.Box;
834843
this.preview = new Preview();
835844
this.preview.addListener('load', this.onPreviewLoad);

0 commit comments

Comments
 (0)