Permalink
Browse files

make jslint settings more sane

we use jslint just as a last resort effort to make
sure our javascript doesn't have syntax errors or
something.  these changes will make the jenkins
output less verbose.

Change-Id: I937ad1bc6f6b142c4ba424f65e72e9806468638f
Reviewed-on: https://gerrit.instructure.com/12787
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Ryan Shaw <ryan@instructure.com>
  • Loading branch information...
1 parent fe603e2 commit 723d9c7e6d69a45eb388903632196be933ab3dc0 @ryankshaw ryankshaw committed Aug 7, 2012
Showing with 34 additions and 21 deletions.
  1. +16 −7 .jshintrc
  2. +14 −10 config/jslint.conf
  3. +2 −2 lib/tasks/canvas.rake
  4. +1 −1 public/javascripts/gradebook_uploads.js
  5. +1 −1 public/javascripts/user_utils.js
View
@@ -1,11 +1,20 @@
{
+ "predef": [
+ "INST", "define", "require", "ENV"
+ ],
"browser": true,
- "onevar": false,
+ "devel": true,
"jquery": true,
- "asi": true,
- "plusplus": false,
- "curly": true,
- "forin": true,
- "strict": false,
- "undef": true
+ "asi": true, // This option suppresses warnings about missing semicolons.
+ "plusplus": false, // This option prohibits the use of unary increment and decrement operators
+ "curly": false, // This option requires you to always put curly braces around blocks in loops and conditionals
+ "forin": false, // This option requires all for in loops to filter object's items.
+ "undef": true, // This option prohibits the use of explicitly undeclared variables. This option is very useful for spotting leaking and mistyped variables.
+ "unused": true, // This option warns when you define and never use your variables. It is very useful for general code cleanup, especially when used in addition to undef.
+ "camelcase": true, //This option allows you to force all variable names to use either camelCase style or UPPER_CASE with underscores.
+ "eqeqeq":true, // This options prohibits the use of == and != in favor of === and !==. The former try to coerce values before comparing them which can lead to some unexpected results
+ "indent": 2, // This option enforces specific tab width for your code.
+ "latedef": true, // This option prohibits the use of a variable before it was defined
+ "immed": true, // This option prohibits the use of immediate function invocations without wrapping them in parentheses. Wrapping parentheses assists readers of your code in understanding that the expression is the result of a function, and not the function itself.
+ "boss": true // This option suppresses warnings about the use of assignments in cases where comparisons are expected. More often than not, code like if (a = 10) {} is a typo.
}
View
@@ -16,19 +16,19 @@
-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
+-missing_semicolon # missing semicolon
+meaningless_block # meaningless block; curly braces have no impact
-+comma_separated_stmts # multiple statements separated by commas (use semicolons?)
+-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
+-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
+-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
+-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
@@ -39,7 +39,7 @@
+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_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
@@ -50,7 +50,9 @@
+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
+-parseint_missing_radix # parseInt missing radix parameter
+
+
### Output format
@@ -111,10 +113,12 @@
# (Use this in conjunction with the "undeclared identifier" warning.)
#
# Common uses for webpages might be:
-+define window
-+define document
+define $
+define jQuery
++define require
++define define
++define INST
++define ENV
### Files
# Specify which files to lint
View
@@ -35,11 +35,11 @@ def check_syntax(files)
end
raise "jsl needs to be in your $PATH, download from: javascriptlint.com" if `which jsl`.empty?
- puts " --> Checking #{js_file} using jsl:"
jsl_output = `jsl -process "#{file_path}" -nologo -conf "#{File.join(Rails.root, 'config', 'jslint.conf')}"`
exit_status = $?.exitstatus
if exit_status != 0
- if jsl_output.match("warning: trailing comma is not legal in ECMA-262 object initializers")
+ puts " --> Error checking #{js_file} using jsl:"
+ if jsl_output.match("warning: trailing comma is not legal in ECMA-262 object initializers") || jsl_output.match("extra comma is not recommended in array initializers")
exit_status = 2
jsl_output << "fatal trailing comma found. Stupid IE!"
end
@@ -24,7 +24,7 @@ define([
'vendor/slickgrid-googlecode/slick.editors',
'jquery.instructure_forms' /* errorBox */,
'jquery.instructure_misc_helpers' /* /\.detect/ */,
- 'jquery.templateData' /* fillTemplateData */,
+ 'jquery.templateData' /* fillTemplateData */
], function(I18n, $, _, htmlEscape, SlickGrid) {
var GradebookUploader = {
@@ -47,7 +47,7 @@ return {
// Use prior information on the last name to try and reconstruct it
// This just checks if prior_surname was provided, and if it matches
// the trailing words of given_parts
- if (!surname && prior_surname && !/^\s*$/.test(prior_surname) &&
+ if (!surname && prior_surname && !(/^\s*$/).test(prior_surname) &&
(prior_surname_parts = prior_surname.split(/\s+/)) &&
given_parts.length >= prior_surname_parts.length &&
given_parts.slice(given_parts.length - prior_surname_parts.length).join(' ') === prior_surname_parts.join(' ')) {

0 comments on commit 723d9c7

Please sign in to comment.