unified-lint-rule
Advanced tools
Comparing version 1.0.2 to 1.0.3
102
index.js
@@ -1,39 +0,39 @@ | ||
'use strict'; | ||
'use strict' | ||
var wrapped = require('wrapped'); | ||
var wrapped = require('wrapped') | ||
module.exports = factory; | ||
module.exports = factory | ||
function factory(id, rule) { | ||
var parts = id.split(':'); | ||
var source = parts[0]; | ||
var ruleId = parts[1]; | ||
var fn = wrapped(rule); | ||
var parts = id.split(':') | ||
var source = parts[0] | ||
var ruleId = parts[1] | ||
var fn = wrapped(rule) | ||
/* istanbul ignore if - possibly useful if externalised later. */ | ||
if (!ruleId) { | ||
ruleId = source; | ||
source = null; | ||
ruleId = source | ||
source = null | ||
} | ||
attacher.displayName = id; | ||
attacher.displayName = id | ||
return attacher; | ||
return attacher | ||
function attacher(raw) { | ||
var config = coerce(ruleId, raw); | ||
var severity = config[0]; | ||
var options = config[1]; | ||
var fatal = severity === 2; | ||
var config = coerce(ruleId, raw) | ||
var severity = config[0] | ||
var options = config[1] | ||
var fatal = severity === 2 | ||
return severity ? transformer : undefined; | ||
return severity ? transformer : undefined | ||
function transformer(tree, file, next) { | ||
var index = file.messages.length; | ||
var index = file.messages.length | ||
fn(tree, file, options, done); | ||
fn(tree, file, options, done) | ||
function done(err) { | ||
var messages = file.messages; | ||
var message; | ||
var messages = file.messages | ||
var message | ||
@@ -44,3 +44,3 @@ /* Add the error, if not already properly added. */ | ||
try { | ||
file.fail(err); | ||
file.fail(err) | ||
} catch (err) {} | ||
@@ -50,11 +50,11 @@ } | ||
while (index < messages.length) { | ||
message = messages[index]; | ||
message.ruleId = ruleId; | ||
message.source = source; | ||
message.fatal = fatal; | ||
message = messages[index] | ||
message.ruleId = ruleId | ||
message.source = source | ||
message.fatal = fatal | ||
index++; | ||
index++ | ||
} | ||
next(); | ||
next() | ||
} | ||
@@ -67,38 +67,36 @@ } | ||
function coerce(name, value) { | ||
var def = 1; | ||
var result; | ||
var level; | ||
var def = 1 | ||
var result | ||
var level | ||
/* istanbul ignore if - Handled by unified in v6.0.0 */ | ||
if (typeof value === 'boolean') { | ||
result = [value]; | ||
result = [value] | ||
} else if (value == null) { | ||
result = [def]; | ||
result = [def] | ||
} else if ( | ||
typeof value === 'object' && | ||
( | ||
typeof value[0] === 'number' || | ||
(typeof value[0] === 'number' || | ||
typeof value[0] === 'boolean' || | ||
typeof value[0] === 'string' | ||
) | ||
typeof value[0] === 'string') | ||
) { | ||
result = value.concat(); | ||
result = value.concat() | ||
} else { | ||
result = [1, value]; | ||
result = [1, value] | ||
} | ||
level = result[0]; | ||
level = result[0] | ||
if (typeof level === 'boolean') { | ||
level = level ? 1 : 0; | ||
level = level ? 1 : 0 | ||
} else if (typeof level === 'string') { | ||
if (level === 'off') { | ||
level = 0; | ||
level = 0 | ||
} else if (level === 'on' || level === 'warn') { | ||
level = 1; | ||
level = 1 | ||
} else if (level === 'error') { | ||
level = 2; | ||
level = 2 | ||
} else { | ||
level = 1; | ||
result = [level, result]; | ||
level = 1 | ||
result = [level, result] | ||
} | ||
@@ -109,10 +107,14 @@ } | ||
throw new Error( | ||
'Invalid severity `' + level + '` for `' + name + '`, ' + | ||
'expected 0, 1, or 2' | ||
); | ||
'Invalid severity `' + | ||
level + | ||
'` for `' + | ||
name + | ||
'`, ' + | ||
'expected 0, 1, or 2' | ||
) | ||
} | ||
result[0] = level; | ||
result[0] = level | ||
return result; | ||
return result | ||
} |
{ | ||
"name": "unified-lint-rule", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Create a linting rule for a unified processors", | ||
@@ -11,4 +11,4 @@ "license": "MIT", | ||
], | ||
"repository": "https://github.com/wooorm/remark-lint/tree/master/packages/unified-lint-rule", | ||
"bugs": "https://github.com/wooorm/remark-lint/issues", | ||
"repository": "https://github.com/remarkjs/remark-lint/tree/master/packages/unified-lint-rule", | ||
"bugs": "https://github.com/remarkjs/remark-lint/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
@@ -15,0 +15,0 @@ "contributors": [ |
@@ -18,6 +18,6 @@ # unified-lint-rule | ||
[lint]: https://github.com/wooorm/remark-lint | ||
[lint]: https://github.com/remarkjs/remark-lint | ||
[mit]: https://github.com/wooorm/remark-lint/blob/master/LICENSE | ||
[mit]: https://github.com/remarkjs/remark-lint/blob/master/LICENSE | ||
[author]: http://wooorm.com |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
94
3429