Skip to content

Commit

Permalink
feat: lint, test and precommit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
iamogbz committed Jul 22, 2018
1 parent 4edef36 commit 543e71d
Show file tree
Hide file tree
Showing 8 changed files with 8,574 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.circleci/
artifacts/
internals/
server/
docs/
node_modules/
59 changes: 59 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"parser": "babel-eslint",
"extends": [
"airbnb",
"prettier"
],
"env": {
"browser": true,
"node": true,
"jest": true,
"es6": true
},
"plugins": [
"import",
"jsx-a11y",
"react",
"prettier"
],
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"globals": {
"browser": false
},
"rules": {
"arrow-parens": [2, "as-needed"],
"arrow-body-style": [2, "as-needed"],
"class-methods-use-this": 0,
"no-console": 1,
"no-param-reassign": ["error", { "props": false }],
"no-trailing-spaces": 2,
"no-use-before-define": [2, {
"functions": false
}],
"import/prefer-default-export": 0,
"react/jsx-first-prop-new-line": [2, "multiline"],
"react/jsx-indent": [2, 4],
"react/jsx-indent-props": [2, 4],
"prettier/prettier": [2, {
"bracketSpacing": true,
"jsxBracketSameLine": false,
"semi": true,
"singleQuote": false,
"tabWidth": 4,
"trailingComma": "all"
}]
},
"settings": {
"import/resolver": {
"node": {
"paths": ["src"]
}
}
}
}
33 changes: 33 additions & 0 deletions .github/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

command_exists () {
command -v "$1" >/dev/null 2>&1
}

has_hook_script () {
[ -f package.json ] && cat package.json | grep -q "\"$1\"[[:space:]]*:"
}

cd "."

# Check if precommit script is defined, skip if not
has_hook_script precommit || exit 0

# Check that npm exists
command_exists npm || {
echo >&2 "Can't find npm in PATH, skipping precommit script in package.json"
exit 0
}

# Export Git hook params
export GIT_PARAMS="$*"

# Run npm script
echo "npm run -s precommit (node `node -v`)"
echo

npm run -s precommit || {
echo
echo "pre-commit hook failed (add --no-verify to bypass)"
exit 1
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
14 changes: 14 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"processors": ["stylelint-processor-styled-components"],
"extends": [
"stylelint-config-standard",
"stylelint-config-styled-components"
],
"syntax": "scss",
"rules": {
"block-opening-brace-space-after": null,
"block-closing-brace-space-before": null,
"declaration-colon-newline-after": null,
"indentation": 4
}
}

0 comments on commit 543e71d

Please sign in to comment.