Class: JSLint
- Inherits:
-
Object
- Object
- JSLint
- Defined in:
- lib/jslintrb-v8.rb
Overview
end
Instance Attribute Summary collapse
-
#adsafe ⇒ Object
if ADsafe should be enforced.
-
#bitwise ⇒ Object
if bitwise operators should not be allowed.
-
#browser ⇒ Object
if the standard browser globals should be predefined.
-
#cap ⇒ Object
if upper case HTML should be allowed.
-
#css ⇒ Object
if CSS workarounds should be tolerated.
-
#debug ⇒ Object
if debugger statements should be allowed.
-
#eqeqeq ⇒ Object
if === should be required.
-
#evil ⇒ Object
if eval should be allowed.
-
#forin ⇒ Object
if for in statements must filter.
-
#fragment ⇒ Object
if HTML fragments should be allowed.
-
#immed ⇒ Object
if immediate invocations must be wrapped in parens.
-
#laxbreak ⇒ Object
if line breaks should not be checked.
-
#newcap ⇒ Object
if constructor names must be capitalized.
-
#nomen ⇒ Object
if names should be checked.
-
#on ⇒ Object
if HTML event handlers should be allowed.
-
#onevar ⇒ Object
if only one var statement per function should be allowed.
-
#passfail ⇒ Object
if the scan should stop on first error.
-
#plusplus ⇒ Object
if increment/decrement should not be allowed.
-
#regexp ⇒ Object
if the .
-
#rhino ⇒ Object
if the Rhino environment globals should be predefined.
-
#safe ⇒ Object
if use of some browser features should be restricted.
-
#sidebar ⇒ Object
if the System object should be predefined.
-
#strict ⇒ Object
require the “use strict”; pragma.
-
#sub ⇒ Object
if all forms of subscript notation are tolerated.
-
#undef ⇒ Object
if variables should be declared before used.
-
#white ⇒ Object
if strict whitespace rules apply.
-
#widget ⇒ Object
if the Yahoo Widgets globals should be predefined.
Instance Method Summary collapse
- #check(input) ⇒ Object
-
#initialize(opts = {}) ⇒ JSLint
constructor
A new instance of JSLint.
Constructor Details
#initialize(opts = {}) ⇒ JSLint
Returns a new instance of JSLint.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/jslintrb-v8.rb', line 100 def initialize(opts = {}) @adsafe = opts.fetch( :adsafe ){ false } @bitwise = opts.fetch( :bitwise ){ true } @browser = opts.fetch( :browser ){ false } @cap = opts.fetch( :cap ){ false } @css = opts.fetch( :css ){ false } @debug = opts.fetch( :debug ){ false } @eqeqeq = opts.fetch( :eqeqeq ){ true } @evil = opts.fetch( :evil ){ false } @forin = opts.fetch( :forin ){ false } @fragment = opts.fetch( :fragment ){ false } @immed = opts.fetch( :immed ){ true } @laxbreak = opts.fetch( :laxbreak ){ false } @newcap = opts.fetch( :newcap ){ true } @nomen = opts.fetch( :nomen ){ true } @on = opts.fetch( :on ){ false } @onevar = opts.fetch( :onevar ){ true } @passfail = opts.fetch( :passfail ){ false } @plusplus = opts.fetch( :plusplus ){ true } @regexp = opts.fetch( :regexp ){ true } @rhino = opts.fetch( :rhino ){ false } @undef = opts.fetch( :undef ){ true } @safe = opts.fetch( :safe ){ false } @sidebar = opts.fetch( :sidebar ){ false } @strict = opts.fetch( :strict ){ true } @sub = opts.fetch( :sub ){ false } @white = opts.fetch( :white ){ false } @widget = opts.fetch( :widget ){ false } end |
Instance Attribute Details
#adsafe ⇒ Object
if ADsafe should be enforced
46 47 48 |
# File 'lib/jslintrb-v8.rb', line 46 def adsafe @adsafe end |
#bitwise ⇒ Object
if bitwise operators should not be allowed
48 49 50 |
# File 'lib/jslintrb-v8.rb', line 48 def bitwise @bitwise end |
#browser ⇒ Object
if the standard browser globals should be predefined
50 51 52 |
# File 'lib/jslintrb-v8.rb', line 50 def browser @browser end |
#cap ⇒ Object
if upper case HTML should be allowed
52 53 54 |
# File 'lib/jslintrb-v8.rb', line 52 def cap @cap end |
#css ⇒ Object
if CSS workarounds should be tolerated
54 55 56 |
# File 'lib/jslintrb-v8.rb', line 54 def css @css end |
#debug ⇒ Object
if debugger statements should be allowed
56 57 58 |
# File 'lib/jslintrb-v8.rb', line 56 def debug @debug end |
#eqeqeq ⇒ Object
if === should be required
58 59 60 |
# File 'lib/jslintrb-v8.rb', line 58 def eqeqeq @eqeqeq end |
#evil ⇒ Object
if eval should be allowed
60 61 62 |
# File 'lib/jslintrb-v8.rb', line 60 def evil @evil end |
#forin ⇒ Object
if for in statements must filter
62 63 64 |
# File 'lib/jslintrb-v8.rb', line 62 def forin @forin end |
#fragment ⇒ Object
if HTML fragments should be allowed
64 65 66 |
# File 'lib/jslintrb-v8.rb', line 64 def fragment @fragment end |
#immed ⇒ Object
if immediate invocations must be wrapped in parens
66 67 68 |
# File 'lib/jslintrb-v8.rb', line 66 def immed @immed end |
#laxbreak ⇒ Object
if line breaks should not be checked
68 69 70 |
# File 'lib/jslintrb-v8.rb', line 68 def laxbreak @laxbreak end |
#newcap ⇒ Object
if constructor names must be capitalized
70 71 72 |
# File 'lib/jslintrb-v8.rb', line 70 def newcap @newcap end |
#nomen ⇒ Object
if names should be checked
72 73 74 |
# File 'lib/jslintrb-v8.rb', line 72 def nomen @nomen end |
#on ⇒ Object
if HTML event handlers should be allowed
74 75 76 |
# File 'lib/jslintrb-v8.rb', line 74 def on @on end |
#onevar ⇒ Object
if only one var statement per function should be allowed
76 77 78 |
# File 'lib/jslintrb-v8.rb', line 76 def onevar @onevar end |
#passfail ⇒ Object
if the scan should stop on first error
78 79 80 |
# File 'lib/jslintrb-v8.rb', line 78 def passfail @passfail end |
#plusplus ⇒ Object
if increment/decrement should not be allowed
80 81 82 |
# File 'lib/jslintrb-v8.rb', line 80 def plusplus @plusplus end |
#regexp ⇒ Object
if the . should not be allowed in regexp literals
82 83 84 |
# File 'lib/jslintrb-v8.rb', line 82 def regexp @regexp end |
#rhino ⇒ Object
if the Rhino environment globals should be predefined
84 85 86 |
# File 'lib/jslintrb-v8.rb', line 84 def rhino @rhino end |
#safe ⇒ Object
if use of some browser features should be restricted
88 89 90 |
# File 'lib/jslintrb-v8.rb', line 88 def safe @safe end |
#sidebar ⇒ Object
if the System object should be predefined
90 91 92 |
# File 'lib/jslintrb-v8.rb', line 90 def @sidebar end |
#strict ⇒ Object
require the “use strict”; pragma
92 93 94 |
# File 'lib/jslintrb-v8.rb', line 92 def strict @strict end |
#sub ⇒ Object
if all forms of subscript notation are tolerated
94 95 96 |
# File 'lib/jslintrb-v8.rb', line 94 def sub @sub end |
#undef ⇒ Object
if variables should be declared before used
86 87 88 |
# File 'lib/jslintrb-v8.rb', line 86 def undef @undef end |
#white ⇒ Object
if strict whitespace rules apply
96 97 98 |
# File 'lib/jslintrb-v8.rb', line 96 def white @white end |
#widget ⇒ Object
if the Yahoo Widgets globals should be predefined
98 99 100 |
# File 'lib/jslintrb-v8.rb', line 98 def @widget end |
Instance Method Details
#check(input) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/jslintrb-v8.rb', line 130 def check(input) V8::Context.new do |context| context.load(File.join(File.dirname(__FILE__), 'jslintrb-v8', 'jslint.js')) context['JSLintRBinput'] = input context['JSLintRBadsafe'] = @adsafe context['JSLintRBbitwise'] = @bitwise context['JSLintRBbrowser'] = @browser context['JSLintRBcap'] = @cap context['JSLintRBcss'] = @css context['JSLintRBdebug'] = @debug context['JSLintRBeqeqeq'] = @eqeqeq context['JSLintRBevil'] = @evil context['JSLintRBforin'] = @forin context['JSLintRBfragment'] = @fragment context['JSLintRBimmed'] = @immed context['JSLintRBlaxbreak'] = @laxbreak context['JSLintRBnewcap'] = @newcap context['JSLintRBnomen'] = @nomen context['JSLintRBon'] = @on context['JSLintRBonevar'] = @onevar context['JSLintRBpassfail'] = @passfail context['JSLintRBplusplus'] = @plusplus context['JSLintRBregexp'] = @regexp context['JSLintRBrhino'] = @rhino context['JSLintRBundef'] = @undef context['JSLintRBsafe'] = @safe context['JSLintRBsidebar'] = @sidebar context['JSLintRBstrict'] = @strict context['JSLintRBsub'] = @sub context['JSLintRBwhite'] = @white context['JSLintRBwidget'] = @widget context.eval %{ JSLINT(JSLintRBinput, { adsafe : JSLintRBadsafe, bitwise : JSLintRBbitwise, browser : JSLintRBbrowser, cap : JSLintRBcap, css : JSLintRBcss, debug : JSLintRBdebug, eqeqeq : JSLintRBeqeqeq, evil : JSLintRBevil, forin : JSLintRBforin, fragment : JSLintRBfragment, immed : JSLintRBimmed, laxbreak : JSLintRBlaxbreak, newcap : JSLintRBnewcap, nomen : JSLintRBnomen, on : JSLintRBon, onevar : JSLintRBonevar, passfail : JSLintRBpassfail, plusplus : JSLintRBplusplus, regexp : JSLintRBregexp, rhino : JSLintRBrhino, undef : JSLintRBundef, safe : JSLintRBsafe, sidebar : JSLintRBsidebar, strict : JSLintRBstrict, sub : JSLintRBsub, white : JSLintRBwhite, widget : JSLintRBwidget }); } errors = context['JSLINT'].errors.inject("") do |output, error| output += "Error at line #{error['line'].to_i + 1} " + "character #{error['character'].to_i + 1}: #{error['reason']}\n" + " #{error['evidence']}" output end if errors.empty? return nil else return errors end end end |