eslint-config-hapi
Advanced tools
Comparing version 6.0.0 to 6.1.0
@@ -52,3 +52,2 @@ 'use strict'; | ||
'no-mixed-spaces-and-tabs': 2, | ||
'no-use-before-define': 2, | ||
'space-after-keywords': 2, | ||
@@ -55,0 +54,0 @@ 'semi': [2, 'always'], |
{ | ||
"name": "eslint-config-hapi", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "Shareable ESLint config for the hapi ecosystem", | ||
@@ -5,0 +5,0 @@ "author": "Continuation Labs <contact@continuation.io> (http://continuation.io/)", |
@@ -18,1 +18,11 @@ # eslint-config-hapi | ||
**Note:** `eslint-plugin-hapi` is a plugin containing custom hapi linting rules. It is a peer dependency because of the way ESLint handles shareable configs that include plugins and custom rules (see [eslint/eslint#3458](https://github.com/eslint/eslint/issues/3458) and [eslint/eslint#2518](https://github.com/eslint/eslint/issues/2518) for more background). | ||
## Working with ES5 | ||
By default, `eslint-config-hapi` enforces several rules that require ES6 features. If you would like to use `eslint-config-hapi`, but are unable to abandon ES5, you can use ES5 config. To use this config, add `eslint-config-hapi` and `eslint-plugin-hapi` to your `package.json`. Then, in your ESLint configuration add: | ||
``` | ||
{ | ||
"extends": "eslint-config-hapi/lib/es5" | ||
} | ||
``` |
@@ -8,2 +8,3 @@ 'use strict'; | ||
var Config = require('../lib'); | ||
var Es5Config = require('../lib/es5'); | ||
var CLIEngine = ESLint.CLIEngine; | ||
@@ -19,11 +20,11 @@ | ||
function getLinter () { | ||
function getLinter (config) { | ||
return new CLIEngine({ | ||
useEslintrc: false, | ||
baseConfig: Config | ||
baseConfig: config || Config | ||
}); | ||
} | ||
function lintFile (file) { | ||
var cli = getLinter(); | ||
function lintFile (file, config) { | ||
var cli = getLinter(config); | ||
var data = Fs.readFileSync(Path.join(__dirname, file), 'utf8'); | ||
@@ -286,34 +287,2 @@ | ||
it('enforces no-use-before-define rule', function (done) { | ||
var output = lintFile('fixtures/no-use-before-define.js'); | ||
var results = output.results[0]; | ||
expect(output.errorCount).to.equal(2); | ||
expect(output.warningCount).to.equal(0); | ||
expect(results.errorCount).to.equal(2); | ||
expect(results.warningCount).to.equal(0); | ||
var msg = results.messages[0]; | ||
expect(msg.ruleId).to.equal('no-use-before-define'); | ||
expect(msg.severity).to.equal(2); | ||
expect(msg.message).to.equal('foo was used before it was defined'); | ||
expect(msg.line).to.equal(3); | ||
expect(msg.column).to.equal(1); | ||
expect(msg.nodeType).to.equal('Identifier'); | ||
expect(msg.source).to.equal('foo();'); | ||
msg = results.messages[1]; | ||
expect(msg.ruleId).to.equal('no-use-before-define'); | ||
expect(msg.severity).to.equal(2); | ||
expect(msg.message).to.equal('bar was used before it was defined'); | ||
expect(msg.line).to.equal(4); | ||
expect(msg.column).to.equal(1); | ||
expect(msg.nodeType).to.equal('Identifier'); | ||
expect(msg.source).to.equal('bar = 5;'); | ||
done(); | ||
}); | ||
it('enforces prefer-const', function (done) { | ||
@@ -488,2 +457,14 @@ var output = lintFile('fixtures/prefer-const.js'); | ||
}); | ||
it('supports ES5 linting', function (done) { | ||
var output = lintFile('fixtures/es5.js', Es5Config); | ||
var results = output.results[0]; | ||
expect(output.errorCount).to.equal(0); | ||
expect(output.warningCount).to.equal(0); | ||
expect(results.errorCount).to.equal(0); | ||
expect(results.warningCount).to.equal(0); | ||
expect(results.messages).to.deep.equal([]); | ||
done(); | ||
}); | ||
}); |
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
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
29
28
25984
633