Skip to content

Commit 7d7dadb

Browse files
committed
Merge updates from project template
Signed-off-by: Kevin Locke <[email protected]>
2 parents ab68e5f + b0a1ce8 commit 7d7dadb

File tree

4 files changed

+62
-14
lines changed

4 files changed

+62
-14
lines changed

.eslintrc.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ extends: "airbnb-base"
88
parserOptions:
99
sourceType: "script"
1010

11-
env:
12-
node: true
13-
## disable unwanted browser env from airbnb/legacy
14-
# Note: Only works for ESLint 2+: https://github.com/eslint/eslint/issues/3915
15-
browser: false
16-
1711
rules:
1812
# Possible Errors
1913
# list: https://github.com/eslint/eslint/tree/master/docs/rules#possible-errors
@@ -31,8 +25,6 @@ rules:
3125
no-param-reassign: 0
3226
## disallow unnecessary use of Function.prototype.{apply,call}
3327
no-useless-call: 2
34-
## allow vars anywhere that satisfies other linting constraints
35-
vars-on-top: 0
3628

3729
# Strict Mode
3830
# list: https://github.com/eslint/eslint/tree/master/docs/rules#strict-mode
@@ -91,7 +83,8 @@ rules:
9183
one-var-declaration-per-line: [2, "initializations"]
9284
## Requires operator at the beginning of the line in multiline statements
9385
# Airbnb prevents breaks around =, suggesting (). I don't see the advantage.
94-
operator-linebreak: [2, "before"]
86+
# Break after = looks better to me, so first assigned operand is farther left.
87+
operator-linebreak: [2, "before", { "overrides": { "=": "after" } }]
9588
## no space before function, eg. 'function()'
9689
space-before-function-paren: [2, "never"]
9790

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
#
3+
# Enforce hooks.allownonascii and core.whitespace configuration on commit.
4+
#
5+
# Copied from:
6+
# https://github.com/git/git/blob/v2.18.0/templates/hooks--pre-commit.sample
7+
8+
if git rev-parse --verify HEAD >/dev/null 2>&1
9+
then
10+
against=HEAD
11+
else
12+
# Initial commit: diff against an empty tree object
13+
against=$(git hash-object -t tree /dev/null)
14+
fi
15+
16+
# If you want to allow non-ASCII filenames set this variable to true.
17+
allownonascii=$(git config --bool hooks.allownonascii)
18+
19+
# Redirect output to stderr.
20+
exec 1>&2
21+
22+
# Cross platform projects tend to avoid non-ASCII filenames; prevent
23+
# them from being added to the repository. We exploit the fact that the
24+
# printable range starts at the space character and ends with tilde.
25+
if [ "$allownonascii" != "true" ] &&
26+
# Note that the use of brackets around a tr range is ok here, (it's
27+
# even required, for portability to Solaris 10's /usr/bin/tr), since
28+
# the square bracket bytes happen to fall in the designated range.
29+
test $(git diff --cached --name-only --diff-filter=A -z $against |
30+
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
31+
then
32+
cat <<\EOF
33+
Error: Attempt to add a non-ASCII file name.
34+
35+
This can cause problems if you want to work with people on other platforms.
36+
37+
To be portable it is advisable to rename the file.
38+
39+
If you know what you are doing you can disable this check using:
40+
41+
git config hooks.allownonascii true
42+
EOF
43+
exit 1
44+
fi
45+
46+
# If there are whitespace errors, print the offending file names and fail.
47+
exec git diff-index --check --cached $against --

.githooks/pre-commit/02-eslint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
# Run ESLint on changed .js and .jsx files
3+
4+
set -Ceu
5+
6+
# Run ESLint on added/modified JS files
7+
# Use -z to \0-separate and prevent quoting of special chars in filenames
8+
# Use tr+grep+tr to filter newline separated (could use --null-data for GNU)
9+
git diff -z --cached --name-only --diff-filter=AM |
10+
tr '\n\0' '\0\n' |
11+
grep -a '\.jsx\?$' |
12+
tr '\0\n' '\n\0' |
13+
xargs -0r ./node_modules/.bin/eslint --

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,6 @@
6262
"node": ">=6",
6363
"npm": ">=1.3.7"
6464
},
65-
"greenkeeper": {
66-
"ignore": [
67-
"eslint"
68-
]
69-
},
7065
"nyc": {
7166
"exclude": [
7267
"test",

0 commit comments

Comments
 (0)