Skip to content

Commit

Permalink
Add settings for ESLint
Browse files Browse the repository at this point in the history
- .eslintrc.js was generated with 'eslint --init' first and then modified. We start with a minimum setting that fix indentation and will expand it gradually to make code cleaner.
- You can run ESLint for 'src/' and 'test/' directories by 'npm run lint'.
- 'npm run lint' is run on Travis CI before compilation by Closure Compiler ('npm run build').
  • Loading branch information
kwkbtr committed Aug 16, 2016
1 parent 0aa0c29 commit 31238bf
Show file tree
Hide file tree
Showing 4 changed files with 250 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/wrapper.js
src/closure
245 changes: 245 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
module.exports = {
"env": {
"browser": true,
"jasmine": true
},
"globals": {
"adapt": false,
"goog": false,
"vivliostyle": false
},
// "extends": "eslint:recommended",
"rules": {
// Possible Errors
// (in recommended)
// "no-constant-condition": [
// "error",
// {
// "checkLoops": false
// }
// ],
// "no-inner-declarations": [
// "error",
// "functions"
// ],
// (not in recommended)
// "no-extra-parens": "off",
// "no-prototype-builtins": "off",
// "no-template-curly-in-string": "error",
// "no-unsafe-negation": "error",
// "valid-jsdoc": "off",

// Best Practices
// (not in recommended)
// "accessor-pairs": "error",
// "array-callback-return": "error",
// "block-scoped-var": "off",
// "complexity": "off",
// "consistent-return": "error",
// "curly": "off",
// "default-case": "off",
// "dot-location": [
// "error",
// "property"
// ],
// "dot-notation": "off",
// "eqeqeq": "off",
// "guard-for-in": "off",
// "no-alert": "error",
// "no-caller": "error",
// "no-div-regex": "error",
// "no-else-return": "off",
// "no-empty-function": "off",
// "no-eq-null": "off",
// "no-eval": "error",
// "no-extend-native": "error",
// "no-extra-bind": "error",
// "no-extra-label": "error",
// "no-floating-decimal": "error",
// "no-global-assign": "error",
// "no-implicit-globals": "off",
// "no-implied-eval": "error",
// "no-invalid-this": "error",
// "no-iterator": "error",
// "no-labels": [
// "error",
// {
// "allowLoop": true,
// "allowSwitch": true
// }
// ],
// "no-lone-blocks": "error",
// "no-loop-func": "off",
// "no-magic-numbers": "off",
// "no-multi-spaces": "off",
// "no-multi-str": "error",
// "no-new-func": "error",
// "no-new-wrappers": "error",
// "no-new": "error",
// "no-octal-escape": "error",
// "no-param-reassign": "off",
// "no-proto": "error",
// "no-return-assign": "off",
// "no-script-url": "error",
// "no-self-compare": "error",
// "no-sequences": "off",
// "no-throw-literal": "off",
// "no-unmodified-loop-condition": "off",
// "no-unused-expressions": "off",
// "no-useless-call": "error",
// "no-useless-concat": "error",
// "no-useless-escape": "off",
// "no-void": "error",
// "no-warning-comments": "off",
// "no-with": "error",
// "radix": [
// "error",
// "always"
// ],
// "vars-on-top": "off",

// Strict Mode
// (not in recommended)
// "strict": "off",

// Variables
// (not in recommended)
// "init-declarations": "off",
// "no-catch-shadow": "error",
// "no-label-var": "error",
// "no-restricted-globals": "error",
// "no-shadow-restricted-names": "error",
// "no-shadow": "off",
// "no-undef-init": "error",
// "no-undefined": "off",
// "no-use-before-define": "off",

// Node.js and CommonJS
// (not in recommended)
// "callback-return": "off",
// "global-require": "error",
// "handle-callback-err": "error",
// "no-mixed-requires": "error",
// "no-new-require": "error",
// "no-path-concat": "error",
// "no-process-env": "error",
// "no-process-exit": "error",
// "no-restricted-modules": "error",
// "no-sync": "error",

// Stylistic Issues
// (in recommended)
"no-mixed-spaces-and-tabs": "warn",
// (not in recommended)
// "array-bracket-spacing": [
// "error",
// "never"
// ],
// "block-spacing": "off",
// "brace-style": "off",
// "camelcase": "off",
// "comma-dangle": "error",
// "comma-spacing": "off",
// "comma-style": [
// "error",
// "last"
// ],
// "computed-property-spacing": "off",
// "consistent-this": "off",
"eol-last": "warn",
// "func-call-spacing": [
// "error",
// "never"
// ],
// "func-names": [
// "error",
// "never"
// ],
// "func-style": "off",
// "id-blacklist": "error",
// "id-length": "off",
// "id-match": "error",
"indent": [
"warn",
4,
{
"SwitchCase": 1
}
],
// "jsx-quotes": "error",
// "key-spacing": "off",
// "keyword-spacing": "off",
"linebreak-style": [
"error",
"unix"
],
// "lines-around-comment": "off",
// "max-depth": "off",
// "max-len": "off",
// "max-lines": "off",
// "max-nested-callbacks": "error",
// "max-params": "off",
// "max-statements-per-line": "off",
// "max-statements": "off",
// "multiline-ternary": "off",
// "new-parens": "error",
// "newline-after-var": "off",
// "newline-before-return": "off",
// "newline-per-chained-call": "off",
// "no-array-constructor": "error",
// "no-bitwise": "off",
// "no-continue": "off",
// "no-inline-comments": "off",
// "no-lonely-if": "off",
// "no-mixed-operators": "off",
// "no-multiple-empty-lines": "off",
// "no-negated-condition": "off",
// "no-nested-ternary": "off",
// "no-new-object": "error",
// "no-plusplus": "off",
// "no-restricted-syntax": "error",
// "no-tabs": "off",
// "no-ternary": "off",
"no-trailing-spaces": "warn",
// "no-underscore-dangle": "off",
// "no-unneeded-ternary": [
// "error",
// {
// "defaultAssignment": true
// }
// ],
// "no-whitespace-before-property": "error",
// "object-curly-newline": "off",
// "object-curly-spacing": "off",
// "object-property-newline": "off",
// "one-var-declaration-per-line": "off",
// "one-var": "off",
// "operator-assignment": "off",
// "operator-linebreak": "off",
// "padded-blocks": "off",
// "quote-props": "off",
// "quotes": "off",
// "require-jsdoc": "off",
// "semi-spacing": "off",
// "semi": "off",
// "sort-keys": "off",
// "sort-vars": "off",
// "space-before-blocks": "off",
// "space-before-function-paren": "off",
// "space-in-parens": "off",
// "space-infix-ops": "off",
// "space-unary-ops": [
// "error",
// {
// "nonwords": false,
// "words": false
// }
// ],
// "spaced-comment": "off",
// "unicode-bom": [
// "error",
// "never"
// ],
// "wrap-regex": "error",
}
};
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ before_install:
- sudo pip install virtualenv
script:
- build/update-version.sh
- npm run lint
- npm run build
- npm test
- build/wpt-sauce.sh
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2016.7.1-pre",
"description": "Library for web sites with rich paged viewing and EPUB support, shared with Vivliostyle Formatter & Browser",
"scripts": {
"lint": "eslint src test",
"build": "mkdirp lib && java -jar node_modules/google-closure-compiler/compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --language_in ECMASCRIPT5 --warning_level VERBOSE --output_wrapper_file src/wrapper.js --externs src/externs.js --js_output_file lib/vivliostyle.min.js src/closure/goog/base.js src/closure/goog/*/*.js src/adapt/*.js src/vivliostyle/*.js",
"test": "karma start test/conf/karma-sauce.conf.js",
"test:local": "karma start test/conf/karma-local.conf.js"
Expand All @@ -26,6 +27,7 @@
"main": "lib/vivliostyle.min.js",
"homepage": "https://github.com/vivliostyle/vivliostyle.js",
"devDependencies": {
"eslint": "^3.3.1",
"google-closure-compiler": "^20150315.0.2",
"jasmine-core": "^2.3.4",
"karma": "^0.13.7",
Expand Down

0 comments on commit 31238bf

Please sign in to comment.