Skip to content

Instantly share code, notes, and snippets.

@jschaf
Last active September 1, 2016 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jschaf/8ce46b7363510777f66b7a8eab730b43 to your computer and use it in GitHub Desktop.
Save jschaf/8ce46b7363510777f66b7a8eab730b43 to your computer and use it in GitHub Desktop.
test
const ERROR = 2;
module.exports = {
extends: [],
parserOptions: {
ecmaVersion: 6,
sourceType: 'script',
},
plugins: [
'no-loops',
],
ecmaFeatures: {
arrowFunctions: true,
},
rules: {
'no-irregular-whitespace': ERROR,
'no-tabs': ERROR,
'no-loops/no-loops': ERROR,
},
}
{
"name": "my-repo",
"version": "0.0.1",
"description": "repo test",
"main": "index.js",
"dependencies": {
"eslint-plugin-no-loops": "^0.3.0"
},
"devDependencies": {
"eslint": "^3.3.1",
"mocha": "^3.0.2"
},
"peerDependencies": {},
"engines": {
"node": ">= 4"
},
"scripts": {
"test": "mocha test.js"
}
}
/**
* @fileoverview Tests for whitespace characters.
*/
const myConfig = require('./index.js');
const emptyRule = {
meta: {
docs: {
description: 'Empty Rule to allow testing the entire config.',
category: 'Stylistic Issues',
},
schema: [],
},
create(context) { return {}; },
};
const RuleTester = require('eslint').RuleTester;
RuleTester.setDefaultConfig(myConfig);
const ruleTester = new RuleTester();
ruleTester.run('whitespace-characters', emptyRule, {
valid: [
'var foo = 2;',
'let foo = 2;',
'const bar = 3;',
],
invalid: [
{
code: '\t let foo = 2;',
errors: 1,
},
],
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment