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

Add git hooks and simplify scripts #8427

Merged
merged 52 commits into from
Nov 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
12974b5
Refactor package.json and add git hooks
lipis Sep 25, 2018
c898599
Npm
lipis Sep 25, 2018
7cdbe76
Lint JS
lipis Sep 25, 2018
1a00df7
Ignore
lipis Sep 25, 2018
49a4d5e
Simpler
lipis Sep 25, 2018
d85b10c
Staged
lipis Sep 25, 2018
39d84c7
Merge branch 'master' of github.com:gatsbyjs/gatsby into hooks
lipis Sep 25, 2018
cf803f5
Plugins
lipis Sep 25, 2018
18a540c
Order
lipis Sep 25, 2018
95faa4d
Run all linters
lipis Sep 25, 2018
6697ee5
Upgrade eslint and remove ^
lipis Sep 25, 2018
f2d2c32
Yarn.lock
lipis Sep 25, 2018
78e6c30
Add prettier and sort
lipis Sep 26, 2018
31ac9f5
unpin
lipis Sep 26, 2018
529268b
Revert
lipis Sep 26, 2018
af78235
npm run
lipis Sep 26, 2018
f8b4a07
Double quotes
lipis Sep 26, 2018
72ac0c7
Quotes
lipis Sep 26, 2018
2416652
--
lipis Sep 26, 2018
e7fd4a6
Merge branch 'master' of github.com:gatsbyjs/gatsby into hooks
lipis Sep 26, 2018
d3e28b4
Merge branch 'master' of github.com:gatsbyjs/gatsby into hooks
lipis Sep 27, 2018
ec13550
Update Husky
lipis Sep 27, 2018
2ad1e1c
Update ignore list
lipis Sep 27, 2018
1f127d9
Lint all
lipis Sep 27, 2018
33cb27a
Clean up
lipis Sep 27, 2018
c072eac
Merge branch 'master' of github.com:gatsbyjs/gatsby into hooks
lipis Sep 28, 2018
66606b0
Merge branch 'master' of github.com:gatsbyjs/gatsby into hooks
lipis Sep 28, 2018
427af33
Merge branch 'master' of github.com:gatsbyjs/gatsby into hooks
lipis Oct 3, 2018
113f15a
Merge
lipis Oct 4, 2018
5eb7833
Merge branch 'master' of github.com:gatsbyjs/gatsby into hooks
lipis Oct 9, 2018
36ebd6b
Rollback
lipis Oct 9, 2018
db9d86c
Update deps
lipis Oct 9, 2018
0b01529
Merge
lipis Oct 20, 2018
5f95ec4
Merge with upstream
lipis Oct 31, 2018
caa3c37
Merge branch 'master' into hooks
lipis Nov 1, 2018
32e828a
use newer lint-staged to support partially staged files
pieh Nov 6, 2018
9d27a29
don't run lint:flow - it's really broken
pieh Nov 6, 2018
c0e74c2
set react version, so eslint-plugin-react doesn't complain about it
pieh Nov 6, 2018
f9c657b
add hooks:(un)install scripts so it's easier to uninstall hooks
pieh Nov 6, 2018
5c12af8
ignore infrastracture directory
pieh Nov 6, 2018
797bc8c
hoist react eslint rules from www to root
pieh Nov 6, 2018
7450f6c
add cy and Cypress globals
pieh Nov 6, 2018
9539a8b
warn for react/no-unescaped-entities instead of error - need to evalu…
pieh Nov 6, 2018
8ad560a
ignore .cache dirs
pieh Nov 6, 2018
031ec68
don't run prettier for .json files
pieh Nov 6, 2018
96715be
ignore specimen files
pieh Nov 6, 2018
37f7a40
format css
pieh Nov 6, 2018
9257ee9
adjust lint-staged rule to not apply to json and apply to css
pieh Nov 6, 2018
2699831
don't reject commits and provide some feedback message
pieh Nov 6, 2018
2f6a57f
Add EOL
lipis Nov 6, 2018
c294bda
Rename scripts from *:js to *:code
lipis Nov 6, 2018
20a6521
Merge branch 'master' of github.com:gatsbyjs/gatsby into hooks
lipis Nov 6, 2018
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 .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
trim_trailing_whitespace = true
52 changes: 25 additions & 27 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"prettier/flowtype",
"prettier/react"
],
"plugins": ["flowtype", "react"],
"plugins": ["flowtype", "prettier", "react"],
"parserOptions": {
"ecmaVersion": 2016,
"sourceType": "module",
Expand All @@ -27,36 +27,22 @@
"spyOn": true
},
"rules": {
"no-console": "off",
"no-inner-declarations": "off",
"valid-jsdoc": "off",
"require-jsdoc": "off",
"quotes": ["error", "backtick"],
"consistent-return": ["error"],
"arrow-body-style": [
"error",
"as-needed",
{ "requireReturnForObjectLiteral": true }
],
"jsx-quotes": ["error", "prefer-double"],
"semi": ["error", "never"],
"object-curly-spacing": ["error", "always"],
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "ignore"
}
],
"react/prop-types": [
"error",
{
"ignore": ["children"]
}
]
"consistent-return": ["error"],
"no-console": "off",
"no-inner-declarations": "off",
"prettier/prettier": "error",
"quotes": ["error", "backtick"],
"react/display-name": "off",
"react/jsx-key": "warn",
"react/no-unescaped-entities": "warn",
"react/prop-types": "off",
"require-jsdoc": "off",
"valid-jsdoc": "off"
},
"overrides": [
{
Expand All @@ -71,6 +57,18 @@
"___loader": false,
"___emitter": false
}
},
{
"files": ["**/cypress/integration/**/*"],
"globals": {
"cy": false,
"Cypress": false
}
}
],
"settings": {
"react": {
"version": "16.4.2"
}
]
}
}
28 changes: 27 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
/package.json
*.min.js
**/node_modules/**
flow-typed

# webfont demo styles
**/specimen_files

