UNPKG

eslint-config-weirdpattern

Version:

ESLint shareable config for JavaScript projects

139 lines (135 loc) 4.74 kB
/** * Copyright (c) 2017, WeirdPattern * All rights reserved. * * This source code is licensed under the MIT-style license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; const { error, off, warn } = require('../utils/reporter'); module.exports = { rules: { 'array-bracket-spacing': warn('never'), 'block-spacing': warn('always'), 'brace-style': warn('1tbs', { allowSingleLine: true }), 'camelcase': warn({ properties: 'always' }), 'capitalized-comments': off(), 'comma-dangle': warn({ arrays: 'always-multiline', objects: 'always-multiline', imports: 'never', exports: 'never', functions: 'never', }), 'comma-spacing': warn({ before: false, after: true }), 'comma-style': warn('last'), 'computed-property-spacing': warn('never'), 'consistent-this': warn('self'), 'eol-last': warn('always'), 'func-call-spacing': warn('never'), 'func-name-matching': warn(), 'func-names': warn('always'), 'func-style': off(), 'id-blacklist': off(), 'id-length': off(), 'id-match': off(), 'indent': warn(2, { SwitchCase: 1, VariableDeclarator: { var: 2, let: 2, const: 3, }, outerIIFEBody: 1, MemberExpression: 1, FunctionDeclaration: { parameters: 'first' }, FunctionExpression: { parameters: 'first' }, }), 'jsx-quotes': warn('prefer-single'), 'key-spacing': warn({ beforeColon: false, afterColon: true, mode: 'strict' }), 'keyword-spacing': warn({ before: true, after: true }), 'line-comment-position': off(), 'linebreak-style': off(), 'lines-around-comment': off(), 'lines-around-directive': warn('always'), 'max-depth': warn(4), 'max-len': warn({ code: 120, ignoreUrls: true, ignoreTrailingComments: true, ignoreTemplateLiterals: true, ignoreRegExpLiterals: true, }), 'max-lines': warn({ max: 300, skipBlankLines: true, skipComments: true }), 'max-nested-callbacks': warn({ max: 10 }), 'max-params': error({ max: 3 }), 'max-statements': warn(10, { ignoreTopLevelFunctions: true }), 'max-statements-per-line': warn({ max: 1 }), 'multiline-ternary': off(), 'new-cap': warn({ newIsCap: true, capIsNew: true }), 'new-parens': warn(), 'newline-after-var': off(), 'newline-before-return': off(), 'newline-per-chained-call': warn(), 'no-array-constructor': warn(), 'no-bitwise': off(), 'no-continue': off(), 'no-inline-comments': off(), 'no-lonely-if': warn(), 'no-mixed-operators': warn({ groups: [ ['+', '-', '*', '/', '%', '**'], ['&', '|', '^', '~', '<<', '>>', '>>>'], ['==', '!=', '===', '!==', '>', '>=', '<', '<='], ['&&', '||'], ['in', 'instanceof'], ], allowSamePrecedence: true, }), 'no-multi-assign': off(), 'no-multiple-empty-lines': warn({ max: 1 }), 'no-negated-condition': warn(), 'no-nested-ternary': warn(), 'no-new-object': warn(), 'no-plusplus': off(), 'no-restricted-syntax': warn('WithStatement'), 'no-tabs': warn(), 'no-ternary': off(), 'no-trailing-spaces': warn({ skipBlankLines: false }), 'no-underscore-dangle': warn(), 'no-unneeded-ternary': warn({ defaultAssignment: false }), 'no-whitespace-before-property': warn(), 'nonblock-statement-body-position': warn('beside'), 'object-curly-newline': warn({ multiline: true }), 'object-curly-spacing': warn('always', { arraysInObjects: true, objectsInObjects: true }), 'object-property-newline': off(), 'one-var': error('never'), 'one-var-declaration-per-line': error('always'), 'operator-assignment': warn('always'), 'operator-linebreak': warn('after', { overrides: { '?': 'ignore', ':': 'ignore' } }), 'padded-blocks': off(), 'quote-props': warn('consistent-as-needed'), 'quotes': warn('single'), 'require-jsdoc': warn({ require: { FunctionDeclaration: true, MethodDefinition: true, ClassDeclaration: true, ArrowFunctionExpression: true, }, }), 'semi': error('always'), 'semi-spacing': warn({ before: false, after: true }), 'sort-keys': off(), 'sort-vars': off(), 'space-before-blocks': warn('always'), 'space-before-function-paren': warn({ anonymous: 'never', named: 'never', asyncArrow: 'always' }), 'space-in-parens': warn('never'), 'space-infix-ops': warn(), 'space-unary-ops': warn({ words: true, nonwords: false }), 'spaced-comment': warn('always'), 'template-tag-spacing': warn('never'), 'unicode-bom': warn('never'), 'wrap-regex': off(), }, };