mirror of
https://github.com/remarkjs/remark-lint.git
synced 2024-10-27 03:37:50 +03:00
Update eslint, jscs, browserify
* Fix new lint-warnings.
This commit is contained in:
parent
490ac160ee
commit
968fee0622
@ -0,0 +1,6 @@
|
|||||||
|
build/
|
||||||
|
components/
|
||||||
|
coverage/
|
||||||
|
build.js
|
||||||
|
mdast-lint.js
|
||||||
|
mdast-lint.min.js
|
@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"extends": "eslint:recommended",
|
||||||
"env": {
|
"env": {
|
||||||
"node": true,
|
"node": true,
|
||||||
"browser": true
|
"browser": true
|
||||||
|
34
.jscs.json
34
.jscs.json
@ -1,19 +1,27 @@
|
|||||||
{
|
{
|
||||||
"plugins": [
|
"excludeFiles": [
|
||||||
"jscs-jsdoc"
|
"build/",
|
||||||
|
"components/",
|
||||||
|
"coverage/",
|
||||||
|
"node_modules/",
|
||||||
|
"build.js",
|
||||||
|
"mdast-lint.js",
|
||||||
|
"mdast-lint.min.js"
|
||||||
],
|
],
|
||||||
"jsDoc": {
|
"jsDoc": {
|
||||||
"checkAnnotations": "jsdoc3",
|
"checkAnnotations": "jsdoc3",
|
||||||
"checkParamNames": true,
|
"checkParamNames": true,
|
||||||
"requireParamTypes": true,
|
|
||||||
"checkRedundantParams": true,
|
|
||||||
"checkReturnTypes": true,
|
|
||||||
"checkRedundantReturns": true,
|
|
||||||
"requireReturnTypes": true,
|
|
||||||
"checkTypes": "strictNativeCase",
|
|
||||||
"checkRedundantAccess": true,
|
"checkRedundantAccess": true,
|
||||||
|
"checkRedundantParams": true,
|
||||||
|
"checkRedundantReturns": true,
|
||||||
|
"checkReturnTypes": true,
|
||||||
|
"checkTypes": "strictNativeCase",
|
||||||
"enforceExistence": true,
|
"enforceExistence": true,
|
||||||
"requireHyphenBeforeDescription": true
|
"requireHyphenBeforeDescription": true,
|
||||||
|
"requireNewlineAfterDescription": true,
|
||||||
|
"requireParamTypes": true,
|
||||||
|
"requireParamDescription": true,
|
||||||
|
"requireReturnTypes": true
|
||||||
},
|
},
|
||||||
"requireCurlyBraces": [
|
"requireCurlyBraces": [
|
||||||
"if",
|
"if",
|
||||||
@ -119,6 +127,7 @@
|
|||||||
"with"
|
"with"
|
||||||
],
|
],
|
||||||
"disallowMultipleLineStrings": true,
|
"disallowMultipleLineStrings": true,
|
||||||
|
"disallowMultipleLineBreaks": true,
|
||||||
"validateLineBreaks": "LF",
|
"validateLineBreaks": "LF",
|
||||||
"validateQuoteMarks": "'",
|
"validateQuoteMarks": "'",
|
||||||
"disallowMixedSpacesAndTabs": true,
|
"disallowMixedSpacesAndTabs": true,
|
||||||
@ -131,10 +140,5 @@
|
|||||||
"requireCapitalizedConstructors": true,
|
"requireCapitalizedConstructors": true,
|
||||||
"safeContextKeyword": "self",
|
"safeContextKeyword": "self",
|
||||||
"requireDotNotation": true,
|
"requireDotNotation": true,
|
||||||
"disallowYodaConditions": true,
|
"disallowYodaConditions": true
|
||||||
"validateJSDoc": {
|
|
||||||
"checkParamNames": true,
|
|
||||||
"checkRedundantParams": true,
|
|
||||||
"requireParamTypes": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
"script/",
|
"script/",
|
||||||
"test/",
|
"test/",
|
||||||
"build.js",
|
"build.js",
|
||||||
"example.js",
|
|
||||||
"index.js",
|
"index.js",
|
||||||
"component.json",
|
"component.json",
|
||||||
"package.json"
|
"package.json"
|
||||||
|
16
example.js
16
example.js
@ -1,16 +0,0 @@
|
|||||||
var mdast = require('mdast');
|
|
||||||
var lint = require('./index.js');
|
|
||||||
|
|
||||||
var processor = mdast().use(lint);
|
|
||||||
|
|
||||||
// Example document.
|
|
||||||
var doc = '* Hello\n' +
|
|
||||||
'\n' +
|
|
||||||
'- World\n';
|
|
||||||
|
|
||||||
// Process.
|
|
||||||
processor.process(doc, function (err, res, file) {
|
|
||||||
// Yields:
|
|
||||||
var messages = file.messages;
|
|
||||||
console.log('json', JSON.stringify(messages, 0, 2));
|
|
||||||
});
|
|
@ -68,7 +68,6 @@ function transformer(ast, file) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (offset === position.end(lastNode).offset) {
|
if (offset === position.end(lastNode).offset) {
|
||||||
update();
|
update();
|
||||||
update(file.toString().length - 1);
|
update(file.toString().length - 1);
|
||||||
|
10
lib/index.js
10
lib/index.js
@ -202,8 +202,8 @@ function lint(mdast, options) {
|
|||||||
/**
|
/**
|
||||||
* Get the latest state of a rule.
|
* Get the latest state of a rule.
|
||||||
*
|
*
|
||||||
* @param {string} ruleId
|
* @param {string} ruleId - Unique rule name.
|
||||||
* @param {File} [file]
|
* @param {File} [file] - File (optional)
|
||||||
*/
|
*/
|
||||||
function getState(ruleId, file) {
|
function getState(ruleId, file) {
|
||||||
var ranges = file && file.lintRanges && file.lintRanges[ruleId];
|
var ranges = file && file.lintRanges && file.lintRanges[ruleId];
|
||||||
@ -224,7 +224,7 @@ function lint(mdast, options) {
|
|||||||
/**
|
/**
|
||||||
* Store settings on `file`.
|
* Store settings on `file`.
|
||||||
*
|
*
|
||||||
* @param {File} file
|
* @param {File} file - Virtual file.
|
||||||
*/
|
*/
|
||||||
function store(file) {
|
function store(file) {
|
||||||
var ranges = file.lintRanges;
|
var ranges = file.lintRanges;
|
||||||
@ -264,8 +264,8 @@ function lint(mdast, options) {
|
|||||||
/**
|
/**
|
||||||
* Handle a new-found marker.
|
* Handle a new-found marker.
|
||||||
*
|
*
|
||||||
* @param {Object} marker
|
* @param {Object} marker - Marker context.
|
||||||
* @param {Object} parser
|
* @param {Object} parser - Parser instance.
|
||||||
*/
|
*/
|
||||||
function onparse(marker, parser) {
|
function onparse(marker, parser) {
|
||||||
var file = parser.file;
|
var file = parser.file;
|
||||||
|
@ -87,7 +87,7 @@ function codeBlockStyle(ast, file, preferred, done) {
|
|||||||
/**
|
/**
|
||||||
* Get the style of `node`.
|
* Get the style of `node`.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node - Node.
|
||||||
* @return {string?} - `'fenced'`, `'indented'`, or
|
* @return {string?} - `'fenced'`, `'indented'`, or
|
||||||
* `null`.
|
* `null`.
|
||||||
*/
|
*/
|
||||||
|
@ -43,7 +43,7 @@ function definitionCase(ast, file, preferred, done) {
|
|||||||
* Validate a node, either a normal definition or
|
* Validate a node, either a normal definition or
|
||||||
* a footnote definition.
|
* a footnote definition.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node - Node.
|
||||||
*/
|
*/
|
||||||
function validate(node) {
|
function validate(node) {
|
||||||
var start = position.start(node).offset;
|
var start = position.start(node).offset;
|
||||||
|
@ -43,7 +43,7 @@ function definitionSpacing(ast, file, preferred, done) {
|
|||||||
* Validate a node, either a normal definition or
|
* Validate a node, either a normal definition or
|
||||||
* a footnote definition.
|
* a footnote definition.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node - Node.
|
||||||
*/
|
*/
|
||||||
function validate(node) {
|
function validate(node) {
|
||||||
var start = position.start(node).offset;
|
var start = position.start(node).offset;
|
||||||
|
@ -83,7 +83,7 @@ function linkTitleStyle(ast, file, preferred, done) {
|
|||||||
/**
|
/**
|
||||||
* Validate a single node.
|
* Validate a single node.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node - Node.
|
||||||
*/
|
*/
|
||||||
function validate(node) {
|
function validate(node) {
|
||||||
var last = end(node).offset - 1;
|
var last = end(node).offset - 1;
|
||||||
@ -116,7 +116,6 @@ function linkTitleStyle(ast, file, preferred, done) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!preferred) {
|
if (!preferred) {
|
||||||
preferred = character;
|
preferred = character;
|
||||||
} else if (preferred !== character) {
|
} else if (preferred !== character) {
|
||||||
|
@ -81,8 +81,8 @@ function maximumLineLength(ast, file, preferred, done) {
|
|||||||
/**
|
/**
|
||||||
* Whitelist from `initial` to `final`, zero-based.
|
* Whitelist from `initial` to `final`, zero-based.
|
||||||
*
|
*
|
||||||
* @param {number} initial
|
* @param {number} initial - Start.
|
||||||
* @param {number} final
|
* @param {number} final - End.
|
||||||
*/
|
*/
|
||||||
function whitelist(initial, final) {
|
function whitelist(initial, final) {
|
||||||
initial--;
|
initial--;
|
||||||
@ -114,9 +114,9 @@ function maximumLineLength(ast, file, preferred, done) {
|
|||||||
* there’s white-space after it, they are not
|
* there’s white-space after it, they are not
|
||||||
* whitelisted.
|
* whitelisted.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node - Node.
|
||||||
* @param {number} pos
|
* @param {number} pos - Position of `node` in `parent`.
|
||||||
* @param {Node} parent
|
* @param {Node} parent - Parent of `node`.
|
||||||
*/
|
*/
|
||||||
function validateLink(node, pos, parent) {
|
function validateLink(node, pos, parent) {
|
||||||
var next = parent.children[pos + 1];
|
var next = parent.children[pos + 1];
|
||||||
|
@ -47,10 +47,10 @@ var MAX = 2;
|
|||||||
function noConsecutiveBlankLines(ast, file, preferred, done) {
|
function noConsecutiveBlankLines(ast, file, preferred, done) {
|
||||||
/**
|
/**
|
||||||
* Compare the difference between `start` and `end`,
|
* Compare the difference between `start` and `end`,
|
||||||
* and warn when that difference exceens `max`.
|
* and warn when that difference exceeds `max`.
|
||||||
*
|
*
|
||||||
* @param {Position} start
|
* @param {Position} start - Initial.
|
||||||
* @param {Position} end
|
* @param {Position} end - Final.
|
||||||
*/
|
*/
|
||||||
function compare(start, end, max) {
|
function compare(start, end, max) {
|
||||||
var diff = end.line - start.line;
|
var diff = end.line - start.line;
|
||||||
|
@ -39,7 +39,7 @@ function noDuplicateDefinitions(ast, file, preferred, done) {
|
|||||||
/**
|
/**
|
||||||
* Check `node`.
|
* Check `node`.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node - Node.
|
||||||
*/
|
*/
|
||||||
function validate(node) {
|
function validate(node) {
|
||||||
var duplicate = map[node.identifier];
|
var duplicate = map[node.identifier];
|
||||||
|
@ -90,7 +90,6 @@ function noShellDollars(ast, file, preferred, done) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,6 @@ function transformer(ast, file) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (offset === position.end(lastNode).offset) {
|
if (offset === position.end(lastNode).offset) {
|
||||||
update();
|
update();
|
||||||
update(file.toString().length - 1);
|
update(file.toString().length - 1);
|
||||||
@ -346,8 +345,8 @@ function lint(mdast, options) {
|
|||||||
/**
|
/**
|
||||||
* Get the latest state of a rule.
|
* Get the latest state of a rule.
|
||||||
*
|
*
|
||||||
* @param {string} ruleId
|
* @param {string} ruleId - Unique rule name.
|
||||||
* @param {File} [file]
|
* @param {File} [file] - File (optional)
|
||||||
*/
|
*/
|
||||||
function getState(ruleId, file) {
|
function getState(ruleId, file) {
|
||||||
var ranges = file && file.lintRanges && file.lintRanges[ruleId];
|
var ranges = file && file.lintRanges && file.lintRanges[ruleId];
|
||||||
@ -368,7 +367,7 @@ function lint(mdast, options) {
|
|||||||
/**
|
/**
|
||||||
* Store settings on `file`.
|
* Store settings on `file`.
|
||||||
*
|
*
|
||||||
* @param {File} file
|
* @param {File} file - Virtual file.
|
||||||
*/
|
*/
|
||||||
function store(file) {
|
function store(file) {
|
||||||
var ranges = file.lintRanges;
|
var ranges = file.lintRanges;
|
||||||
@ -408,8 +407,8 @@ function lint(mdast, options) {
|
|||||||
/**
|
/**
|
||||||
* Handle a new-found marker.
|
* Handle a new-found marker.
|
||||||
*
|
*
|
||||||
* @param {Object} marker
|
* @param {Object} marker - Marker context.
|
||||||
* @param {Object} parser
|
* @param {Object} parser - Parser instance.
|
||||||
*/
|
*/
|
||||||
function onparse(marker, parser) {
|
function onparse(marker, parser) {
|
||||||
var file = parser.file;
|
var file = parser.file;
|
||||||
@ -955,7 +954,7 @@ function codeBlockStyle(ast, file, preferred, done) {
|
|||||||
/**
|
/**
|
||||||
* Get the style of `node`.
|
* Get the style of `node`.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node - Node.
|
||||||
* @return {string?} - `'fenced'`, `'indented'`, or
|
* @return {string?} - `'fenced'`, `'indented'`, or
|
||||||
* `null`.
|
* `null`.
|
||||||
*/
|
*/
|
||||||
@ -1046,7 +1045,7 @@ function definitionCase(ast, file, preferred, done) {
|
|||||||
* Validate a node, either a normal definition or
|
* Validate a node, either a normal definition or
|
||||||
* a footnote definition.
|
* a footnote definition.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node - Node.
|
||||||
*/
|
*/
|
||||||
function validate(node) {
|
function validate(node) {
|
||||||
var start = position.start(node).offset;
|
var start = position.start(node).offset;
|
||||||
@ -1122,7 +1121,7 @@ function definitionSpacing(ast, file, preferred, done) {
|
|||||||
* Validate a node, either a normal definition or
|
* Validate a node, either a normal definition or
|
||||||
* a footnote definition.
|
* a footnote definition.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node - Node.
|
||||||
*/
|
*/
|
||||||
function validate(node) {
|
function validate(node) {
|
||||||
var start = position.start(node).offset;
|
var start = position.start(node).offset;
|
||||||
@ -2064,7 +2063,7 @@ function linkTitleStyle(ast, file, preferred, done) {
|
|||||||
/**
|
/**
|
||||||
* Validate a single node.
|
* Validate a single node.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node - Node.
|
||||||
*/
|
*/
|
||||||
function validate(node) {
|
function validate(node) {
|
||||||
var last = end(node).offset - 1;
|
var last = end(node).offset - 1;
|
||||||
@ -2097,7 +2096,6 @@ function linkTitleStyle(ast, file, preferred, done) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!preferred) {
|
if (!preferred) {
|
||||||
preferred = character;
|
preferred = character;
|
||||||
} else if (preferred !== character) {
|
} else if (preferred !== character) {
|
||||||
@ -2727,8 +2725,8 @@ function maximumLineLength(ast, file, preferred, done) {
|
|||||||
/**
|
/**
|
||||||
* Whitelist from `initial` to `final`, zero-based.
|
* Whitelist from `initial` to `final`, zero-based.
|
||||||
*
|
*
|
||||||
* @param {number} initial
|
* @param {number} initial - Start.
|
||||||
* @param {number} final
|
* @param {number} final - End.
|
||||||
*/
|
*/
|
||||||
function whitelist(initial, final) {
|
function whitelist(initial, final) {
|
||||||
initial--;
|
initial--;
|
||||||
@ -2760,9 +2758,9 @@ function maximumLineLength(ast, file, preferred, done) {
|
|||||||
* there’s white-space after it, they are not
|
* there’s white-space after it, they are not
|
||||||
* whitelisted.
|
* whitelisted.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node - Node.
|
||||||
* @param {number} pos
|
* @param {number} pos - Position of `node` in `parent`.
|
||||||
* @param {Node} parent
|
* @param {Node} parent - Parent of `node`.
|
||||||
*/
|
*/
|
||||||
function validateLink(node, pos, parent) {
|
function validateLink(node, pos, parent) {
|
||||||
var next = parent.children[pos + 1];
|
var next = parent.children[pos + 1];
|
||||||
@ -3052,10 +3050,10 @@ var MAX = 2;
|
|||||||
function noConsecutiveBlankLines(ast, file, preferred, done) {
|
function noConsecutiveBlankLines(ast, file, preferred, done) {
|
||||||
/**
|
/**
|
||||||
* Compare the difference between `start` and `end`,
|
* Compare the difference between `start` and `end`,
|
||||||
* and warn when that difference exceens `max`.
|
* and warn when that difference exceeds `max`.
|
||||||
*
|
*
|
||||||
* @param {Position} start
|
* @param {Position} start - Initial.
|
||||||
* @param {Position} end
|
* @param {Position} end - Final.
|
||||||
*/
|
*/
|
||||||
function compare(start, end, max) {
|
function compare(start, end, max) {
|
||||||
var diff = end.line - start.line;
|
var diff = end.line - start.line;
|
||||||
@ -3174,7 +3172,7 @@ function noDuplicateDefinitions(ast, file, preferred, done) {
|
|||||||
/**
|
/**
|
||||||
* Check `node`.
|
* Check `node`.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node - Node.
|
||||||
*/
|
*/
|
||||||
function validate(node) {
|
function validate(node) {
|
||||||
var duplicate = map[node.identifier];
|
var duplicate = map[node.identifier];
|
||||||
@ -4273,7 +4271,6 @@ function noShellDollars(ast, file, preferred, done) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
package.json
10
package.json
@ -33,12 +33,12 @@
|
|||||||
"LICENSE"
|
"LICENSE"
|
||||||
],
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"browserify": "^10.0.0",
|
"browserify": "^11.0.0",
|
||||||
"dox": "^0.8.0",
|
"dox": "^0.8.0",
|
||||||
"eslint": "^0.24.0",
|
"eslint": "^1.0.0",
|
||||||
"esmangle": "^1.0.0",
|
"esmangle": "^1.0.0",
|
||||||
"istanbul": "^0.3.0",
|
"istanbul": "^0.3.0",
|
||||||
"jscs": "^1.0.0",
|
"jscs": "^2.0.0",
|
||||||
"jscs-jsdoc": "^1.0.0",
|
"jscs-jsdoc": "^1.0.0",
|
||||||
"mdast": "^0.28.0",
|
"mdast": "^0.28.0",
|
||||||
"mdast-github": "^0.3.0",
|
"mdast-github": "^0.3.0",
|
||||||
@ -53,8 +53,8 @@
|
|||||||
"test-coverage": "istanbul cover _mocha -- --check-leaks test/index.js",
|
"test-coverage": "istanbul cover _mocha -- --check-leaks test/index.js",
|
||||||
"test-travis": "npm run test-coveralls",
|
"test-travis": "npm run test-coveralls",
|
||||||
"test": "npm run test-api",
|
"test": "npm run test-api",
|
||||||
"lint-api": "eslint index.js lib test",
|
"lint-api": "eslint .",
|
||||||
"lint-style": "jscs --reporter inline index.js lib test",
|
"lint-style": "jscs . --reporter inline",
|
||||||
"lint": "npm run lint-api && npm run lint-style",
|
"lint": "npm run lint-api && npm run lint-style",
|
||||||
"make": "npm run lint && npm run test-coverage",
|
"make": "npm run lint && npm run test-coverage",
|
||||||
"build-rules": "node script/build-rule-documentation.js",
|
"build-rules": "node script/build-rule-documentation.js",
|
||||||
|
@ -27,6 +27,13 @@ var additional = require('./additional.json');
|
|||||||
|
|
||||||
var exists = fs.existsSync;
|
var exists = fs.existsSync;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the first tag in `tags` with a type set to `key`.
|
||||||
|
*
|
||||||
|
* @param {Array.<Object>} tags - List of tags.
|
||||||
|
* @param {string} key - Type of tag.
|
||||||
|
* @return {Object?} - Tag, when found.
|
||||||
|
*/
|
||||||
function find(tags, key) {
|
function find(tags, key) {
|
||||||
var value = null;
|
var value = null;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ var dirname = path.dirname;
|
|||||||
/**
|
/**
|
||||||
* Create a `File` from a `filePath`.
|
* Create a `File` from a `filePath`.
|
||||||
*
|
*
|
||||||
* @param {string} filePath
|
* @param {string} filePath - Path to file.
|
||||||
* @return {File}
|
* @return {File}
|
||||||
*/
|
*/
|
||||||
function toFile(filePath) {
|
function toFile(filePath) {
|
||||||
@ -51,7 +51,7 @@ function toFile(filePath) {
|
|||||||
/**
|
/**
|
||||||
* Shortcut.
|
* Shortcut.
|
||||||
*
|
*
|
||||||
* @param {string} filePath
|
* @param {string} filePath - Path to `file`.
|
||||||
* @param {Object?} options - Passed to `mdast-lint`
|
* @param {Object?} options - Passed to `mdast-lint`
|
||||||
* @param {Object?} settings - Passed to `mdast`
|
* @param {Object?} settings - Passed to `mdast`
|
||||||
* @param {boolean?} shouldClean - Uses `clean` plugin,
|
* @param {boolean?} shouldClean - Uses `clean` plugin,
|
||||||
@ -257,7 +257,6 @@ describe('External', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Validate gaps are ignored.
|
* Validate gaps are ignored.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user