Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replace jslint with jshint

  • Loading branch information...
commit 13870f092cf1e76e68335ebf73b21038f172637a 1 parent b0e6ced
@ixti ixti authored
View
8 .jshintignore
@@ -0,0 +1,8 @@
+.git/
+doc/
+node_modules/
+tmp/
+support/
+demo/
+js-yaml.js
+js-yaml.min.js
View
72 .jshintrc
@@ -0,0 +1,72 @@
+{
+ // Enforcing Options /////////////////////////////////////////////////////////
+
+ "bitwise" : false, // Prohibit bitwise operators (&, |, ^, etc.).
+ "curly" : true, // Require {} for every new block or scope.
+ "eqeqeq" : true, // Require triple equals i.e. `===`.
+ "forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`.
+ "immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
+ "latedef" : true, // Prohibit hariable use before definition.
+ "newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`.
+ "noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
+ "noempty" : true, // Prohibit use of empty blocks.
+ "nonew" : true, // Prohibit use of constructors for side-effects.
+ "plusplus" : false, // Prohibit use of `++` & `--`.
+ "regexp" : false, // Prohibit `.` and `[^...]` in regular expressions.
+ "undef" : true, // Require all non-global variables be declared before they are used.
+ "strict" : true, // Require `use strict` pragma in every file.
+ "trailing" : true, // Prohibit trailing whitespaces.
+
+ // Relaxing Options //////////////////////////////////////////////////////////
+
+ "asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
+ "boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
+ "debug" : false, // Allow debugger statements e.g. browser breakpoints.
+ "eqnull" : false, // Tolerate use of `== null`.
+ "es5" : true, // Allow ECMAScript 5 syntax.
+ "esnext" : false, // Allow ES.next specific features such as const and let
+ "evil" : false, // Tolerate use of `eval`.
+ "expr" : false, // Tolerate `ExpressionStatement` as Programs.
+ "funcscope" : false, // Tolerate declaring variables inside of control structures while accessing them later
+ "globalstrict" : true, // Allow global "use strict" (also enables 'strict').
+ "iterator" : false, // Allow usage of __iterator__ property.
+ "lastsemic" : false, // Tolerate semicolon omited for the last statement.
+ "laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
+ "laxcomma" : true, // This option suppresses warnings about comma-first coding style
+ "loopfunc" : false, // Allow functions to be defined within loops.
+ "multistr" : false, // Tolerate multi-line strings.
+ "onecase" : false, // Tolerate swithes with only one case.
+ "proto" : false, // Allow usage of __proto__ property.
+ "regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`.
+ "scripturl" : true, // Tolerate script-targeted URLs.
+ "smarttabs" : false, // Allow mixed tabs and spaces when the latter are used for alignmnent only.
+ "shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
+ "sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
+ "supernew" : true, // Tolerate `new function () { ... };` and `new Object;`.
+
+ // Environments //////////////////////////////////////////////////////////////
+
+ "browser" : false, // Defines globals exposed by modern browsers
+ "couch" : false, // Defines globals exposed by CouchDB
+ "devel" : false, // Allow developments statements e.g. `console.log();`.
+ "dojo" : false, // Defines globals exposed by the Dojo Toolkit
+ "jquery" : false, // Defines globals exposed by the jQuery
+ "mootools" : false, // Defines globals exposed by the MooTools
+ "node" : true, // Defines globals exposed when running under Node.JS
+ "nonstandard" : false, // Defines non-standard but widely adopted globals such as escape and unescape
+ "prototypejs" : false, // Defines globals exposed by the Prototype
+ "rhino" : false, // Defines globals exposed when running under Rhino
+ "wsh" : false, // Defines globals exposed when running under WSH
+
+ // Legacy ////////////////////////////////////////////////////////////////////
+
+ "nomen" : false, // Prohibit use of initial or trailing underbars in names.
+ "onevar" : false, // Allow only one `var` statement per function.
+ "passfail" : false, // Stop on first error.
+ "white" : false, // Check against strict whitespace and indentation rules.
+
+ // Undocumented //////////////////////////////////////////////////////////////
+
+ "maxerr" : 100, // Maximum error before stopping.
+ "indent" : 2 // Specify indentation spacing
+}
View
84 Makefile
@@ -1,7 +1,7 @@
-PATH := $(shell pwd)/node_modules/.bin:${PATH}
+PATH := ./node_modules/.bin:${PATH}
-NPM_PACKAGE := $(shell node -e 'console.log(require("./package.json").name)')
-NPM_VERSION := $(shell node -e 'console.log(require("./package.json").version)')
+NPM_PACKAGE := $(shell node -e 'process.stdout.write(require("./package.json").name)')
+NPM_VERSION := $(shell node -e 'process.stdout.write(require("./package.json").version)')
TMP_PATH := /tmp/${NPM_PACKAGE}-$(shell date +%s)
@@ -12,20 +12,26 @@ CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut --bytes=-6) ma
GITHUB_PROJ := nodeca/${NPM_PACKAGE}
SRC_URL_FMT := https://github.com/${GITHUB_PROJ}/blob/${CURR_HEAD}/{file}\#L{line}
-JS_FILES := $(shell find ./lib ./test -type f -name '*.js' -print)
+
+help:
+ echo "make help - Print this help"
+ echo "make lint - Lint sources with JSHint"
+ echo "make test - Lint sources and run all tests"
+ echo "make doc - Build API docs"
+ echo "make dev-deps - Install developer dependencies"
+ echo "make gh-pages - Build and push API docs into gh-pages branch"
+ echo "make publish - Set new version tag and publish npm package"
+ echo "make todo - Find and list all TODOs"
+
lint:
- @if test ! `which jslint` ; then \
- echo "You need 'jslint' installed in order to run lint." >&2 ; \
+ if test ! `which jshint` ; then \
+ echo "You need 'jshint' installed in order to run lint." >&2 ; \
echo " $ make dev-deps" >&2 ; \
exit 128 ; \
fi
- # (node) -> Node.JS compatibility mode
- # (indent) -> indentation level (2 spaces)
- # (nomen) -> tolerate underscores in identifiers (e.g. `var _val = 1`)
- # (bitwise) -> tolerate bitwise operators (used in base64)
- # (white) -> tolerate messy whitespace
- jslint --node --nomen --bitwise --white --indent=2 ./index.js ${JS_FILES}
+ jshint . --show-non-errors
+
test: lint
@if test ! `which vows` ; then \
@@ -35,27 +41,25 @@ test: lint
fi
NODE_ENV=test vows --spec
+
+doc:
+ @if test ! `which ndoc` ; then \
+ echo "You need 'ndoc' installed in order to generate docs." >&2 ; \
+ echo " $ npm install ndoc" >&2 ; \
+ exit 128 ; \
+ fi
+ rm -rf ./doc
+ ndoc --output ./doc --link-format "${SRC_URL_FMT}" ./lib
+
+
dev-deps:
@if test ! `which npm` ; then \
echo "You need 'npm' installed." >&2 ; \
echo " See: http://npmjs.org/" >&2 ; \
exit 128 ; \
fi
- npm install --dev
-
-build: browserify uglify
-
-browserify:
- if test ! `which browserify` ; then npm install browserify ; fi
- cp -r support/browserify/ ${TMP_PATH}
- browserify index.js -o ${TMP_PATH}/50_js-yaml.js
- cat ${TMP_PATH}/* > js-yaml.js
- rm -rf ${TMP_PATH}
- cp js-yaml.js demo/js/
-
-uglify:
- if test ! `which uglifyjs` ; then npm install uglify-js ; fi
- uglifyjs js-yaml.js > js-yaml.min.js
+ which jshint > /dev/null || npm install jshint
+ npm install
gh-pages:
@@ -63,18 +67,19 @@ gh-pages:
echo 'Remote repo URL not found' >&2 ; \
exit 128 ; \
fi
- mkdir ${TMP_PATH}
- cp -r demo/* ${TMP_PATH}
- touch ${TMP_PATH}/.nojekyll
+ $(MAKE) doc && \
+ cp -r ./doc ${TMP_PATH} && \
+ touch ${TMP_PATH}/.nojekyll
cd ${TMP_PATH} && \
git init && \
git add . && \
- git commit -q -m 'Update browserified demo'
+ git commit -q -m 'Recreated docs'
cd ${TMP_PATH} && \
git remote add remote ${REMOTE_REPO} && \
git push --force remote +master:gh-pages
rm -rf ${TMP_PATH}
+
publish:
@if test 0 -ne `git status --porcelain | wc -l` ; then \
echo "Unclean working tree. Commit or stash changes first." >&2 ; \
@@ -87,8 +92,21 @@ publish:
git tag ${NPM_VERSION} && git push origin ${NPM_VERSION}
npm publish https://github.com/${GITHUB_PROJ}/tarball/${NPM_VERSION}
+
+browserify:
+ if test ! `which browserify` ; then npm install browserify ; fi
+ if test ! `which uglifyjs` ; then npm install uglify-js ; fi
+ cp -r support/browserify/ ${TMP_PATH}
+ browserify index.js -o ${TMP_PATH}/50_js-yaml.js
+ cat ${TMP_PATH}/* > js-yaml.js
+ rm -rf ${TMP_PATH}
+ cp js-yaml.js demo/js/
+ uglifyjs js-yaml.js > js-yaml.min.js
+
+
todo:
grep 'TODO' -n -r ./lib 2>/dev/null || test true
-.PHONY: publish test lint dev-deps gh-pages todo
-.SILENT: todo test test-functional test-issues
+
+.PHONY: publish lint test doc dev-deps gh-pages todo
+.SILENT: help lint test doc todo
View
4 lib/js-yaml/composer.js
@@ -137,7 +137,7 @@ Composer.prototype.composeScalarNode = function composeScalarNode(anchor) {
};
Composer.prototype.composeSequenceNode = function composeSequenceNode(anchor) {
- var start_event, event, tag, node, index, end_event;
+ var start_event, tag, node, index, end_event;
start_event = this.getEvent();
tag = start_event.tag;
@@ -170,7 +170,7 @@ Composer.prototype.composeSequenceNode = function composeSequenceNode(anchor) {
Composer.prototype.composeMappingNode = function composeMappingNode(anchor) {
- var startEvent, event, tag, node, itemKey, itemValue, endEvent;
+ var startEvent, tag, node, itemKey, itemValue, endEvent;
startEvent = this.getEvent();
tag = startEvent.tag;
View
4 lib/js-yaml/constructor.js
@@ -183,7 +183,7 @@ BaseConstructor.prototype.constructMapping = function constructMapping(node, dee
var key_node = pair[0], value_node = pair[1], key, value;
key = this.constructObject(key_node, deep);
- // TODO: Do we need to check
+ // TODO: Do we need to check
if (undefined === key_node.hash) {
throw new ConstructorError("while constructing a mapping", key_node.startMark,
"found unhashable key", key_node.startMark);
@@ -233,7 +233,7 @@ SafeConstructor.prototype.constructScalar = function constructScalar(node) {
if ($$.isInstanceOf(node, _nodes.MappingNode)) {
$$.each(node.value, function (pair) {
- var key_node = pair[0], value_node = pair[1], value;
+ var key_node = pair[0], value_node = pair[1];
if ('tag:yaml.org,2002:value' === key_node.tag) {
result = this.constructScalar(value_node);
View
10 lib/js-yaml/errors.js
@@ -109,11 +109,11 @@ function toStringFull(self) {
lines.push(self.context);
}
- if (null !== self.contextMark
- && (null === self.problem || null === self.problemMark
- || self.contextMark.name !== self.problemMark.name
- || self.contextMark.line !== self.problemMark.line
- || self.contextMark.column !== self.problemMark.column)) {
+ if (null !== self.contextMark &&
+ (null === self.problem || null === self.problemMark ||
+ self.contextMark.name !== self.problemMark.name ||
+ self.contextMark.line !== self.problemMark.line ||
+ self.contextMark.column !== self.problemMark.column)) {
lines.push(self.contextMark.toString());
}
View
2  lib/js-yaml/parser.js
@@ -551,7 +551,7 @@ Parser.prototype.parseBlockMappingKey = function parseBlockMappingKey() {
};
Parser.prototype.parseBlockMappingValue = function parseBlockMappingValue() {
- var token, event;
+ var token;
if (this.checkToken(_tokens.ValueToken)) {
token = this.getToken();
View
10 lib/js-yaml/reader.js
@@ -13,9 +13,9 @@ var NON_PRINTABLE = new RegExp('[^\x09\x0A\x0D -~\x85\xA0-\uD7FF\uE000-\uFFFD]')
// IE 7-8 hack. As we use ONLY strings in browsers as input stream, there's no
// need for stream.slice() call and we can simply use stream.charAt() when we
// are running on that shit...
-var getSingleChar = (undefined === ('a')[0])
- ? function (str, pos) { return str.charAt(pos); }
- : function (str, pos) { return str[pos]; };
+var getSingleChar = (undefined === ('a')[0]) ?
+ function (str, pos) { return str.charAt(pos); }
+ : function (str, pos) { return str[pos]; };
function ReaderError(name, position, character, encoding, reason) {
@@ -105,8 +105,8 @@ Reader.prototype.forward = function forward(length) {
this.pointer += 1;
this.index += 1;
- if (0 <= '\n\x85\u2028\u2029'.indexOf(ch)
- || ('\r' === ch && '\n' !== this.buffer[this.pointer])) {
+ if (0 <= '\n\x85\u2028\u2029'.indexOf(ch) ||
+ ('\r' === ch && '\n' !== this.buffer[this.pointer])) {
this.line += 1;
this.column = 0;
} else if (ch !== '\uFEFF') {
View
30 lib/js-yaml/scanner.js
@@ -20,7 +20,7 @@
// ANCHOR(value)
// TAG(value)
// SCALAR(value, plain, style)
-//
+//
// Read comments in the Scanner code for more details.
@@ -907,11 +907,9 @@ Scanner.prototype.checkPlain = function checkPlain() {
// independent.
var ch = this.peek();
return (
- -1 === '\x00 \t\r\n\x85\u2028\u2029-?:,[]{}#&*!|>\'\"%@`'.indexOf(ch)
- ||
+ -1 === '\x00 \t\r\n\x85\u2028\u2029-?:,[]{}#&*!|>\'\"%@`'.indexOf(ch) ||
(
- -1 === '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(1))
- &&
+ -1 === '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(1)) &&
(
ch === '-' || (!this.flowLevel && 0 <= '?:'.indexOf(ch))
)
@@ -1469,7 +1467,7 @@ Scanner.prototype.scanBlockScalarBreaks = function scanBlockScalarBreaks(indent)
};
Scanner.prototype.scanFlowScalar = function scanFlowScalar(style) {
- var dbl, chunks, length, code, startMark, quote, endMark;
+ var dbl, chunks, startMark, quote, endMark;
// See the specification for details.
// Note that we loose indentation rules for quoted scalars. Quoted
// scalars don't need to adhere indentation because " and ' clearly
@@ -1647,10 +1645,10 @@ Scanner.prototype.scanPlain = function scanPlain() {
while (true) {
ch = this.peek(length);
- if (0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(ch)
- || (!this.flowLevel && ch === ':'
- && 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(length + 1)))
- || (this.flowLevel && 0 <= ',:?[]{}'.indexOf(ch))) {
+ if (0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(ch) || (
+ !this.flowLevel && ch === ':' &&
+ 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(length + 1))
+ ) || (this.flowLevel && 0 <= ',:?[]{}'.indexOf(ch))) {
break;
}
@@ -1677,8 +1675,8 @@ Scanner.prototype.scanPlain = function scanPlain() {
endMark = this.getMark();
spaces = this.scanPlainSpaces(indent, startMark);
- if (!Array.isArray(spaces) || !spaces.length || this.peek() === '#'
- || (!this.flowLevel && this.column < indent)) {
+ if (!Array.isArray(spaces) || !spaces.length || this.peek() === '#' ||
+ (!this.flowLevel && this.column < indent)) {
break;
}
}
@@ -1709,8 +1707,8 @@ Scanner.prototype.scanPlainSpaces = function scanPlainSpaces(indent, startMark)
this.allowSimpleKey = true;
prefix = this.prefix(3);
- if ((prefix === '---' || prefix === '...')
- && 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3))) {
+ if ((prefix === '---' || prefix === '...') &&
+ 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3))) {
return;
}
@@ -1723,8 +1721,8 @@ Scanner.prototype.scanPlainSpaces = function scanPlainSpaces(indent, startMark)
breaks.push(this.scanLineBreak());
prefix = this.prefix(3);
- if ((prefix === '---' || prefix === '...')
- && 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3))) {
+ if ((prefix === '---' || prefix === '...') &&
+ 0 <= '\x00 \t\r\n\x85\u2028\u2029'.indexOf(this.peek(3))) {
return;
}
}
View
5 package.json
@@ -23,9 +23,6 @@
"test" : "make test"
},
- "devDependencies" : {
- "vows" : "~ 0.6.0",
- "jslint" : "https://github.com/reid/node-jslint/tarball/6131ebf5713274871b89735105e3286131804771"
- },
+ "devDependencies" : { "vows": "~ 0.6.0" },
"engines" : { "node": "> 0.4.11" }
}
View
8 test/functional/canonical.js
@@ -160,8 +160,8 @@ CanonicalScanner.prototype.scan = function scan() {
};
CanonicalScanner.prototype.scanDirective = function scanDirective() {
- if (this.data.slice(this.index, this.index + DIRECTIVE.length) === this.DIRECTIVE
- && 0 <= ' \n\x00'.indexOf(this.data.slice(this.index + DIRECTIVE.length))) {
+ if (this.data.slice(this.index, this.index + DIRECTIVE.length) === this.DIRECTIVE &&
+ 0 <= ' \n\x00'.indexOf(this.data.slice(this.index + DIRECTIVE.length))) {
this.index += this.DIRECTIVE.length;
return new _tokens.DirectiveToken('YAML', [1, 1], null, null);
}
@@ -172,8 +172,8 @@ CanonicalScanner.prototype.scanDirective = function scanDirective() {
CanonicalScanner.prototype.scanAlias = function scanAlias() {
var start, value, TokenClass;
- TokenClass = (this.data[this.index] === '*')
- ? (_tokens.AliasToken) : (_tokens.AnchorToken);
+ TokenClass = (this.data[this.index] === '*') ? (_tokens.AliasToken)
+ : (_tokens.AnchorToken);
this.index += 1;
start = this.index;
View
4 test/functional/functional-tokens.js
@@ -61,8 +61,8 @@ module.exports = {
});
JsYaml.scan(Fs.readFileSync(dataFile, 'utf8'), function (token) {
- if (Common.isInstanceOf(token, Tokens.StreamStartToken)
- || Common.isInstanceOf(token, Tokens.StreamEndToken)) {
+ if (Common.isInstanceOf(token, Tokens.StreamStartToken) ||
+ Common.isInstanceOf(token, Tokens.StreamEndToken)) {
return;
}
Please sign in to comment.
Something went wrong with that request. Please try again.