cba4c7042d
This enables the function form of the "use strict" invocation. In general, 'strict' is considered a good practice, so enabling it is good. Requiring the function method of use strict avoid a common bug encountered with a global strict declaration, where the rule applies to all javascript that comes after the global "use strict" statement. Using the function method prevents brittleness, by creating a scope around the 'strict' case. http://eslint.org/docs/rules/strict Change-Id: I5c89c26d2d7a38c342e7c8f49f8cabe145dd02c0
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
describe("Unit: eslint-config-openstack", function() {
|
|
"use strict";
|
|
|
|
it("should set espree as the default parser.", function() {
|
|
var config = require('../index');
|
|
expect(config.parser).toEqual('espree');
|
|
});
|
|
|
|
it("should disable all ecma6 features.", function() {
|
|
var config = require('../index');
|
|
|
|
var keys = Object.keys(config.ecmaFeatures);
|
|
|
|
keys.forEach(function(key) {
|
|
expect(config.ecmaFeatures[key]).toBeFalsy();
|
|
});
|
|
});
|
|
|
|
it("should disable all environments.", function() {
|
|
var config = require('../index');
|
|
expect(config.env).toBeFalsy();
|
|
});
|
|
|
|
it("should alert on rule replacements.", function() {
|
|
var eslintReplacements = require('eslint/conf/replacements.json');
|
|
var rules = require('../index').rules;
|
|
|
|
/*eslint-disable guard-for-in */
|
|
for (var ruleName in eslintReplacements) {
|
|
expect(rules.hasOwnProperty(ruleName))
|
|
.toBeFalsy("Rule " + ruleName + " has been replaced:", eslintReplacements[ruleName]);
|
|
}
|
|
/*eslint-enable guard-for-in */
|
|
});
|
|
|
|
it("should have an opinion on every eslint default rule.", function() {
|
|
var eslintDefaults = require('eslint/conf/eslint.json');
|
|
var rules = require('../index').rules;
|
|
|
|
/*eslint-disable guard-for-in */
|
|
for (var ruleName in eslintDefaults.rules) {
|
|
expect(rules.hasOwnProperty(ruleName))
|
|
.toBeTruthy("Rule " + ruleName + " must be defined.");
|
|
}
|
|
/*eslint-enable guard-for-in */
|
|
});
|
|
|
|
it("should only have opinions on rules that exist (no zombies).", function() {
|
|
var eslintRules = require('eslint/conf/eslint.json').rules;
|
|
var openstackRules = require('../index').rules;
|
|
|
|
/*eslint-disable guard-for-in */
|
|
for (var ruleName in openstackRules) {
|
|
expect(eslintRules.hasOwnProperty(ruleName))
|
|
.toBeTruthy("Rule " + ruleName + " is a zombie.");
|
|
}
|
|
/*eslint-enable guard-for-in */
|
|
});
|
|
});
|