Skip to content

Commit 6f9db09

Browse files
authored
Merge pull request #293 from thunderstore-io/pre-commit
Use pre-commit to enforce code style practices
2 parents 0dd8bbe + bf99c0b commit 6f9db09

File tree

10 files changed

+60
-30
lines changed

10 files changed

+60
-30
lines changed

.github/actions/get-node-version/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { setOutput, setFailed, getInput } from "@actions/core";
22
import semver from "semver";
3-
import {readFileSync} from "fs";
3+
import { readFileSync } from "fs";
44

55
(() => {
66
const inputPath = getInput("package-json");

.github/actions/get-node-version/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
"composite": true,
4242

43-
"skipLibCheck": false,
43+
"skipLibCheck": false
4444
},
45-
"include": ["./src/**/*.ts"],
45+
"include": ["./src/**/*.ts"]
4646
}

.github/workflows/test.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ jobs:
2525
id: get-node-version
2626
uses: ./.github/actions/get-node-version
2727

28+
pre-commit:
29+
name: Code style check
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v2
33+
- uses: actions/setup-python@v2
34+
with:
35+
python-version: '3.8'
36+
- name: Install pre-commit
37+
run: curl https://pre-commit.com/install-local.py | python -
38+
- name: Run pre-commit
39+
run: ~/bin/pre-commit run --show-diff-on-failure --color=always --all-files
40+
2841
test:
2942
name: Test
3043
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ repos:
44
hooks:
55
- id: trailing-whitespace
66
- id: end-of-file-fixer
7+
exclude_types: [svg]
78
- id: check-yaml
89
- id: mixed-line-ending
910
args: [--fix=lf]
1011
- repo: https://github.com/pre-commit/mirrors-prettier
1112
rev: "v2.3.1"
1213
hooks:
1314
- id: prettier
15+
exclude_types: [markdown, yaml]

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,16 @@ files.
9797

9898
To upgrade Storybook when it informs you about new version being available, run
9999
the given `npx sb@latest upgrade` command in `apps/storybook` directory.
100+
101+
## pre-commit
102+
103+
[Pre-commit](https://pre-commit.com/) enforces code style practices in this
104+
project. Choose your preferred
105+
[installation method](https://pre-commit.com/#install) and then run `pre-commit
106+
install` to enable Git hook scripts. Pre-commit will now automatically cancel
107+
your commits if any problems are detected, and autofix them. Stage the changed
108+
files to your commit and re-run the commit command.
109+
110+
Pre-commit can be disabled for a single commit with `--no-verify` option, but
111+
note that CI also runs pre-commit and will fail if any problems are encountered
112+
at this stage.

apps/storybook/.babelrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@
5858
}
5959
]
6060
]
61-
}
61+
}

apps/storybook/.storybook/main.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
module.exports = {
2-
"stories": [
2+
stories: [
33
"../stories/**/*.stories.mdx",
44
{
5-
"directory": "../stories/components",
6-
"files": "*.stories.*",
7-
"titlePrefix": "@thunderstore/components"
5+
directory: "../stories/components",
6+
files: "*.stories.*",
7+
titlePrefix: "@thunderstore/components",
88
},
99
],
10-
"addons": [
10+
addons: [
1111
"@storybook/addon-links",
1212
"@storybook/addon-essentials",
1313
"@storybook/addon-interactions",
14-
"@snek-at/storybook-addon-chakra-ui", // Must come after @storybook addons
14+
"@snek-at/storybook-addon-chakra-ui", // Must come after @storybook addons
1515
],
16-
"framework": "@storybook/react",
16+
framework: "@storybook/react",
1717
};

apps/storybook/.storybook/preview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ export const parameters = {
1414
{ name: "dark", value: "#333" },
1515
],
1616
},
17-
}
17+
};

apps/storybook/stories/Introduction.stories.mdx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Meta } from '@storybook/addon-docs';
2-
import Code from './assets/code-brackets.svg';
3-
import Colors from './assets/colors.svg';
4-
import Comments from './assets/comments.svg';
5-
import Direction from './assets/direction.svg';
6-
import Flow from './assets/flow.svg';
7-
import Plugin from './assets/plugin.svg';
8-
import Repo from './assets/repo.svg';
9-
import StackAlt from './assets/stackalt.svg';
1+
import { Meta } from "@storybook/addon-docs";
2+
import Code from "./assets/code-brackets.svg";
3+
import Colors from "./assets/colors.svg";
4+
import Comments from "./assets/comments.svg";
5+
import Direction from "./assets/direction.svg";
6+
import Flow from "./assets/flow.svg";
7+
import Plugin from "./assets/plugin.svg";
8+
import Repo from "./assets/repo.svg";
9+
import StackAlt from "./assets/stackalt.svg";
1010

1111
<Meta title="Example/Introduction" />
1212

@@ -180,14 +180,22 @@ We recommend building UIs with a [**component-driven**](https://componentdriven.
180180
Configure, customize, and extend
181181
</span>
182182
</a>
183-
<a className="link-item" href="https://storybook.js.org/tutorials/" target="_blank">
183+
<a
184+
className="link-item"
185+
href="https://storybook.js.org/tutorials/"
186+
target="_blank"
187+
>
184188
<img src={Direction} alt="direction" />
185189
<span>
186190
<strong>In-depth guides</strong>
187191
Best practices from leading teams
188192
</span>
189193
</a>
190-
<a className="link-item" href="https://github.com/storybookjs/storybook" target="_blank">
194+
<a
195+
className="link-item"
196+
href="https://github.com/storybookjs/storybook"
197+
target="_blank"
198+
>
191199
<img src={Code} alt="code" />
192200
<span>
193201
<strong>GitHub project</strong>
@@ -204,6 +212,6 @@ We recommend building UIs with a [**component-driven**](https://componentdriven.
204212
</div>
205213

206214
<div className="tip-wrapper">
207-
<span className="tip">Tip</span>Edit the Markdown in{' '}
215+
<span className="tip">Tip</span>Edit the Markdown in{" "}
208216
<code>src/stories/Introduction.stories.mdx</code>
209217
</div>

apps/storybook/stories/components/Markdown.stories.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ ${"```"}js
1919
console.log("Hello, World!");
2020
${"```"}
2121
22-
23-
2422
${"```"}python
2523
print('Hello, World!')
2624
${"```"}
@@ -33,16 +31,12 @@ const listContent = `
3331
* Subitem
3432
* Yet another item
3533
36-
37-
3834
1. First item
3935
2. Second item
4036
1. Subitem
4137
2. Subitem
4238
3. Last item
4339
44-
45-
4640
- [x] Read ticket thoroughly
4741
- [ ] Design implementation
4842
- [ ] Write code and tests

0 commit comments

Comments
 (0)