diff --git a/.gitignore b/.gitignore index 496ee2c..9daa824 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.DS_Store \ No newline at end of file +.DS_Store +node_modules diff --git a/javascript/.editorconfig b/javascript/.editorconfig index ef6b499..f4a577c 100644 --- a/javascript/.editorconfig +++ b/javascript/.editorconfig @@ -5,6 +5,11 @@ # (multiple files can be used, and are applied starting from current document location) root = true +# Special handling of package.json since npm want 2 spaces here +[{package.json}] +indent_style = space +indent_size = 2 + # Use bracketed regexp to target specific file types or file locations [*.{js,json}] diff --git a/javascript/.eslintrc b/javascript/.eslintrc deleted file mode 100644 index 81ee24c..0000000 --- a/javascript/.eslintrc +++ /dev/null @@ -1,154 +0,0 @@ -{ - "env": { - "node": true, - "mocha": true, - "browser": true - }, - "rules": { - "block-scoped-var": 0, - "brace-style": 2, - "camelcase": 2, - "comma-dangle": 2, - "comma-spacing": 2, - "comma-style": 2, - "complexity": 0, - "consistent-return": 2, - "consistent-this": [2, "self"], - "curly": 2, - "default-case": 2, - "dot-notation": 2, - "eol-last": 2, - "eqeqeq": 2, - "func-names": 0, - "func-style": 0, - "handle-callback-err": 2, - "indent": [2, 4, {"SwitchCase": 1}], - "jsx-quotes": [2, "prefer-double"], - "key-spacing": 2, - "max-depth": [2, 6], - "max-len": [2, 120, 4], - "max-nested-callbacks": [2, 6], - "max-params": 0, - "max-statements": 0, - "new-cap": 2, - "new-parens": 2, - "no-alert": 2, - "no-array-constructor": 2, - "no-bitwise": 2, - "no-caller": 2, - "no-catch-shadow": 2, - "no-cond-assign": 2, - "no-console": 1, - "no-constant-condition": 2, - "no-control-regex": 1, - "no-debugger": 2, - "no-delete-var": 2, - "no-div-regex": 2, - "no-dupe-args": 2, - "no-dupe-keys": 2, - "no-duplicate-case": 2, - "no-else-return": 2, - "no-empty": 2, - "no-empty-character-class": 2, - "no-empty-label": 2, - "no-eq-null": 2, - "no-eval": 2, - "no-ex-assign": 2, - "no-extend-native": 2, - "no-extra-bind": 2, - "no-extra-boolean-cast": 2, - "no-extra-parens": [2, "functions"], - "no-extra-semi": 2, - "no-fallthrough": 2, - "no-floating-decimal": 2, - "no-func-assign": 2, - "no-implied-eval": 2, - "no-inline-comments": 2, - "no-inner-declarations": 2, - "no-invalid-regexp": 2, - "no-irregular-whitespace": 2, - "no-iterator": 2, - "no-label-var": 2, - "no-labels": 2, - "no-lone-blocks": 2, - "no-lonely-if": 2, - "no-loop-func": 2, - "no-mixed-requires": 2, - "no-mixed-spaces-and-tabs": 2, - "no-multi-spaces": 2, - "no-multi-str": 2, - "no-multiple-empty-lines": [2, {"max": 1}], - "no-native-reassign": 2, - "no-negated-in-lhs": 2, - "no-nested-ternary": 2, - "no-new": 2, - "no-new-func": 2, - "no-new-object": 2, - "no-new-require": 2, - "no-new-wrappers": 2, - "no-obj-calls": 2, - "no-octal": 2, - "no-octal-escape": 2, - "no-path-concat": 2, - "no-plusplus": 0, - "no-process-env": 0, - "no-process-exit": 2, - "no-proto": 2, - "no-redeclare": 2, - "no-regex-spaces": 2, - "no-restricted-modules": 0, - "no-return-assign": 2, - "no-script-url": 2, - "no-self-compare": 2, - "no-sequences": 2, - "no-shadow": 2, - "no-shadow-restricted-names": 2, - "no-spaced-func": 2, - "no-sparse-arrays": 2, - "no-sync": 0, - "no-ternary": 0, - "no-throw-literal": 2, - "no-trailing-spaces": 2, - "no-undef": 2, - "no-undef-init": 2, - "no-undefined": 0, - "no-underscore-dangle": 2, - "no-unreachable": 2, - "no-unused-expressions": 2, - "no-unused-vars": 2, - "no-use-before-define": [2, "nofunc"], - "no-void": 2, - "no-warning-comments": 1, - "no-with": 2, - "one-var": 0, - "operator-assignment": [2, "always"], - "padded-blocks": [2, "never"], - "quote-props": [2, "consistent-as-needed"], - "quotes": [2, "single"], - "radix": 2, - "semi": 2, - "semi-spacing": 2, - "sort-vars": 0, - "space-after-keywords": 2, - "space-before-blocks": 2, - "space-before-function-paren": [2, {"anonymous": "never", "named": "never"}], - "space-in-brackets": 0, - "space-in-parens": [2, "never"], - "space-infix-ops": 2, - "space-return-throw-case": 2, - "space-unary-ops": 2, - "spaced-comment": 2, - "strict": [2, "global"], - "use-isnan": 2, - "valid-jsdoc": [2, { - "requireParamDescription": false, - "requireReturnDescription": false, - "requireReturn": false - }], - "valid-typeof": 2, - "vars-on-top": 0, - "wrap-iife": [2, "any"], - "wrap-regex": 0, - "yoda": 2 - } -} diff --git a/javascript/.eslintrc-react b/javascript/.eslintrc-react deleted file mode 100644 index 257b001..0000000 --- a/javascript/.eslintrc-react +++ /dev/null @@ -1,24 +0,0 @@ -{ - "extends": "./.eslintrc", - "plugins": [ - "react" - ], - "ecmaFeatures": { - "jsx": true - }, - "rules": { - "react/jsx-boolean-value": 2, - "react/jsx-no-undef": 2, - "react/jsx-sort-props": 0, - "react/jsx-uses-react": 2, - "react/jsx-uses-vars": 2, - "react/no-did-mount-set-state": 2, - "react/no-did-update-set-state": 2, - "react/no-multi-comp": 2, - "react/no-unknown-property": 2, - "react/prop-types": 2, - "react/react-in-jsx-scope": 2, - "react/self-closing-comp": 2, - "react/wrap-multilines": 2 - } -} diff --git a/javascript/.jscsrc b/javascript/.jscsrc deleted file mode 100644 index b252e2b..0000000 --- a/javascript/.jscsrc +++ /dev/null @@ -1,101 +0,0 @@ -{ - "requireCurlyBraces": [ - "if", - "else", - "for", - "while", - "do" - ], - "requireSpaceAfterKeywords": [ - "if", - "else", - "for", - "while", - "do", - "switch", - "return", - "catch" - ], - "disallowKeywords": [ - "with" - ], - "disallowKeywordsOnNewLine": [ - "else", - "catch" - ], - - "disallowSpaceAfterPrefixUnaryOperators": true, - "disallowSpaceBeforePostfixUnaryOperators": [ - "++", - "--" - ], - "requireSpaceBeforeBinaryOperators": true, - "requireSpaceAfterBinaryOperators": true, - - "disallowSpacesInsideParentheses": true, - "disallowEmptyBlocks": true, - - "requireParenthesesAroundIIFE": true, - "requireSpacesInFunctionDeclaration": { - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInFunctionDeclaration": { - "beforeOpeningRoundBrace": true - }, - "requireSpacesInAnonymousFunctionExpression": { - "beforeOpeningCurlyBrace": true - }, - "disallowSpacesInNamedFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - "requireSpacesInNamedFunctionExpression": { - "beforeOpeningCurlyBrace": true - }, - - "requireSpacesInConditionalExpression": { - "afterTest": true, - "beforeConsequent": true, - "afterConsequent": true, - "beforeAlternate": true - }, - - "disallowSpaceBeforeBinaryOperators": [ - "," - ], - "requireCommaBeforeLineBreak": true, - - "validateQuoteMarks": "'", - "disallowMultipleLineStrings": true, - - "disallowImplicitTypeConversion": [ - "numeric", - "boolean", - "binary", - "string" - ], - "disallowYodaConditions": true, - - "disallowSpacesInsideArrayBrackets": true, - - "requireDotNotation": true, - "disallowSpaceAfterObjectKeys": true, - "disallowQuotedKeysInObjects": "allButReserved", - - "validateJSDoc": { - "checkParamNames": true, - "requireParamTypes": true - }, - - "maximumLineLength": { - "value": 120, - "allowUrlComments": true - }, - "requireSpaceAfterLineComment": true, - "requireLineFeedAtFileEnd": true, - "disallowMultipleLineBreaks": true, - "disallowMixedSpacesAndTabs": true, - "disallowTrailingWhitespace": true, - "validateLineBreaks": "LF", - - "excludeFiles": ["node_modules/**"] -} \ No newline at end of file diff --git a/javascript/.jshintrc b/javascript/.jshintrc deleted file mode 100644 index f89684b..0000000 --- a/javascript/.jshintrc +++ /dev/null @@ -1,35 +0,0 @@ -{ - "strict": true, /* Require all functions to run in ECMAScript 5's strict mode. */ - "curly": true, /* Always put curly braces around blocks in loops and conditionals. */ - "camelcase": true, /* Force all variable names to use either camelCase style or UPPER_CASE. */ - "undef": true, /* Prohibit the use of explicitly undeclared variables. */ - "latedef": "nofunc", /* Prohibit the use of a variable before it was defined. */ - "eqeqeq": true, /* Prohibit the use of == and != in favor of === and !==. */ - "browser": true, /* Define globals exposed by modern browsers. */ - "node": true, /* Defines NodeJS globals. */ - "es3": true, /* Disallows keywords as properties in objects (<= IE8) */ - "es5": false, /* Disables syntax first defined in the ECMAScript 5.1 specification. */ - "esnext": false, /* Disable ECMAScript 6 specific syntax. */ - "moz": false, /* Disable Mozilla JavaScript extensions. */ - "newcap": true, /* Requires you to capitalize names of constructor functions. */ - "quotmark": "single", /* Enforce use og single quotes. */ - "maxlen": 120, /* Set maximum line length to 120. */ - "indent": 4, /* Set indent level to 4 spaces. */ - "noarg": true, /* Prohibits the use of arguments.caller and arguments.callee */ - "bitwise": false, /* Prohibits the use of bitwise operators such as ^ (XOR), | (OR) and others */ - "unused": true, /* Don't allow unused variables */ - "globals": { - /* RequireJS */ - "define": false, - "require": false, - /* mocha */ - "describe" : false, - "it" : false, - "before" : false, - "beforeEach" : false, - "after" : false, - "afterEach" : false, - /* Allow JSON global even if IE7 doesn't support it (see "es3" option) */ - "JSON": false - } -} diff --git a/javascript/index.js b/javascript/index.js new file mode 100644 index 0000000..932f9e0 --- /dev/null +++ b/javascript/index.js @@ -0,0 +1,4 @@ +module.exports = { + 'extends': require.resolve('eslint-config-airbnb/base'), + 'rules': require('./override') +} diff --git a/javascript/legacy.js b/javascript/legacy.js new file mode 100644 index 0000000..1ddfc6d --- /dev/null +++ b/javascript/legacy.js @@ -0,0 +1,4 @@ +module.exports = { + 'extends': require.resolve('eslint-config-airbnb/legacy'), + 'rules': require('./override') +} diff --git a/javascript/override.js b/javascript/override.js new file mode 100644 index 0000000..6fe0cdc --- /dev/null +++ b/javascript/override.js @@ -0,0 +1,6 @@ +module.exports = { + 'indent': [2, 4, { 'SwitchCase': 1, 'VariableDeclarator': 1 }], + 'comma-dangle': [2, 'never'], + 'max-len': [2, 120, 4], + 'no-use-before-define': [2, { 'functions': false }] +}; diff --git a/javascript/package.json b/javascript/package.json index 81bd4ce..38bfb7e 100644 --- a/javascript/package.json +++ b/javascript/package.json @@ -22,5 +22,8 @@ "bugs": { "url": "https://github.com/vgno/coding-standards/issues" }, - "homepage": "https://github.com/vgno/coding-standards" + "homepage": "https://github.com/vgno/coding-standards", + "dependencies": { + "eslint-config-airbnb": "~6.1.0" + } } diff --git a/javascript/react.js b/javascript/react.js new file mode 100644 index 0000000..440ce54 --- /dev/null +++ b/javascript/react.js @@ -0,0 +1,4 @@ +module.exports = { + 'extends': require.resolve('eslint-config-airbnb'), + 'rules': require('./override') +}