Skip to content
This repository was archived by the owner on Apr 1, 2023. It is now read-only.

setup Husky and Lint-staged #297

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 template/default/example/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ExampleComponent } from '{{name}}'
import '{{name}}/dist/index.css'

const App = () => {
return <ExampleComponent text="Create React Library Example 😄" />
return <ExampleComponent text='Create React Library Example 😄' />
}

export default App
15 changes: 14 additions & 1 deletion template/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"test:unit": "cross-env CI=1 react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"predeploy": "cd example && {{manager}} install && {{manager}} run build",
"deploy": "gh-pages -d example/build"
"deploy": "gh-pages -d example/build",
"pre-commit": "lint-staged"
},
"peerDependencies": {
"react": "^16.0.0"
Expand All @@ -43,10 +44,22 @@
"gh-pages": "^2.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.4",
"husky": "^4.2.5",
"lint-staged": "^10.3.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "^3.4.1"
},
"husky": {
"hooks": {
"pre-commit": "{{manager}} run pre-commit"
}
},
"lint-staged": {
"*.{js|json}": [
"prettier --write"
]
},
"files": [
"dist"
]
Expand Down
50 changes: 10 additions & 40 deletions template/flow/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,15 @@
"react/jsx-fragments": 0,
"react/no-unused-prop-types": 0,
"import/export": 0,
"flowtype/boolean-style": [
2,
"boolean"
],
"flowtype/boolean-style": [2, "boolean"],
"flowtype/define-flow-type": 1,
"flowtype/delimiter-dangle": [
2,
"never"
],
"flowtype/generic-spacing": [
2,
"never"
],
"flowtype/delimiter-dangle": [2, "never"],
"flowtype/generic-spacing": [2, "never"],
"flowtype/no-mixed": 2,
"flowtype/no-primitive-constructor-types": 2,
"flowtype/no-types-missing-file-annotation": 2,
"flowtype/no-weak-types": 2,
"flowtype/object-type-delimiter": [
2,
"comma"
],
"flowtype/object-type-delimiter": [2, "comma"],
"flowtype/require-parameter-type": 2,
"flowtype/require-readonly-react-props": 0,
"flowtype/require-return-type": [
Expand All @@ -61,30 +49,12 @@
}
],
"flowtype/require-valid-file-annotation": 2,
"flowtype/semi": [
2,
"always"
],
"flowtype/space-after-type-colon": [
2,
"always"
],
"flowtype/space-before-generic-bracket": [
2,
"never"
],
"flowtype/space-before-type-colon": [
2,
"never"
],
"flowtype/type-id-match": [
2,
"^([A-Z][a-z0-9]+)+Type$"
],
"flowtype/union-intersection-spacing": [
2,
"always"
],
"flowtype/semi": [2, "always"],
"flowtype/space-after-type-colon": [2, "always"],
"flowtype/space-before-generic-bracket": [2, "never"],
"flowtype/space-before-type-colon": [2, "never"],
"flowtype/type-id-match": [2, "^([A-Z][a-z0-9]+)+Type$"],
"flowtype/union-intersection-spacing": [2, "always"],
"flowtype/use-flow-type": 1,
"flowtype/valid-syntax": 1
}
Expand Down
2 changes: 1 addition & 1 deletion template/flow/example/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ExampleComponent } from '{{name}}'
import '{{name}}/dist/index.css'

const App = () => {
return <ExampleComponent text="Create React Library Example 😄" />
return <ExampleComponent text='Create React Library Example 😄' />
}

export default App
15 changes: 14 additions & 1 deletion template/flow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"test:unit": "cross-env CI=1 react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"predeploy": "cd example && {{manager}} install && {{manager}} run build",
"deploy": "gh-pages -d example/build"
"deploy": "gh-pages -d example/build",
"pre-commit": "lint-staged"
},
"peerDependencies": {
"react": "^16.0.0"
Expand All @@ -43,12 +44,24 @@
"gh-pages": "^2.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.4",
"husky": "^4.2.5",
"lint-staged": "^10.3.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "^3.4.1",
"@babel/preset-flow": "^7.10.1",
"eslint-plugin-flowtype": "^5.1.3"
},
"husky": {
"hooks": {
"pre-commit": "{{manager}} run pre-commit"
}
},
"lint-staged": {
"*.{js|json}": [
"prettier --write"
]
},
"files": [
"dist"
]
Expand Down
2 changes: 1 addition & 1 deletion template/typescript/example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ExampleComponent } from '{{name}}'
import '{{name}}/dist/index.css'

const App = () => {
return <ExampleComponent text="Create React Library Example 😄" />
return <ExampleComponent text='Create React Library Example 😄' />
}

export default App
2 changes: 1 addition & 1 deletion template/typescript/example/src/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom/extend-expect';
import '@testing-library/jest-dom/extend-expect'
15 changes: 14 additions & 1 deletion template/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"test:unit": "cross-env CI=1 react-scripts test --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"predeploy": "cd example && {{manager}} install && {{manager}} run build",
"deploy": "gh-pages -d example/build"
"deploy": "gh-pages -d example/build",
"pre-commit": "lint-staged"
},
"peerDependencies": {
"react": "^16.0.0"
Expand Down Expand Up @@ -52,11 +53,23 @@
"gh-pages": "^2.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.0.4",
"husky": "^4.2.5",
"lint-staged": "^10.3.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "^3.4.1",
"typescript": "^3.7.5"
},
"husky": {
"hooks": {
"pre-commit": "{{manager}} run pre-commit"
}
},
"lint-staged": {
"*.{js|json}": [
"prettier --write"
]
},
"files": [
"dist"
]
Expand Down
21 changes: 11 additions & 10 deletions template/typescript/src/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@
* will be overridden with file-specific definitions by rollup
*/
declare module '*.css' {
const content: { [className: string]: string };
export default content;
const content: { [className: string]: string }
export default content
}
declare module '*.scss' {
const content: { [className: string]: string };
export default content;
const content: { [className: string]: string }
export default content
}
declare module '*.less' {
const content: { [className: string]: string };
export default content;
const content: { [className: string]: string }
export default content
}

interface SvgrComponent extends React.StatelessComponent<React.SVGAttributes<SVGElement>> {}
interface SvgrComponent
extends React.StatelessComponent<React.SVGAttributes<SVGElement>> {}

declare module '*.svg' {
const svgUrl: string;
const svgComponent: SvgrComponent;
export default svgUrl;
const svgUrl: string
const svgComponent: SvgrComponent
export default svgUrl
export { svgComponent as ReactComponent }
}
2 changes: 1 addition & 1 deletion template/typescript/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"compilerOptions": {
"module": "commonjs"
}
}
}