Skip to content

Commit

Permalink
chore: update git hooks config
Browse files Browse the repository at this point in the history
  • Loading branch information
qiqiboy committed Nov 13, 2020
1 parent f3a9f71 commit 933d9bc
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 18 deletions.
16 changes: 1 addition & 15 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
const pkg = require('./package.json');

const hasJsxRuntime = (() => {
if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
return false;
}

try {
require.resolve('react/jsx-runtime');

return true;
} catch (e) {
return false;
}
})();

/**
* 0: off
* 1: warn
Expand All @@ -31,7 +17,7 @@ module.exports = {
}
],
settings: {
'import/core-modules': [...Object.keys(pkg.dependencies), ...Object.keys(pkg.peerDependencies)]
'import/core-modules': [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})]
},
rules: {
'react/react-in-jsx-scope': 2,
Expand Down
1 change: 1 addition & 0 deletions jest/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
]
},
{
displayName: 'test',
rootDir: process.cwd(),
roots: ['<rootDir>/src', fs.existsSync(process.cwd() + '/tests') && '<rootDir>/tests'].filter(Boolean),
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts'],
Expand Down
52 changes: 49 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"start": "cd docs && npm start",
"build": "npm run clear && rollup -c",
"clear": "rimraf dist",
"test": "node jest/test.js"
"test": "node jest/test.js",
"tsc": "node -e \"require('fs-extra').outputJsonSync('.git-tsconfig.json',{ extends: './tsconfig.json', include: ['*.d.ts'].concat(process.env.StagedFiles.split(/\\n+/)) })\" && echo 'TS checking...\\n' && tsc -p .git-tsconfig.json --noEmit --checkJs false"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -89,7 +90,7 @@
"eslint-config-react-app": "6.0.0",
"eslint-plugin-flowtype": "5.2.0",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-jest": "24.1.0",
"eslint-plugin-jest": "24.1.3",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-react": "7.21.5",
"eslint-plugin-react-hooks": "4.2.0",
Expand Down Expand Up @@ -122,5 +123,50 @@
"react-fast-compare": "^3.0.1",
"warning": "^4.0.3"
},
"sideEffects": false
"sideEffects": false,
"husky": {
"hooks": {
"commit-msg": "node_modules/.bin/commitlint --edit $HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged && export StagedFiles=$(git diff --diff-filter AM --name-only --relative --staged | grep -E '^src/.*\\.m?[jt]sx?$') && if [ -n \"$StagedFiles\" ]; then npm run tsc ; fi"
}
},
"lint-staged": {
"src/**/*.{js,jsx,mjs,ts,tsx}": [
"node_modules/.bin/prettier --write",
"node_modules/.bin/eslint --fix"
],
"src/**/*.{css,scss,less,json,html,md}": [
"node_modules/.bin/prettier --write"
]
},
"stylelint": {
"extends": "stylelint-config-recommended"
},
"browserslist": [
">0.2%",
"not dead",
"not op_mini all"
],
"config": {
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"engines": {
"node": ">=10.13.0",
"tiger-new": "6.2.7"
},
"commitlint": {
"extends": [
"@commitlint/config-conventional"
],
"rules": {
"subject-case": [
0
],
"scope-case": [
0
]
}
}
}

0 comments on commit 933d9bc

Please sign in to comment.