eslint-plugin-playlyfe
Version:
custom eslint stuff for playlyfe
376 lines (374 loc) • 13.5 kB
JavaScript
;
module.exports = {
plugins: ['playlyfe'],
rules: {
'array-bracket-newline': ['error', {
multiline: true
}],
// enforce spacing inside array brackets
'array-bracket-spacing': ['error', 'never'],
'playlyfe/babel-array-bracket-spacing': 'off',
'array-element-newline': ['off'],
// enforce spacing inside single-line blocks
// http://eslint.org/docs/rules/block-spacing
'block-spacing': ['error', 'always'],
// enforce one true brace style
'brace-style': ['error', '1tbs', {
allowSingleLine: true
}],
// no use
'capitalized-comments': 'off',
// require camel case names
camelcase: ['error', {
properties: 'always'
}],
// TODO: enable when we required this rule
'playlyfe/babel-camelcase': 'off',
// enforce comma
'comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline'
}],
'playlyfe/babel-func-params-comma-dangle': 'off',
// deprecated
// enforce spacing before and after comma
'comma-spacing': ['error', {
before: false,
after: true
}],
// enforce one true comma style
'comma-style': ['error', 'last'],
// disallow padding inside computed properties
'computed-property-spacing': ['error', 'never'],
// enforces consistent naming when capturing the current execution context
// we use arrow function so there is no need
'consistent-this': 'error',
// enforce newline at the end of file, with no multiple empty lines
'eol-last': 'error',
// enforce spacing between functions and their invocations
// http://eslint.org/docs/rules/func-call-spacing
'func-call-spacing': ['error', 'never'],
// we use arrow functions
'func-name-matching': 'off',
// require function expressions to have a name
'func-names': ['error', 'always'],
// enforces use of function declarations or expressions
// http://eslint.org/docs/rules/func-style
// TODO: enable
'func-style': ['error', 'declaration', {
allowArrowFunctions: true
}],
'function-paren-newline': ['error', 'multiline'],
// Blacklist certain identifiers to prevent them being used
// http://eslint.org/docs/rules/id-blacklist
// can be enabled per project basis
'id-blacklist': 'off',
// this option enforces minimum and maximum identifier lengths
// (variable names, property names etc.)
// Todo: enable
'id-length': 'off',
// require identifiers to match the provided regular expression
'id-match': 'off',
'implicit-arrow-linebreak': ['error', 'below'],
// this option sets a specific tab width for your code
// http://eslint.org/docs/rules/indent
'indent-legacy': 'off',
indent: ['error', 2, {
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
MemberExpression: 1,
FunctionDeclaration: {
parameters: 1,
body: 1
},
FunctionExpression: {
parameters: 1,
body: 1
},
CallExpression: {
arguments: 1
},
ArrayExpression: 1,
ObjectExpression: 1
}],
// specify whether double or single quotes should be used in JSX attributes
// http://eslint.org/docs/rules/jsx-quotes
// already defined in react
'jsx-quotes': 'off',
// enforces spacing between keys and values in object literal properties
'key-spacing': ['error', {
beforeColon: false,
afterColon: true
}],
// require a space before & after certain keywords
'keyword-spacing': ['error', {
before: true,
after: true,
overrides: {
return: {
after: true
},
throw: {
after: true
},
case: {
after: true
}
}
}],
// enforce position of line comments
// http://eslint.org/docs/rules/line-comment-position
// TODO: enable?
'line-comment-position': ['off', {
position: 'above',
ignorePattern: '',
applyDefaultPatterns: true
}],
// disallow mixed 'LF' and 'CRLF' as linebreaks
// http://eslint.org/docs/rules/linebreak-style
'linebreak-style': ['error', 'unix'],
// enforces empty lines around comments
// TODO: enable ?
'lines-around-comment': 'off',
'lines-between-class-members': ['error', 'always', {
exceptAfterSingleLine: true
}],
// require or disallow newlines around directives
// http://eslint.org/docs/rules/lines-around-directive
'lines-around-directive': ['error', {
before: 'always',
after: 'always'
}],
// specify the maximum depth that blocks can be nested
'max-depth': ['error', 4],
// specify the maximum length of a line in your program
// http://eslint.org/docs/rules/max-len
'max-len': ['error', 100, 2, {
ignoreUrls: true,
ignoreComments: true,
ignoreStrings: true,
ignoreTemplateLiterals: true
}],
// specify the max number of lines in a file
// http://eslint.org/docs/rules/max-lines
// very strict rule so not enabling for now
'max-lines': ['off', {
max: 300,
skipBlankLines: true,
skipComments: true
}],
'max-lines-per-function': 'off',
// specify the maximum depth callbacks can be nested
'max-nested-callbacks': 'error',
// limits the number of parameters that can be used in the function declaration.
// strict rule not enabling now
'max-params': ['off', 3],
// restrict the number of statements per line
// http://eslint.org/docs/rules/max-statements-per-line
'max-statements-per-line': ['error', {
max: 2
}],
// specify the maximum number of statement allowed in a function
'max-statements': ['off', 10],
'multiline-comment-style': 'off',
// require multiline ternary
// http://eslint.org/docs/rules/multiline-ternary
// single and multiline both are allowed in code
'multiline-ternary': ['off', 'always'],
// require a capital letter for constructors
'new-cap': ['off', {
newIsCap: true
}],
// cause issues with decorators
'playlyfe/babel-new-cap': ['off', {
newIsCap: true
}],
// disallow the omission of parentheses when invoking a constructor with no arguments
// http://eslint.org/docs/rules/new-parens
'new-parens': 'error',
// allow/disallow an empty newline after var statement
'newline-after-var': 'off',
// http://eslint.org/docs/rules/newline-before-return
'newline-before-return': 'off',
// enforces new line after each method call in the chain to make it
// more readable and easy to maintain
// http://eslint.org/docs/rules/newline-per-chained-call
'newline-per-chained-call': ['error', {
ignoreChainWithDepth: 2
}],
// disallow use of the Array constructor
'no-array-constructor': 'error',
// disallow use of bitwise operators
// http://eslint.org/docs/rules/no-bitwise
'no-bitwise': 'error',
// disallow use of the continue statement
// http://eslint.org/docs/rules/no-continue
'no-continue': 'error',
// disallow comments inline after code
'no-inline-comments': 'off',
// disallow if as the only statement in an else block
// http://eslint.org/docs/rules/no-lonely-if
'no-lonely-if': 'error',
// disallow un-paren'd mixes of different operators
// http://eslint.org/docs/rules/no-mixed-operators
'no-mixed-operators': ['error', {
groups: [['+', '-', '*', '/', '%', '**'], ['&', '|', '^', '~', '<<', '>>', '>>>'], ['==', '!=', '===', '!==', '>', '>=', '<', '<='], ['&&', '||'], ['in', 'instanceof']],
allowSamePrecedence: false
}],
// disallow mixed spaces and tabs for indentation
'no-mixed-spaces-and-tabs': 'error',
'no-multi-assign': 'error',
// disallow multiple empty lines and only one newline at the end
'no-multiple-empty-lines': ['error', {
max: 2,
maxEOF: 1
}],
// disallow negated conditions
// http://eslint.org/docs/rules/no-negated-condition
'no-negated-condition': 'error',
// disallow nested ternary expressions
'no-nested-ternary': 'error',
// disallow use of the Object constructor
'no-new-object': 'error',
// disallow use of unary operators, ++ and --
// http://eslint.org/docs/rules/no-plusplus
'no-plusplus': 'error',
// disallow certain syntax forms
// http://eslint.org/docs/rules/no-restricted-syntax
'no-restricted-syntax': 'off',
// disallow space between function identifier and application
'no-spaced-func': 'error',
// disallow tab characters entirely
'no-tabs': 'error',
// disallow the use of ternary operators
'no-ternary': 'off',
// disallow trailing whitespace at the end of lines
'no-trailing-spaces': 'error',
// disallow dangling underscores in identifiers
'no-underscore-dangle': ['off', {
allowAfterThis: false
}],
// disallow the use of Boolean literals in conditional expressions
// also, prefer `a || b` over `a ? a : b`
// http://eslint.org/docs/rules/no-unneeded-ternary
'no-unneeded-ternary': ['error', {
defaultAssignment: true
}],
// disallow whitespace before properties
// http://eslint.org/docs/rules/no-whitespace-before-property
'no-whitespace-before-property': 'error',
'nonblock-statement-body-position': 'off',
// enforce line breaks between braces
// http://eslint.org/docs/rules/object-curly-newline
'object-curly-newline': ['error', {
ObjectExpression: {
minProperties: 0,
multiline: true
},
ObjectPattern: {
minProperties: 0,
multiline: true
}
}],
// require padding inside curly braces
'object-curly-spacing': ['off', 'always'],
'playlyfe/babel-object-curly-spacing': ['error', 'always'],
// enforce "same line" or "multiple line" on object properties.
// http://eslint.org/docs/rules/object-property-newline
'object-property-newline': ['error', {
allowMultiplePropertiesPerLine: true
}],
// allow just one var statement per function
'one-var': ['error', 'never'],
// require a newline around variable declaration
// http://eslint.org/docs/rules/one-var-declaration-per-line
'one-var-declaration-per-line': ['error', 'always'],
// require assignment operator shorthand where possible or prohibit it entirely
// http://eslint.org/docs/rules/operator-assignment
'operator-assignment': ['error', 'always'],
// enforce operators to be placed before or after line breaks
'operator-linebreak': ['error', 'after', {
overrides: {
'?': 'before',
':': 'before'
}
}],
// enforce padding within blocks
'padded-blocks': ['error', 'never'],
// TODO: enable?
'padding-line-between-statements': 'off',
'prefer-object-spread': 'error',
// require quotes around object literal property names
// http://eslint.org/docs/rules/quote-props.html
'quote-props': ['error', 'as-needed', {
keywords: false,
unnecessary: true,
numbers: false
}],
// specify whether double or single quotes should be used
quotes: ['error', 'single', {
avoidEscape: true
}],
'playlyfe/babel-quotes': ['error', 'single', {
avoidEscape: true
}],
// do not require jsdoc
// http://eslint.org/docs/rules/require-jsdoc
'require-jsdoc': 'off',
// require or disallow use of semicolons instead of ASI
semi: ['off', 'always'],
'playlyfe/babel-semi': ['error', 'always'],
// enforce spacing before and after semicolons
'semi-spacing': ['error', {
before: false,
after: true
}],
'semi-style': ['error', 'last'],
// requires object keys to be sorted
'sort-keys': ['off', 'asc', {
caseSensitive: false,
natural: true
}],
// sort variables within the same declaration block
'sort-vars': 'off',
// require or disallow space before blocks
'space-before-blocks': 'error',
// require or disallow space before function opening parenthesis
// http://eslint.org/docs/rules/space-before-function-paren
'space-before-function-paren': ['error', {
anonymous: 'always',
named: 'never'
}],
// require or disallow spaces inside parentheses
'space-in-parens': ['error', 'never'],
// require spaces around operators
'space-infix-ops': 'error',
// Require or disallow spaces before/after unary operators
// http://eslint.org/docs/rules/space-unary-ops
'space-unary-ops': ['error', {
words: true,
nonwords: false,
overrides: {}
}],
// require or disallow a space immediately following the // or /* in a comment
'spaced-comment': ['error', 'always', {
exceptions: ['-', '+'],
markers: ['=', '!'] // space here to support sprockets directives
}],
'switch-colon-spacing': ['error', {
after: true,
before: false
}],
'template-tag-spacing': ['error', 'never'],
// require or disallow the Unicode Byte Order Mark
// http://eslint.org/docs/rules/unicode-bom
'unicode-bom': ['error', 'never'],
// require regex literals to be wrapped in parentheses
'wrap-regex': 'off',
'playlyfe/babel-flow-object-type': 'off'
}
};