[Tests] run npm run lint as part of tests; fix errors.

hat tip to https://github.com/airbnb/javascript/pull/678#issuecomment-172017623
This commit is contained in:
Jordan Harband
2016-01-15 10:31:00 -08:00
parent a4845a82cf
commit ab58d3b68e
10 changed files with 43 additions and 37 deletions

View File

@@ -1,7 +1,7 @@
module.exports = {
'extends': [
extends: [
'eslint-config-airbnb/legacy',
'eslint-config-airbnb/rules/es6',
].map(require.resolve),
'rules': {}
rules: {}
};

View File

@@ -1,5 +1,5 @@
module.exports = {
'extends': [
extends: [
'eslint-config-airbnb/base',
'eslint-config-airbnb/rules/strict',
'eslint-config-airbnb/rules/react',

View File

@@ -1,5 +1,5 @@
module.exports = {
'extends': [
extends: [
'eslint-config-airbnb/rules/best-practices',
'eslint-config-airbnb/rules/errors',
'eslint-config-airbnb/rules/legacy',
@@ -7,14 +7,14 @@ module.exports = {
'eslint-config-airbnb/rules/style',
'eslint-config-airbnb/rules/variables'
].map(require.resolve),
'env': {
'browser': true,
'node': true,
'amd': false,
'mocha': false,
'jasmine': false
env: {
browser: true,
node: true,
amd: false,
mocha: false,
jasmine: false
},
'ecmaFeatures': {},
'globals': {},
'rules': {}
ecmaFeatures: {},
globals: {},
rules: {}
};

View File

@@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"lint": "eslint .",
"test": "babel-tape-runner ./test/test-*.js"
"tests-only": "babel-tape-runner ./test/test-*.js",
"test": "npm run lint && npm run tests-only"
},
"repository": {
"type": "git",

View File

@@ -0,0 +1,5 @@
{
"rules": {
"quote-props": 0
}
}

View File

@@ -13,7 +13,7 @@ module.exports = {
// require default case in switch statements
'default-case': 2,
// encourages use of dot notation whenever possible
'dot-notation': [2, { 'allowKeywords': true}],
'dot-notation': [2, { 'allowKeywords': true }],
// enforces consistent newlines before or after dots
'dot-location': 0,
// require the use of === and !==

View File

@@ -10,10 +10,10 @@ module.exports = {
'rules': {
// Prevent missing displayName in a React component definition
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md
'react/display-name': [0, {'acceptTranspilerName': false}],
'react/display-name': [0, { 'acceptTranspilerName': false }],
// Forbid certain propTypes (any, array, object)
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/forbid-prop-types.md
'react/forbid-prop-types': [0, {'forbid': ['any', 'array', 'object']}],
'react/forbid-prop-types': [0, { 'forbid': ['any', 'array', 'object'] }],
// Enforce boolean attributes notation in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-boolean-value.md
'react/jsx-boolean-value': [2, 'never'],
@@ -22,7 +22,7 @@ module.exports = {
'react/jsx-closing-bracket-location': [2, 'line-aligned'],
// Enforce or disallow spaces inside of curly braces in JSX attributes
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-curly-spacing.md
'react/jsx-curly-spacing': [0, 'never', {'allowMultiline': true}],
'react/jsx-curly-spacing': [0, 'never', { 'allowMultiline': true }],
// Enforce event handler naming conventions in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-handler-names.md
'react/jsx-handler-names': [0, {
@@ -37,13 +37,13 @@ module.exports = {
'react/jsx-key': 0,
// Limit maximum of props on a single line in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-max-props-per-line.md
'react/jsx-max-props-per-line': [0, {'maximum': 1}],
'react/jsx-max-props-per-line': [0, { 'maximum': 1 }],
// Prevent usage of .bind() and arrow functions in JSX props
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
'react/jsx-no-bind': 2,
// Prevent duplicate props in JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-duplicate-props.md
'react/jsx-no-duplicate-props': [0, {'ignoreCase': false}],
'react/jsx-no-duplicate-props': [0, { 'ignoreCase': false }],
// Prevent usage of unwrapped JSX strings
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md
'react/jsx-no-literals': 0,
@@ -67,7 +67,7 @@ module.exports = {
}],
// Prevent React to be incorrectly marked as unused
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-react.md
'react/jsx-uses-react': [2, {'pragma': 'React'}],
'react/jsx-uses-react': [2, { 'pragma': 'React' }],
// Prevent variables used in JSX to be incorrectly marked as unused
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-uses-vars.md
'react/jsx-uses-vars': 2,
@@ -76,7 +76,7 @@ module.exports = {
'react/no-danger': 0,
// Prevent usage of deprecated methods
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-deprecated.md
'react/no-deprecated': [1, {"react": "0.14.0"}],
'react/no-deprecated': [1, { 'react': '0.14.0' }],
// Prevent usage of setState in componentDidMount
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-mount-set-state.md
'react/no-did-mount-set-state': [2, 'allow-in-func'],
@@ -91,7 +91,7 @@ module.exports = {
'react/no-is-mounted': 2,
// Prevent multiple component definition per file
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
'react/no-multi-comp': [2, {'ignoreStateless': true}],
'react/no-multi-comp': [2, { 'ignoreStateless': true }],
// Prevent usage of setState
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-set-state.md
'react/no-set-state': 0,
@@ -106,13 +106,13 @@ module.exports = {
'react/prefer-es6-class': [2, 'always'],
// Prevent missing props validation in a React component definition
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md
'react/prop-types': [2, {'ignore': [], customValidators: []}],
'react/prop-types': [2, { 'ignore': [], customValidators: [] }],
// Prevent missing React when using JSX
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/react-in-jsx-scope.md
'react/react-in-jsx-scope': 2,
// Restrict file extensions that may be required
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/require-extension.md
'react/require-extension': [0, {'extensions': ['.jsx']}],
'react/require-extension': [0, { 'extensions': ['.jsx'] }],
// Prevent extra closing tags for components without children
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/self-closing-comp.md
'react/self-closing-comp': 2,

View File

@@ -3,11 +3,11 @@ module.exports = {
// enforce spacing inside array brackets
'array-bracket-spacing': [2, 'never'],
// enforce one true brace style
'brace-style': [2, '1tbs', {'allowSingleLine': true }],
'brace-style': [2, '1tbs', { 'allowSingleLine': true }],
// require camel case names
'camelcase': [2, {'properties': 'never'}],
'camelcase': [2, { 'properties': 'never' }],
// enforce spacing before and after comma
'comma-spacing': [2, {'before': false, 'after': true}],
'comma-spacing': [2, { 'before': false, 'after': true }],
// enforce one true comma style
'comma-style': [2, 'last'],
// disallow padding inside computed properties
@@ -20,16 +20,17 @@ module.exports = {
'func-names': 1,
// enforces use of function declarations or expressions
'func-style': 0,
// this option enforces minimum and maximum identifier lengths (variable names, property names etc.)
// this option enforces minimum and maximum identifier lengths
// (variable names, property names etc.)
'id-length': 0,
// this option sets a specific tab width for your code
// https://github.com/eslint/eslint/blob/master/docs/rules/indent.md
'indent': [2, 2, { "SwitchCase": 1, "VariableDeclarator": 1 }],
'indent': [2, 2, { 'SwitchCase': 1, 'VariableDeclarator': 1 }],
// specify whether double or single quotes should be used in JSX attributes
// http://eslint.org/docs/rules/jsx-quotes
'jsx-quotes': [2, 'prefer-double'],
// enforces spacing between keys and values in object literal properties
'key-spacing': [2, {'beforeColon': false, 'afterColon': true}],
'key-spacing': [2, { 'beforeColon': false, 'afterColon': true }],
// enforces empty lines around comments
'lines-around-comment': 0,
// disallow mixed 'LF' and 'CRLF' as linebreaks
@@ -43,7 +44,7 @@ module.exports = {
// specify the maximum depth callbacks can be nested
'max-nested-callbacks': 0,
// require a capital letter for constructors
'new-cap': [2, {'newIsCap': true}],
'new-cap': [2, { 'newIsCap': true }],
// disallow the omission of parentheses when invoking a constructor with no arguments
'new-parens': 0,
// allow/disallow an empty newline after var statement
@@ -59,7 +60,7 @@ module.exports = {
// disallow mixed spaces and tabs for indentation
'no-mixed-spaces-and-tabs': 2,
// disallow multiple empty lines and only one newline at the end
'no-multiple-empty-lines': [2, {'max': 2, 'maxEOF': 1}],
'no-multiple-empty-lines': [2, { 'max': 2, 'maxEOF': 1 }],
// disallow nested ternary expressions
'no-nested-ternary': 2,
// disallow use of the Object constructor
@@ -92,7 +93,7 @@ module.exports = {
// require identifiers to match the provided regular expression
'id-match': 0,
// enforce spacing before and after semicolons
'semi-spacing': [2, {'before': false, 'after': true}],
'semi-spacing': [2, { 'before': false, 'after': true }],
// require or disallow use of semicolons instead of ASI
'semi': [2, 'always'],
// sort variables within the same declaration block

View File

@@ -19,7 +19,7 @@ module.exports = {
// disallow use of undefined variable
'no-undefined': 0,
// disallow declaration of variables that are not used in the code
'no-unused-vars': [2, {'vars': 'local', 'args': 'after-used'}],
'no-unused-vars': [2, { 'vars': 'local', 'args': 'after-used' }],
// disallow use of variables before they are defined
'no-use-before-define': 2
}

View File

@@ -1,7 +1,6 @@
import test from 'tape';
import { CLIEngine } from 'eslint';
import eslintrc from '../';
import baseConfig from '../base';
import reactRules from '../rules/react';
const cli = new CLIEngine({
@@ -9,7 +8,7 @@ const cli = new CLIEngine({
baseConfig: eslintrc,
// This rule fails when executing on text.
rules: {indent: 0},
rules: { indent: 0 },
});
function lint(text) {