Merge pull request #1523 from ajaxorg/jshint

update jshint to 2.1.4
This commit is contained in:
Lennart Kats 2013-07-23 00:19:43 -07:00
commit a4a30b6665
8 changed files with 6807 additions and 5773 deletions

View file

@ -520,10 +520,10 @@ new StatusBar(env.editor, cmdLine.container);
var Emmet = require("ace/ext/emmet"); var Emmet = require("ace/ext/emmet");
net.loadScript("https://rawgithub.com/nightwing/emmet-core/master/emmet.js", function() { net.loadScript("http://nightwing.github.io/emmet-core/emmet.js", function() {
Emmet.setCore(window.emmet); Emmet.setCore(window.emmet);
env.editor.setOption("enableEmmet", true); env.editor.setOption("enableEmmet", true);
}) });
// require("ace/placeholder").PlaceHolder; // require("ace/placeholder").PlaceHolder;

View file

@ -145,11 +145,11 @@ var docs = {
"docs/assembly_x86.asm": "Assembly_x86", "docs/assembly_x86.asm": "Assembly_x86",
"docs/autohotkey.ahk": "AutoHotKey", "docs/autohotkey.ahk": "AutoHotKey",
"docs/batchfile.bat": "BatchFile", "docs/batchfile.bat": "BatchFile",
"docs/erlang/erl": "Erlang", "docs/erlang.erl": "Erlang",
"docs/forth.frt": "Forth", "docs/forth.frt": "Forth",
"docs/haskell.hs": "Haskell", "docs/haskell.hs": "Haskell",
"docs/julia.js": "Julia", "docs/julia.js": "Julia",
"docs/prolog/plg": "Prolog", "docs/prolog.plg": "Prolog",
"docs/rust.rs": "Rust", "docs/rust.rs": "Rust",
"docs/twig.twig": "Twig" "docs/twig.twig": "Twig"
}; };

File diff suppressed because it is too large Load diff

View file

