mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
feat: git commit hooks for formatting and msg check
This commit is contained in:
parent
d408b482bb
commit
75049e3a7d
16
.commitlintrc.cjs
Normal file
16
.commitlintrc.cjs
Normal file
@ -0,0 +1,16 @@
|
||||
const conventional = require("@commitlint/config-conventional");
|
||||
|
||||
module.exports = {
|
||||
extends: ["@commitlint/config-conventional"],
|
||||
plugins: ["commitlint-plugin-function-rules"],
|
||||
helpUrl: "https://github.com/nextui-org/nextui/blob/main/CONTRIBUTING.MD#commit-convention",
|
||||
rules: {
|
||||
...conventional.rules,
|
||||
"type-enum": [
|
||||
2,
|
||||
"always",
|
||||
["feat", "feature", "fix", "refactor", "docs", "build", "test", "ci", "chore"],
|
||||
],
|
||||
"function-rules/header-max-length": [0],
|
||||
},
|
||||
};
|
||||
@ -1,9 +1,9 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_size = 2
|
||||
max_line_length = 100
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
max_line_length = 80
|
||||
|
||||
@ -5,7 +5,6 @@ examples/*
|
||||
dist
|
||||
esm/*
|
||||
public/*
|
||||
scripts/*
|
||||
tests/*
|
||||
*.config.js
|
||||
.DS_Store
|
||||
@ -13,4 +12,11 @@ node_modules
|
||||
coverage
|
||||
.next
|
||||
build
|
||||
|
||||
!scripts
|
||||
!.storybook
|
||||
!.commitlintrc.cjs
|
||||
!.lintstagedrc.cjs
|
||||
!jest.config.js
|
||||
!plopfile.js
|
||||
!react-shim.js
|
||||
!tsup.config.ts
|
||||
|
||||
4
.husky/commit-msg
Normal file
4
.husky/commit-msg
Normal file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
pnpm commitlint --config .commitlintrc.cjs --edit ${1}
|
||||
9
.husky/pre-commit
Normal file
9
.husky/pre-commit
Normal file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
# Avoid excessive outputs
|
||||
if [ -t 2 ]; then
|
||||
exec >/dev/tty 2>&1
|
||||
fi
|
||||
|
||||
pnpm lint-staged
|
||||
27
.lintstagedrc.cjs
Normal file
27
.lintstagedrc.cjs
Normal file
@ -0,0 +1,27 @@
|
||||
const {relative} = require("path");
|
||||
|
||||
const {ESLint} = require("eslint");
|
||||
|
||||
const removeIgnoredFiles = async (files) => {
|
||||
const cwd = process.cwd();
|
||||
const eslint = new ESLint();
|
||||
const relativePaths = files.map((file) => relative(cwd, file));
|
||||
const isIgnored = await Promise.all(relativePaths.map((file) => eslint.isPathIgnored(file)));
|
||||
const filteredFiles = files.filter((_, i) => !isIgnored[i]);
|
||||
|
||||
return filteredFiles.join(" ");
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
// *.!(js|ts|jsx|tsx|d.ts)
|
||||
"**/*.{js,cjs,mjs,ts,jsx,tsx,json,md}": async (files) => {
|
||||
const filesToLint = await removeIgnoredFiles(files);
|
||||
|
||||
return [`prettier --config .prettierrc.json --ignore-path --write ${filesToLint}`];
|
||||
},
|
||||
"**/*.{js,cjs,mjs,ts,jsx,tsx}": async (files) => {
|
||||
const filesToLint = await removeIgnoredFiles(files);
|
||||
|
||||
return [`eslint -c .eslintrc.json --max-warnings=0 --fix ${filesToLint}`];
|
||||
},
|
||||
};
|
||||
@ -1,5 +1,16 @@
|
||||
dist
|
||||
examples
|
||||
node_modules
|
||||
plop
|
||||
coverage
|
||||
.next
|
||||
build
|
||||
pnpm-lock.yaml
|
||||
!scripts
|
||||
!.storybook
|
||||
!.commitlintrc.cjs
|
||||
!.lintstagedrc.cjs
|
||||
!jest.config.js
|
||||
!plopfile.js
|
||||
!react-shim.js
|
||||
!tsup.config.ts
|
||||
|
||||
12
.prettierrc.json
Normal file
12
.prettierrc.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/prettierrc.json",
|
||||
"tabWidth": 2,
|
||||
"printWidth": 100,
|
||||
"semi": true,
|
||||
"useTabs": false,
|
||||
"singleQuote": false,
|
||||
"bracketSpacing": false,
|
||||
"endOfLine": "auto",
|
||||
"arrowParens": "always",
|
||||
"trailingComma": "all"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user