Skip to content

Commit

Permalink
add precommit lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Sep 15, 2017
1 parent eb33e96 commit 91913e1
Show file tree
Hide file tree
Showing 4 changed files with 300 additions and 11 deletions.
283 changes: 283 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
module.exports = {
"env": {
"es6": true,
"node": true
},
"globals": {
// react native
"window": true,
"__DEV__": true,
"localStorage": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"accessor-pairs": "error",
"array-bracket-spacing": "warn",
"array-callback-return": "warn",
"arrow-body-style": "warn",
"arrow-parens": [
"error",
"as-needed"
],
"arrow-spacing": [
"error",
{
"after": true,
"before": true
}
],
"block-scoped-var": "error",
"block-spacing": "error",
"brace-style": [
"error",
"1tbs"
],
"callback-return": "error",
"camelcase": "warn",
"capitalized-comments": "off",
"class-methods-use-this": "error",
"comma-dangle": "off",
"comma-spacing": [
"error",
{
"after": true,
"before": false
}
],
"comma-style": [
"error",
"last"
],
"complexity": "error",
"computed-property-spacing": "error",
"consistent-return": "warn",
"consistent-this": "warn",
"curly": "off",
"default-case": "error",
"dot-location": "off",
"dot-notation": "warn",
"eol-last": "warn",
"eqeqeq": "warn",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": "warn",
"func-style": "warn",
"generator-star-spacing": "off",
"global-require": "off",
"guard-for-in": "warn",
"handle-callback-err": "warn",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"indent": "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "error",
"keyword-spacing": [
"error",
{
"after": true,
"before": true
}
],
"line-comment-position": "warn",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "warn",
"lines-around-directive": "error",
"max-depth": "error",
"max-len": "off",
"max-lines": "warn",
"max-nested-callbacks": "error",
"max-params": "warn",
"max-statements": "off",
"max-statements-per-line": "error",
"multiline-ternary": "warn",
"new-cap": "error",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "warn",
"no-alert": "error",
"no-array-constructor": "error",
"no-await-in-loop": "error",
"no-bitwise": "error",
"no-caller": "error",
"no-case-declarations": "warn",
"no-catch-shadow": "warn",
"no-cond-assign": "warn",
"no-confusing-arrow": "error",
"no-console": "warn",
"no-constant-condition": "warn",
"no-continue": "warn",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "error",
"no-ex-assign": "off",
"no-empty": [
"error",
{
"allowEmptyCatch": true
}
],
"no-empty-function": "off",
"no-eq-null": "warn",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": "warn",
"no-extra-semi": "warn",
"no-floating-decimal": "error",
"no-implicit-coercion": "warn",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": "warn",
"no-invalid-this": "warn",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "warn",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-mixed-operators": "error",
"no-mixed-requires": "error",
"no-multi-assign": "warn",
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "warn",
"no-negated-in-lhs": "error",
"no-nested-ternary": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "warn",
"no-path-concat": "error",
"no-process-env": "off",
"no-process-exit": "off",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "warn",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "warn",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "off",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "warn",
"no-undefined": "warn",
"no-underscore-dangle": "warn",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-unused-vars": "warn",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-escape": "warn",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "warn",
"no-void": "error",
"no-warning-comments": "warn",
"no-whitespace-before-property": "error",
"no-with": "error",
"object-curly-newline": "off",
"object-curly-spacing": [
"error",
"always"
],
"object-property-newline": [
"error",
{
"allowMultiplePropertiesPerLine": true
}
],
"object-shorthand": "warn",
"one-var": "off",
"one-var-declaration-per-line": "error",
"operator-assignment": "error",
"operator-linebreak": "error",
"padded-blocks": "off",
"prefer-const": "warn",
"prefer-destructuring": "warn",
"prefer-numeric-literals": "error",
"prefer-promise-reject-errors": "error",
"prefer-reflect": "warn",
"prefer-rest-params": "warn",
"prefer-spread": "warn",
"prefer-template": "off",
"quote-props": "off",
"quotes": "off",
"radix": "error",
"require-await": "error",
"require-jsdoc": "off",
"require-yield": "off",
"rest-spread-spacing": [
"error",
"never"
],
"semi": "off",
"semi-spacing": "error",
"sort-imports": "error",
"sort-keys": "off",
"sort-vars": "error",
"space-before-blocks": "error",
"space-before-function-paren": "error",
"space-in-parens": [
"error",
"never"
],
"space-infix-ops": "off",
"space-unary-ops": "error",
"spaced-comment": [
"error",
"always"
],
"strict": "error",
"symbol-description": "error",
"template-curly-spacing": [
"error",
"never"
],
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "warn",
"vars-on-top": "off",
"wrap-iife": "error",
"wrap-regex": "warn",
"yield-star-spacing": "error",
"yoda": [
"error",
"never"
]
}
};
2 changes: 1 addition & 1 deletion cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function installShims ({ modules, overwrite }, done) {

parallel(shimPkgNames.map(function (name) {
var modPath = path.resolve('./node_modules/' + name)
return function (cb) {
return function (cb) {
fs.exists(modPath, function (exists) {
if (!exists) return cb()

Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@
"run-parallel": "^1.1.2",
"semver": "^5.0.1",
"xtend": "^4.0.0"
},
"scripts": {
"lint": "eslint --quiet --ignore-path .gitignore .",
"precommit": "npm run lint"
},
"devDependencies": {
"husky": "^0.14.3"
}
}
19 changes: 9 additions & 10 deletions pkg-hacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ var path = require('path')

module.exports = function hackFiles (hacks) {
var finder = find('./node_modules')
hacks = hacks || hackers.map(function (h) { return h.name })
hacks = hacks || hackers.map(h => h.name)

finder.on('file', function (file) {
if (!/\.(js|json)$/.test(file)
|| /\/tests?\//.test(file)) {
if (!/\.(js|json)$/.test(file) ||
/\/tests?\//.test(file)) {
return
}

Expand Down Expand Up @@ -163,7 +163,7 @@ var hackers = [
regex: [
/webtorrent\/lib\/fs-storage\.js/
],
hack: function(file, contents) {
hack: function (file, contents) {
if (isInReactNative(file)) return

var fixed = contents.replace(/fs\.existsSync\([^\)]*\)/g, 'false')
Expand All @@ -177,7 +177,7 @@ var hackers = [
],
hack: function (file, contents) {
var fixed = contents.replace(/typeof\ FileReaderSync \!\=\= \'undefined\'/, 'false')
return contents === fixed ? null : fixed
return contents === fixed ? null : fixed
}
},
{
Expand Down Expand Up @@ -224,7 +224,7 @@ var hackers = [
regex: [
/levelup\/lib\/util\.js$/
],
hack: function(file, contents) {
hack: function (file, contents) {
if (isInReactNative(file)) return

var fixed = contents
Expand Down Expand Up @@ -257,7 +257,7 @@ var hackers = [
regex: [
/level-jobs\/package\.json$/
],
hack: function(file, contents) {
hack: function (file, contents) {
if (isInReactNative(file)) return

var pkg
Expand Down Expand Up @@ -425,7 +425,7 @@ var hackers = [
regex: [
/bytewise\/bytewise\.js$/
],
hack: function(file, contents) {
hack: function (file, contents) {
if (isInReactNative(file)) return

var fixed = contents
Expand Down Expand Up @@ -532,8 +532,7 @@ function rewireMain (pkg) {
var main = pkg.browser || './index.js'
pkg.browser = {}
pkg.browser[pkg.main] = main
}
else if (typeof pkg.browser === 'undefined') {
} else if (typeof pkg.browser === 'undefined') {
pkg.browser = {}
}
}
Expand Down

0 comments on commit 91913e1

Please sign in to comment.