@ -79,8 +79,8 @@ oop.inherits(JavaScriptWorker, Mirror);
this.options = options || { this.options = options || {
// undef: true, // undef: true,
// unused: true, // unused: true,
es5: true,
esnext: true, esnext: true,
moz: true,
devel: true, devel: true,
browser: true, browser: true,
node: true, node: true,

View file

@ -91,11 +91,11 @@ module.exports = {
"test for each": function() { "test for each": function() {
var worker = new JavaScriptWorker(this.sender); var worker = new JavaScriptWorker(this.sender);
worker.setValue("for each(var i in x)'"); worker.setValue("for each(var i in x)");
worker.deferredUpdate.call(); worker.deferredUpdate.call();
var error = this.sender.events[0][1][0]; var error = this.sender.events[0][1][0];
assert.equal(error.text, "Expected '(' and instead saw 'each'."); assert.equal(error.text, "Unexpected early end of program.");
} }
}; };

View file

@ -469,10 +469,10 @@ var SnippetManager = function() {
var snippetNameMap = this.snippetNameMap; var snippetNameMap = this.snippetNameMap;
function removeSnippet(s) { function removeSnippet(s) {
var map = snippetNameMap[scope]; var nameMap = snippetNameMap[s.scope||scope];
if (map && map[s.name]) { if (nameMap && nameMap[s.name]) {
delete map[s.name]; delete nameMap[s.name];
map = snippetMap[scope]; var map = snippetMap[s.scope||scope];
var i = map && map.indexOf(s); var i = map && map.indexOf(s);
if (i >= 0) if (i >= 0)
map.splice(i, 1); map.splice(i, 1);

View file

@ -4,17 +4,15 @@ if (typeof window.window != "undefined" && window.document) {
return; return;
} }
window.console = { window.console = function() {
log: function() { var msgs = Array.prototype.slice.call(arguments, 0);
var msgs = Array.prototype.slice.call(arguments, 0); postMessage({type: "log", data: msgs});
postMessage({type: "log", data: msgs});
},
error: function() {
var msgs = Array.prototype.slice.call(arguments, 0);
postMessage({type: "log", data: msgs});
},
trace: function() {}
}; };
window.console.error =
window.console.warn =
window.console.log =
window.console.trace = window.console;
window.window = window; window.window = window;
window.ace = window; window.ace = window;

View file

@ -3,195 +3,178 @@ var https = require("https")
, url = require("url") , url = require("url")
, fs = require("fs"); , fs = require("fs");
var async = require("asyncjs");
var rootDir = __dirname + "/../lib/ace/"; var rootDir = __dirname + "/../lib/ace/";
var deps = [{ var deps = [{
path: "mode/css/csslint.js", path: "mode/css/csslint.js",
url: "https://raw.github.com/stubbornella/csslint/master/release/csslint-node.js", url: "https://raw.github.com/stubbornella/csslint/master/release/csslint-node.js",
needsFixup: true needsFixup: true
}, { }, {
path: "../../demo/kitchen-sink/require.js", path: "../../demo/kitchen-sink/require.js",
url: "https://raw.github.com/jrburke/requirejs/master/require.js", url: "https://raw.github.com/jrburke/requirejs/master/require.js",
needsFixup: false needsFixup: false
}, { }, {
path: "mode/lua/luaparse.js", path: "mode/lua/luaparse.js",
url: "https://raw.github.com/oxyc/luaparse/master/luaparse.js", url: "https://raw.github.com/oxyc/luaparse/master/luaparse.js",
needsFixup: true, needsFixup: true,
postProcess: function(src) { postProcess: function(src) {
return src.replace( return src.replace(
/\(function\s*\(root,\s*name,\s*factory\)\s*{[\s\S]*?}\(this,\s*'luaparse',/, /\(function\s*\(root,\s*name,\s*factory\)\s*{[\s\S]*?}\(this,\s*'luaparse',/,
"(function (root, name, factory) {\n factory(exports)\n}(this, 'luaparse'," "(function (root, name, factory) {\n factory(exports)\n}(this, 'luaparse',"
) )
} }
}, {
path: "mode/javascript/jshint.js",
url: "http://jshint.com/get/jshint-2.1.4.js",
needsFixup: true,
postProcess: function(src) {
src = src.replace(/(\],|\{)((?:\d+|"\w+"):\[)/g, "$1\n$2")
.replace(/^(\},)(\{[^{}\[\]]*?\}\])/gm, "$1\n$2")
src = src.replace(
/"Expected a conditional expression and instead saw an assignment."/g,
'"Assignment in conditional expression"'
);
src = src.replace(/\brequire\(["']|\(require,|\(require\)/g, function(r){
return r.replace("require", "req");
})
src = src.replace(/var defaultMaxListeners = 10;/, function(a) {return a.replace("10", "200")});
src = src.replace(/var JSHINT;\s*\(function[\s()]+\{\s*/, "")
.replace(/JSHINT = .*\n\s*\}\(\)\);\s*/, "");
src += '\n'
+ 'function req() {return require.apply(this, arguments)}\n'
+ 'module.exports = req("jshint");\n';
return src;
}
}, {
path: "ext/emmet-core.js",
url: [
"https://raw.github.com/sergeche/emmet-sublime/master/emmet/emmet-app.js",
"https://raw.github.com/sergeche/emmet-sublime/master/emmet/snippets.json"
],
postProcess: function(data) {
return data[0]
.replace("define(emmet)", "define('emmet', [], emmet)")
.replace(/(emmet.define\('bootstrap'.*)[\s\S]*$/, function(_, x) {
return x + "\n" +
"var snippets = " + data[1] + ";\n" +
"var res = require('resources');\n" +
"var userData = res.getVocabulary('user') || {};\n" +
"res.setVocabulary(require('utils').deepMerge(userData, snippets), 'user');\n" +
"});";
});
}
}]; }];
var download = function(href, callback) { var download = function(href, callback) {
var options = url.parse(href); if (Array.isArray(href))
var protocol = options.protocol === "https:" ? https : http; return async.map(href, download, callback);
console.log("connecting to " + options.host + " " + options.path);
protocol.get(options, function(res) {
var data = "";
res.setEncoding("utf-8");
res.on("data", function(chunk){ var options = url.parse(href);
data += chunk; var protocol = options.protocol === "https:" ? https : http;
}); console.log("connecting to " + options.host + " " + options.path);
protocol.get(options, function(res) {
var data = "";
res.setEncoding("utf-8");
res.on("end", function(){ res.on("data", function(chunk){
callback(data); data += chunk;
}); });
});
res.on("end", function(){
callback(null, data);
});
});
}; };
var getDep = function(dep) { var getDep = function(dep) {
download(dep.url, function(data) { download(dep.url, function(err, data) {
if (dep.postProcess) if (dep.postProcess)
data = dep.postProcess(data); data = dep.postProcess(data);
if (dep.needsFixup) if (dep.needsFixup)
data = "define(function(require, exports, module) {\n" data = "define(function(require, exports, module) {\n"
+ data + data
+ "\n});"; + "\n});";
fs.writeFile(rootDir + dep.path, data, "utf-8", function(err){ fs.writeFile(rootDir + dep.path, data, "utf-8", function(err){
if (err) throw err; if (err) throw err;
console.log("File " + dep.path + " saved."); console.log("File " + dep.path + " saved.");
}); });
}); });
}; };
deps.forEach(getDep); deps.slice(-1).forEach(getDep);
// coffee-script // coffee-script
void function(){ void function(){
var rootHref = "https://raw.github.com/jashkenas/coffee-script/master/"; var rootHref = "https://raw.github.com/jashkenas/coffee-script/master/";
var path = "mode/coffee/"; var path = "mode/coffee/";
var subDir = "lib/coffee-script/"; var subDir = "lib/coffee-script/";
var deps = [ var deps = [
"helpers.js", "helpers.js",
"lexer.js", "lexer.js",
"nodes.js", "nodes.js",
"parser.js", "parser.js",
"rewriter.js", "rewriter.js",
"scope.js" "scope.js"
].map(function(x) { ].map(function(x) {
return { return {
name: x, name: x,
href: rootHref + subDir + x, href: rootHref + subDir + x,
path: rootDir + path + x path: rootDir + path + x
}; };
}); });
deps.push({name:"LICENSE", href: rootHref + "LICENSE"}); deps.push({name:"LICENSE", href: rootHref + "LICENSE"});
var downloads = {}, counter = 0; var downloads = {}, counter = 0;
deps.forEach(function(x) { deps.forEach(function(x) {
download(x.href, function(data) { download(x.href, function(err, data) {
counter++; counter++;
downloads[x.name] = data; downloads[x.name] = data;
if (counter == deps.length) if (counter == deps.length)
allDone(); allDone();
}); });
}); });
function allDone() { function allDone() {
deps.pop(); deps.pop();
var license = downloads.LICENSE.split('\n'); var license = downloads.LICENSE.split('\n');
license = "/**\n * " + license.join("\n * ") + "\n */"; license = "/**\n * " + license.join("\n * ") + "\n */";
deps.forEach(function(x) { deps.forEach(function(x) {
var data = downloads[x.name]; var data = downloads[x.name];
console.log(x.name); console.log(x.name);
console.log(!data); console.log(!data);
if (!data) if (!data)
return; return;
if (x.name == "parser.js") { if (x.name == "parser.js") {
data = data.replace("var parser = (function(){", "") data = data.replace("var parser = (function(){", "")
.replace(/\nreturn (new Parser)[\s\S]*$/, "\n\nmodule.exports = $1;\n\n"); .replace(/\nreturn (new Parser)[\s\S]*$/, "\n\nmodule.exports = $1;\n\n");
} else { } else {
data = data.replace("(function() {", "") data = data.replace("(function() {", "")
.replace(/\}\).call\(this\);\s*$/, ""); .replace(/\}\).call\(this\);\s*$/, "");
} }
data = license data = license
+ "\n\n" + "\n\n"
+ "define(function(require, exports, module) {\n" + "define(function(require, exports, module) {\n"
+ data + data
+ "\n});"; + "\n});";
fs.writeFile(x.path, data, "utf-8", function(err){ fs.writeFile(x.path, data, "utf-8", function(err){
if (err) throw err; if (err) throw err;
console.log("File " + x.name + " saved."); console.log("File " + x.name + " saved.");
console.warn("mode/coffee/coffee-script file needs to updated manually"); console.warn("mode/coffee/coffee-script file needs to updated manually");
console.warn("mode/coffee/parser.js: parseError function needs to be modified"); console.warn("mode/coffee/parser.js: parseError function needs to be modified");
}); });
}); });
} }
}(); }//();
var spawn = require("child_process").spawn;
var run = function(cmd, cb) {
var proc = spawn("cmd", ["/c " + cmd]);
proc.stderr.setEncoding("utf8");
proc.stderr.on('data', function (data) {
// console.error(data);
});
proc.stdout.setEncoding("utf8");
proc.stdout.on('data', function (data) {
//console.log(data);
});
proc.on('exit', done);
proc.on('close', done);
function done(code) {
if (code !== 0) {
console.error(cmd + '::: process exited with code :::' + code);
}
cb()
}
}
function unquote(str) {
return str.replace(/\\(.)/g, function(x, a) {
return a == "n" ? "\n"
: a == "t" ? "\t"
: a == "r" ? "\r"
: a
});
}
run("npm install jshint", function() {
var jshintDist = fs.readFileSync("node_modules/jshint/dist/jshint.js", "utf8");
jshintDist = jshintDist.replace(
/(require.define.*)Function\(\[([^\]]*?)\],\s*"(.*)"\s*\)/g,
function(a, def, args, content) {
return def + "function("+args.replace(/["']/g, "") + ") {\n"
+ unquote(content)
+ "\n}";
}
);
jshintDist = jshintDist.replace(
/"Expected a conditional expression and instead saw an assignment."/g,
'"Assignment in conditional expression"'
);
jshintDist = jshintDist.replace(/\brequire\(["']|\(require,|\(require\)/g, function(r){
return r.replace("require", "req");
}).replace(/\brequire\.define(\(|\s*=)/g, function(d){
return d.replace("define", "def");
});
jshintDist = jshintDist.replace(/var defaultMaxListeners = 10;/, function(a) {return a.replace("10", "200")});
jshintDist = 'define(function(require, exports, module) {\n'
+ jshintDist + '\n'
+ 'function req() {return require.apply(this, arguments)}\n'
+ 'module.exports = req("/src/stable/jshint.js");\n'
+'});';
fs.writeFileSync(rootDir + "mode/javascript/jshint.js", jshintDist);
});