mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1330006 - Land and enable self-hosted JS eslint plugin. r=till,mossop
This commit is contained in:
parent
ec8b3e8c5d
commit
aeaf8fb38c
@ -24,7 +24,6 @@ hal/**
|
||||
image/**
|
||||
intl/**
|
||||
ipc/**
|
||||
js/**
|
||||
layout/**
|
||||
media/**
|
||||
memory/**
|
||||
@ -154,6 +153,17 @@ devtools/client/framework/test/code_ugly*
|
||||
devtools/server/tests/unit/babel_and_browserify_script_with_source_map.js
|
||||
devtools/server/tests/unit/setBreakpoint*
|
||||
|
||||
# Exclude everything but self-hosted JS
|
||||
js/ductwork/**
|
||||
js/examples/**
|
||||
js/ipc/**
|
||||
js/public/**
|
||||
js/xpconnect/**
|
||||
js/src/devtools/**
|
||||
js/src/octane/**
|
||||
js/src/jit-test/**
|
||||
js/src/tests/**
|
||||
|
||||
# mobile/android/ exclusions
|
||||
mobile/android/tests/
|
||||
|
||||
|
22
js/src/builtin/.eslintrc.js
Normal file
22
js/src/builtin/.eslintrc.js
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
"extends": [
|
||||
"../../../toolkit/.eslintrc.js"
|
||||
],
|
||||
|
||||
"rules": {
|
||||
// We should fix those at some point, but we use this to detect NaNs.
|
||||
"no-self-compare": "off",
|
||||
// Disabling these two make it easier to implement the spec.
|
||||
"spaced-comment": "off",
|
||||
"no-lonely-if": "off",
|
||||
// SpiderMonkey's style doesn't match any of the possible options.
|
||||
"brace-style": "off",
|
||||
// Manually defining all the selfhosted methods is a slog.
|
||||
"no-undef": "off",
|
||||
// Disabled until we can use let/const to fix those erorrs,
|
||||
// and undefined names cause an exception and abort during runtime initialization.
|
||||
"no-redeclare": "off",
|
||||
}
|
||||
};
|
@ -15,6 +15,7 @@
|
||||
module.exports = {
|
||||
processors: {
|
||||
".xml": require("../lib/processors/xbl-bindings"),
|
||||
".js": require("../lib/processors/self-hosted"),
|
||||
},
|
||||
rules: {
|
||||
"avoid-removeChild": require("../lib/rules/avoid-removeChild"),
|
||||
|
@ -0,0 +1,44 @@
|
||||
/**
|
||||
* @fileoverview Remove macros from SpiderMonkey's self-hosted JS.
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const selfHostedRegex = /js\/src\/builtin\/.*?\.js$/;
|
||||
const macroRegex = /\s*\#(if|ifdef|else|elif|endif|include|define|undef).*/;
|
||||
|
||||
module.exports = {
|
||||
preprocess: function(text, filename) {
|
||||
if (!selfHostedRegex.test(filename)) {
|
||||
return [text];
|
||||
}
|
||||
|
||||
let lines = text.split(/\n/);
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (!macroRegex.test(lines[i])) {
|
||||
// No macro here, nothing to do.
|
||||
continue;
|
||||
}
|
||||
|
||||
for (; i < lines.length; i++) {
|
||||
lines[i] = "// " + lines[i];
|
||||
|
||||
// If the line ends with a backslash (\), the next line
|
||||
// is also part of part of the macro.
|
||||
if (!lines[i].endsWith("\\")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [lines.join("\n")];
|
||||
},
|
||||
|
||||
postprocess: function(messages, filename) {
|
||||
return Array.prototype.concat.apply([], messages);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "eslint-plugin-mozilla",
|
||||
"version": "0.2.18",
|
||||
"version": "0.2.19",
|
||||
"description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
|
||||
"keywords": [
|
||||
"eslint",
|
||||
|
Loading…
Reference in New Issue
Block a user