Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pre-commit to enforce code style practices #293

Merged
merged 4 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/get-node-version/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setOutput, setFailed, getInput } from "@actions/core";
import semver from "semver";
import {readFileSync} from "fs";
import { readFileSync } from "fs";

(() => {
const inputPath = getInput("package-json");
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/get-node-version/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

"composite": true,

"skipLibCheck": false,
"skipLibCheck": false
},
"include": ["./src/**/*.ts"],
"include": ["./src/**/*.ts"]
}
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ jobs:
id: get-node-version
uses: ./.github/actions/get-node-version

pre-commit:
name: Code style check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install pre-commit
run: curl https://pre-commit.com/install-local.py | python -
- name: Run pre-commit
run: ~/bin/pre-commit run --show-diff-on-failure --color=always --all-files

test:
name: Test
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ repos:
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
exclude_types: [svg]
- id: check-yaml
- id: mixed-line-ending
args: [--fix=lf]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.3.1"
hooks:
- id: prettier
exclude_types: [markdown, yaml]
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,16 @@ files.

To upgrade Storybook when it informs you about new version being available, run
the given `npx sb@latest upgrade` command in `apps/storybook` directory.

## pre-commit

[Pre-commit](https://pre-commit.com/) enforces code style practices in this
project. Choose your preferred
[installation method](https://pre-commit.com/#install) and then run `pre-commit
install` to enable Git hook scripts. Pre-commit will now automatically cancel
your commits if any problems are detected, and autofix them. Stage the changed
files to your commit and re-run the commit command.

Pre-commit can be disabled for a single commit with `--no-verify` option, but
note that CI also runs pre-commit and will fail if any problems are encountered
at this stage.
2 changes: 1 addition & 1 deletion apps/storybook/.babelrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
}
]
]
}
}
14 changes: 7 additions & 7 deletions apps/storybook/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module.exports = {
"stories": [
stories: [
"../stories/**/*.stories.mdx",
{
"directory": "../stories/components",
"files": "*.stories.*",
"titlePrefix": "@thunderstore/components"
directory: "../stories/components",
files: "*.stories.*",
titlePrefix: "@thunderstore/components",
},
],
"addons": [
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
"@snek-at/storybook-addon-chakra-ui", // Must come after @storybook addons
"@snek-at/storybook-addon-chakra-ui", // Must come after @storybook addons
],
"framework": "@storybook/react",
framework: "@storybook/react",
};
2 changes: 1 addition & 1 deletion apps/storybook/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export const parameters = {
{ name: "dark", value: "#333" },
],
},
}
};
32 changes: 20 additions & 12 deletions apps/storybook/stories/Introduction.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Meta } from '@storybook/addon-docs';
import Code from './assets/code-brackets.svg';
import Colors from './assets/colors.svg';
import Comments from './assets/comments.svg';
import Direction from './assets/direction.svg';
import Flow from './assets/flow.svg';
import Plugin from './assets/plugin.svg';
import Repo from './assets/repo.svg';
import StackAlt from './assets/stackalt.svg';
import { Meta } from "@storybook/addon-docs";
import Code from "./assets/code-brackets.svg";
import Colors from "./assets/colors.svg";
import Comments from "./assets/comments.svg";
import Direction from "./assets/direction.svg";
import Flow from "./assets/flow.svg";
import Plugin from "./assets/plugin.svg";
import Repo from "./assets/repo.svg";
import StackAlt from "./assets/stackalt.svg";

<Meta title="Example/Introduction" />

Expand Down Expand Up @@ -180,14 +180,22 @@ We recommend building UIs with a [**component-driven**](https://componentdriven.
Configure, customize, and extend
</span>
</a>
<a className="link-item" href="https://storybook.js.org/tutorials/" target="_blank">
<a
className="link-item"
href="https://storybook.js.org/tutorials/"
target="_blank"
>
<img src={Direction} alt="direction" />
<span>
<strong>In-depth guides</strong>
Best practices from leading teams
</span>
</a>
<a className="link-item" href="https://github.com/storybookjs/storybook" target="_blank">
<a
className="link-item"
href="https://github.com/storybookjs/storybook"
target="_blank"
>
<img src={Code} alt="code" />
<span>
<strong>GitHub project</strong>
Expand All @@ -204,6 +212,6 @@ We recommend building UIs with a [**component-driven**](https://componentdriven.
</div>

<div className="tip-wrapper">
<span className="tip">Tip</span>Edit the Markdown in{' '}
<span className="tip">Tip</span>Edit the Markdown in{" "}
<code>src/stories/Introduction.stories.mdx</code>
</div>
6 changes: 0 additions & 6 deletions apps/storybook/stories/components/Markdown.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ ${"```"}js
console.log("Hello, World!");
${"```"}



${"```"}python
print('Hello, World!')
${"```"}
Expand All @@ -33,16 +31,12 @@ const listContent = `
* Subitem
* Yet another item



1. First item
2. Second item
1. Subitem
2. Subitem
3. Last item



- [x] Read ticket thoroughly
- [ ] Design implementation
- [ ] Write code and tests
Expand Down