Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonJS module env validation #77

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 20 additions & 2 deletions jslint.js
Expand Up @@ -158,6 +158,7 @@
// adsafe true, if ADsafe rules should be enforced
// bitwise true, if bitwise operators should be allowed
// browser true, if the standard browser globals should be predefined
// commonjs true, if the standard commonjs globals should be predefined
// cap true, if upper case HTML should be allowed
// confusion true, if types can be used inconsistently
// 'continue' true, if the continuation statement should be tolerated
Expand Down Expand Up @@ -194,7 +195,7 @@
// For example:

/*jslint
evil: true, nomen: true, regexp: true
evil: true, nomen: true, regexp: true, commonjs: true
*/

// The properties directive declares an exclusive list of property names.
Expand Down Expand Up @@ -253,7 +254,7 @@
'caption-side': array, ceil: string, center: object, charAt: *,
charCodeAt: *, character, cite: object, clear: array, clip: array, closure,
cm: boolean, code: object, col: object, colgroup: object, color,
combine_var: string, command: object, concat: string,
combine_var: string, command: object, commonjs: boolean, concat: string,
conditional_assignment: string, confusing_a: string,
confusing_regexp: string, confusion: boolean, constructor: string,
constructor_name_a: string, content: array, continue, control_a: string,
Expand Down Expand Up @@ -310,6 +311,7 @@
isAlpha: function, isArray: function boolean, isDigit: function,
isExtensible: string, isFrozen: string, isNaN: string,
isPrototypeOf: string, isSealed: string, join: *, jslint: function boolean,
JSLINT: function boolean,
json: boolean, kbd: object, keygen: object, keys: *, label: object,
label_a_b: string, labeled: boolean, lang: string, lastIndex: string,
lastIndexOf: *, lbp: number, leading_decimal_a: string, led: function,
Expand Down Expand Up @@ -463,6 +465,13 @@ var JSLINT = (function () {
'setTimeout', 'Storage', 'window', 'XMLHttpRequest'
], false),

// commonjs contains a set of global names that are commonly provided by a
// CommonJS environment.

commonjs = array_to_object([
'require', 'module', 'exports'
], false),

// bundle contains the text messages.

bundle = {
Expand Down Expand Up @@ -1279,6 +1288,10 @@ var JSLINT = (function () {
add_to_predefined(browser);
option.browser = false;
}
if (option.commonjs) {
add_to_predefined(commonjs);
option.commonjs = false;
}
if (option.windows) {
add_to_predefined(windows);
option.windows = false;
Expand Down Expand Up @@ -6949,6 +6962,11 @@ klass: do {
};
itself.jslint = itself;

// CommonJS module export
if (typeof exports !== "undefined") {
exports.JSLINT = itself;
}

itself.edition = '2011-09-29';

return itself;
Expand Down