# built sites
benchmarks/**/public
e2e-tests/**/public
examples/**/public
integration-tests/**/public
www/public

# cache-dirs
**/.cache

# ignore built packages
packages/*/*.js
packages/gatsby/cache-dir/commonjs
packages/gatsby/dist

# fixtures
**/__testfixtures__/**
**/__tests__/fixtures/**

infrastructure
5 changes: 3 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"trailingComma": "es5",
"semi": false,
"tabWidth": 2
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5"
}
59 changes: 36 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@
"babel-jest": "^22.4.3",
"chokidar": "^1.7.0",
"cross-env": "^5.1.4",
"eslint": "^4.19.1",
"eslint-config-google": "^0.9.1",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-flowtype": "^2.46.1",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-react": "^7.7.0",
"eslint": "^5.6.1",
"eslint-config-google": "^0.10.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-flow-vars": "^0.5.0",
"eslint-plugin-flowtype": "^2.50.3",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-react": "^7.11.1",
"flow-bin": "^0.42.0",
"fs-extra": "^7.0.0",
"glob": "^7.1.1",
"husky": "1.1.1",
"jest": "^23.5.0",
"jest-cli": "^23.5.0",
"lerna": "^3.3.0",
"lint-staged": "^8.0.4",
"npm-run-all": "4.1.2",
"plop": "^1.8.1",
"prettier": "^1.12",
"prettier-eslint-cli": "4.7.1",
"prettier": "^1.14.3",
"rimraf": "^2.6.1",
"yargs": "^10.0.3"
},
Expand All @@ -38,27 +40,39 @@
"**/__tests__/fixtures/"
],
"private": true,
"lint-staged": {
"*.{js,jsx}": [
"eslint --ignore-path .gitignore --ignore-path .prettierignore --fix",
"git add"
],
"*.{md,css,scss,yaml,yml}": [
"prettier --write",
"git add"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged || node scripts/on-lint-error.js"
}
},
"scripts": {
"bootstrap": "npm-run-all -s check-versions lerna-prepare",
"check-versions": "babel-node scripts/check-versions.js",
"format": "npm-run-all -p format-packages format-cache-dir format-www format-integration format-examples format-scripts format-markdown format-yaml",
"format-cache-dir": "prettier-eslint --write \"packages/gatsby/cache-dir/*.js\"",
"format-examples": "prettier-eslint --write \"examples/**/gatsby-node.js\" \"examples/**/gatsby-config.js\" \"examples/**/src/**/*.js\"",
"format-markdown": "prettier --write \"**/*.md\" --no-semi",
"format-packages": "prettier-eslint --write \"packages/*/src/**/*.js\"",
"format-scripts": "prettier-eslint --write \"scripts/**/*.js\"",
"format-www": "prettier-eslint --write \"www/*.js\" \"www/src/**/*.js\"",
"format-integration": "prettier-eslint --write \"integration-tests/**/src/**/*.js\" \"integration-tests/**/cypress/**/*.js\"",
"format-yaml": "prettier --write \"**/*.y?(a)ml\"",
"format": "npm run format:code && npm run format:other",
"format:other": "npm run prettier -- --write",
"format:code": "npm run lint:code -- --fix",
"hooks:uninstall": "node node_modules/husky/husky.js uninstall",
"hooks:install": "node node_modules/husky/husky.js install",
"jest": "jest",
"lerna": "lerna",
"lerna-prepare": "lerna run prepare",
"lint": "npm-run-all --continue-on-error --parallel lint:js lint:yaml",
"lint:js": "eslint --ext .js,.jsx packages/**/src integration-tests/**/src",
"lint": "npm-run-all --continue-on-error -p lint:code lint:other",
"lint:code": "eslint --ignore-path .gitignore --ignore-path .prettierignore --ext .js,.jsx .",
"lint:flow": "babel-node scripts/flow-check.js",
"lint:yaml": "prettier --list-different \"**/*.y?(a)ml\"",
"lint:other": "npm run prettier -- --list-different",
"plop": "plop",
"prebootstrap": "yarn",
"prettier": "prettier \"**/*.{md,css,scss,yaml,yml}\"",
"publish": "node scripts/check-publish-access && lerna publish",
"publish-canary": "lerna publish --canary --yes",
"publish-next": "lerna publish --npm-tag=next --bump=prerelease",
Expand All @@ -67,7 +81,6 @@
"test:update": "jest --updateSnapshot",
"test:watch": "jest --watch",
"test:integration": "jest --config=integration-tests/jest.config.js",
"version": "prettier --write \"**/CHANGELOG.md\" --no-semi",
"watch": "lerna run watch --no-sort --stream --concurrency 999"
},
"workspaces": [
Expand Down
12 changes: 12 additions & 0 deletions scripts/on-lint-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
console.log(
`Gatsby uses precommit hooks to run our linting and style checks. We do this
to avoid additional hassle during pull request reviews, so please fix any linting
problems before submitting pull request, because all PRs must pass these checks.

If you're doing something temporary, you can disable this hook with:
git commit --no-verify

If you want disable this hook for all future commits:
npm run hooks:uninstall
`
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

5 changes: 0 additions & 5 deletions www/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
{
"globals": {
"graphql": true
},
"rules": {
"react/display-name": [0],
"react/jsx-key": [1],
"react/prop-types": [0]
}
}
8 changes: 0 additions & 8 deletions www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,10 @@
"front-matter": "^2.3.0",
"get-package-json-from-github": "^1.2.1",
"github-api": "^3.0.0",
"husky": "^1.0.0-rc.14",
"prettier": "^1.14.2",
"pretty-quick": "^1.6.0",
"stylelint": "^9.6.0",
"stylelint-config-standard": "^18.2.0",
"stylelint-config-styled-components": "^0.1.1",
"stylelint-processor-styled-components": "^1.5.0",
"webshot": "^0.18.0"
},
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
}
}
Loading