[Pkg-javascript-commits] [backbone] 74/173: Enable ESLint

Jonas Smedegaard dr at jones.dk
Wed Aug 31 07:44:04 UTC 2016


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository backbone.

commit bf0527897f8fda9f3133dd8a980913e6ad4c03fb
Author: Jordan Eldredge <jordan at jordaneldredge.com>
Date:   Tue Dec 15 15:30:17 2015 -0800

    Enable ESLint
    
    This pull request replaces the old "jsl" linter with ESLint and enables it as
    part of our integration tests.
    
    So far, the only rules it includes are the ones which are both currently
    enforced in Underscore AND are already passing in Backbone.
    
    I will follow up with individual pull requests for each rule which will require
    changes to the code in an attempt to bring us in sync with Underscore's style.
---
 .eslintrc      | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 docs/jsl.conf  | 44 ------------------------------------
 package.json   |  5 +++--
 test/.eslintrc | 24 ++++++++++++++++++++
 4 files changed, 98 insertions(+), 46 deletions(-)

diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 0000000..378ed32
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,71 @@
+{
+  "env": {
+    "browser": true,
+    "node": true,
+    "amd": true
+  },
+
+  "rules": {
+    "array-bracket-spacing": [2],
+    "camelcase": 2,
+    "comma-dangle": [2, "never"],
+    "comma-spacing": 2,
+    "computed-property-spacing": [2, "never"],
+    "eol-last": 2,
+    "linebreak-style": 2,
+    "max-depth": [1, 4],
+    "max-params": [1, 5],
+    "no-alert": 2,
+    "no-caller": 2,
+    "no-catch-shadow": 2,
+    "no-console": 2,
+    "no-debugger": 2,
+    "no-delete-var": 2,
+    "no-div-regex": 1,
+    "no-dupe-args": 2,
+    "no-dupe-keys": 2,
+    "no-duplicate-case": 2,
+    "no-else-return": 1,
+    "no-empty-character-class": 2,
+    "no-empty-label": 2,
+    "no-eval": 2,
+    "no-ex-assign": 2,
+    "no-extend-native": 2,
+    "no-extra-boolean-cast": 2,
+    "no-extra-semi": 2,
+    "no-fallthrough": 2,
+    "no-floating-decimal": 2,
+    "no-func-assign": 2,
+    "no-implied-eval": 2,
+    "no-inner-declarations": 2,
+    "no-irregular-whitespace": 2,
+    "no-label-var": 2,
+    "no-lone-blocks": 2,
+    "no-multi-str": 2,
+    "no-native-reassign": 2,
+    "no-negated-in-lhs": 1,
+    "no-new-object": 2,
+    "no-new-wrappers": 2,
+    "no-obj-calls": 2,
+    "no-octal": 2,
+    "no-octal-escape": 2,
+    "no-proto": 2,
+    "no-redeclare": 2,
+    "no-spaced-func": 2,
+    "no-throw-literal": 2,
+    "no-trailing-spaces": 2,
+    "no-undef-init": 2,
+    "no-undefined": 2,
+    "no-unneeded-ternary": 2,
+    "no-unreachable": 2,
+    "no-with": 2,
+    "quotes": [2, "single", "avoid-escape"],
+    "radix": 2,
+    "semi": 2,
+    "space-infix-ops": 2,
+    "space-return-throw-case": 2,
+    "space-unary-ops": [2, { "words": true, "nonwords": false }],
+    "use-isnan": 2,
+    "valid-typeof": 2
+  }
+}
diff --git a/docs/jsl.conf b/docs/jsl.conf
deleted file mode 100644
index cc52566..0000000
--- a/docs/jsl.conf
+++ /dev/null
@@ -1,44 +0,0 @@
-# JavaScriptLint configuration file for Backbone.
-
-+no_return_value              # function {0} does not always return a value
-+duplicate_formal             # duplicate formal argument {0}
--equal_as_assign              # test for equality (==) mistyped as assignment (=)?{0}
-+var_hides_arg                # variable {0} hides argument
-+redeclared_var               # redeclaration of {0} {1}
--anon_no_return_value         # anonymous function does not always return a value
-+missing_semicolon            # missing semicolon
-+meaningless_block            # meaningless block; curly braces have no impact
--comma_separated_stmts        # multiple statements separated by commas (use semicolons?)
-+unreachable_code             # unreachable code
-+missing_break                # missing break statement
-+missing_break_for_last_case  # missing break statement for last case in switch
--comparison_type_conv         # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
--inc_dec_within_stmt          # increment (++) and decrement (--) operators used as part of greater statement
--useless_void                 # use of the void type may be unnecessary (void is always undefined)
-+multiple_plus_minus          # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs
-+use_of_label                 # use of label
--block_without_braces         # block statement without curly braces
-+leading_decimal_point        # leading decimal point may indicate a number or an object member
-+trailing_decimal_point       # trailing decimal point may indicate a number or an object member
-+octal_number                 # leading zeros make an octal number
-+nested_comment               # nested comment
-+misplaced_regex              # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma
--ambiguous_newline            # unexpected end of line; it is ambiguous whether these lines are part of the same statement
-+empty_statement              # empty statement or extra semicolon
--missing_option_explicit      # the "option explicit" control comment is missing
-+partial_option_explicit      # the "option explicit" control comment, if used, must be in the first script tag
-+dup_option_explicit          # duplicate "option explicit" control comment
-+useless_assign               # useless assignment
-+ambiguous_nested_stmt        # block statements containing block statements should use curly braces to resolve ambiguity
-+ambiguous_else_stmt          # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent)
--missing_default_case         # missing default case in switch statement
-+duplicate_case_in_switch     # duplicate case in switch statements
-+default_not_at_end           # the default case is not at the end of the switch statement
-+legacy_cc_not_understood     # couldn't understand control comment using /*@keyword@*/ syntax
-+jsl_cc_not_understood        # couldn't understand control comment using /*jsl:keyword*/ syntax
-+useless_comparison           # useless comparison; comparing identical expressions
-+with_statement               # with statement hides undeclared variables; use temporary variable instead
-+trailing_comma_in_array      # extra comma is not recommended in array initializers
-+assign_to_function_call      # assignment to a function call
-+parseint_missing_radix       # parseInt missing radix parameter
-+lambda_assign_requires_semicolon
diff --git a/package.json b/package.json
index 85e5d04..fadcff0 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,7 @@
   "devDependencies": {
     "coffee-script": "1.7.1",
     "docco": "0.7.0",
+    "eslint": "1.10.x",
     "karma": "^0.13.13",
     "karma-phantomjs-launcher": "^0.1.4",
     "karma-qunit": "^0.1.5",
@@ -17,10 +18,10 @@
     "uglify-js": "^2.4.17"
   },
   "scripts": {
-    "test": "karma start && coffee test/model.coffee",
+    "test": "karma start && coffee test/model.coffee && npm run lint",
     "build": "uglifyjs backbone.js --mangle --source-map backbone-min.map -o backbone-min.js",
     "doc": "docco backbone.js && docco examples/todos/todos.js examples/backbone.localStorage.js",
-    "lint": "jsl -nofilelisting -nologo -conf docs/jsl.conf -process backbone.js"
+    "lint": "eslint backbone.js test/*.js"
   },
   "main"          : "backbone.js",
   "version"       : "1.2.3",
diff --git a/test/.eslintrc b/test/.eslintrc
new file mode 100644
index 0000000..50c9972
--- /dev/null
+++ b/test/.eslintrc
@@ -0,0 +1,24 @@
+{
+  "env": {
+    "browser": true
+  },
+  "globals": {
+    "QUnit": false
+  },
+  "rules": {
+    "array-bracket-spacing": 0,
+    "brace-style": 0,
+    "camelcase": 0,
+    "comma-spacing": 0,
+    "no-extend-native": 0,
+    "no-new-wrappers": 0,
+    "no-spaced-func": 0,
+    "no-sparse-arrays": 0,
+    "no-throw-literal": 0,
+    "no-undefined": 0,
+    "quote-props": 0,
+    "quotes": 0,
+    "semi": 0,
+    "space-before-function-paren": 0
+  }
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list