@perfective/eslint-config
Version:
ESLint shareable rules configuration
200 lines • 7.12 kB
JavaScript
import eslintPluginStylisticJs from '@stylistic/eslint-plugin-js';
export function stylisticJsConfig() {
return {
plugins: {
'@stylistic/js': eslintPluginStylisticJs
},
rules: {
'@stylistic/js/array-bracket-newline': ['warn', 'consistent'],
'@stylistic/js/array-bracket-spacing': ['warn', 'never'],
'@stylistic/js/array-element-newline': ['warn', 'consistent'],
'@stylistic/js/arrow-parens': ['warn', 'as-needed'],
'@stylistic/js/arrow-spacing': ['warn', {
before: true,
after: true
}],
'@stylistic/js/block-spacing': ['warn', 'always'],
'@stylistic/js/brace-style': ['warn', 'stroustrup', {
allowSingleLine: false
}],
'@stylistic/js/comma-dangle': ['warn', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'always-multiline'
}],
'@stylistic/js/comma-spacing': ['warn', {
before: false,
after: true
}],
'@stylistic/js/comma-style': ['warn', 'last'],
'@stylistic/js/computed-property-spacing': ['warn', 'never'],
'@stylistic/js/dot-location': ['warn', 'property'],
'@stylistic/js/eol-last': ['warn', 'always'],
'@stylistic/js/func-call-spacing': 'off',
'@stylistic/js/function-call-argument-newline': ['warn', 'consistent'],
'@stylistic/js/function-call-spacing': ['warn', 'never'],
'@stylistic/js/function-paren-newline': ['warn', 'consistent'],
'@stylistic/js/generator-star-spacing': ['warn', {
before: true,
after: false
}],
'@stylistic/js/implicit-arrow-linebreak': ['warn', 'beside'],
'@stylistic/js/indent': ['warn', 4, {
SwitchCase: 1
}],
'@stylistic/js/jsx-quotes': ['warn', 'prefer-double'],
'@stylistic/js/key-spacing': ['warn', {
beforeColon: false,
afterColon: true,
mode: 'strict'
}],
'@stylistic/js/keyword-spacing': ['warn', {
before: true,
after: true
}],
'@stylistic/js/line-comment-position': ['error', {
position: 'above',
ignorePattern: '^ == .+'
}],
'@stylistic/js/linebreak-style': ['warn', 'unix'],
'@stylistic/js/lines-around-comment': ['warn', {
beforeBlockComment: true,
afterBlockComment: false,
beforeLineComment: false,
afterLineComment: false,
allowBlockStart: false,
allowBlockEnd: false,
allowObjectStart: false,
allowObjectEnd: false,
allowArrayStart: false,
allowArrayEnd: false,
allowClassStart: true,
allowClassEnd: false,
afterHashbangComment: true
}],
'@stylistic/js/lines-between-class-members': ['warn', 'always', {
exceptAfterSingleLine: true
}],
'@stylistic/js/max-len': ['error', {
code: 120,
tabWidth: 4,
ignoreRegExpLiterals: true,
ignoreUrls: true
}],
'@stylistic/js/max-statements-per-line': ['error', {
max: 1
}],
'@stylistic/js/multiline-comment-style': ['warn', 'separate-lines', {
checkJSDoc: false
}],
'@stylistic/js/multiline-ternary': ['warn', 'always-multiline'],
'@stylistic/js/new-parens': 'warn',
'@stylistic/js/newline-per-chained-call': ['off', {
ignoreChainWithDepth: 3
}],
'@stylistic/js/no-confusing-arrow': ['warn', {
allowParens: true,
onlyOneSimpleParam: false
}],
'@stylistic/js/no-extra-parens': ['warn', 'all', {
ignoreJSX: 'all',
nestedBinaryExpressions: false,
nestedConditionalExpressions: false,
enforceForArrowConditionals: false,
ternaryOperandBinaryExpressions: false
}],
'@stylistic/js/no-extra-semi': 'warn',
'@stylistic/js/no-floating-decimal': 'warn',
'@stylistic/js/no-mixed-operators': ['error', {
groups: [['+', '-'], ['*', '/', '%', '**'], ['&', '|', '^', '~', '<<', '>>', '>>>'], ['==', '!=', '===', '!==', '>', '>=', '<', '<='], ['&&', '||', '?:', '??'], ['in', 'instanceof']],
allowSamePrecedence: true
}],
'@stylistic/js/no-mixed-spaces-and-tabs': 'error',
'@stylistic/js/no-multi-spaces': 'warn',
'@stylistic/js/no-multiple-empty-lines': ['warn', {
max: 1,
maxEOF: 0,
maxBOF: 0
}],
'@stylistic/js/no-tabs': 'error',
'@stylistic/js/no-trailing-spaces': 'warn',
'@stylistic/js/no-whitespace-before-property': 'warn',
'@stylistic/js/nonblock-statement-body-position': ['warn', 'below'],
'@stylistic/js/object-curly-newline': ['warn', {
ImportDeclaration: {
multiline: true
},
ExportDeclaration: {
multiline: true
}
}],
'@stylistic/js/object-curly-spacing': ['warn', 'always', {
arraysInObjects: true,
objectsInObjects: true
}],
'@stylistic/js/object-property-newline': ['warn', {
allowAllPropertiesOnSameLine: true
}],
'@stylistic/js/one-var-declaration-per-line': ['warn', 'always'],
'@stylistic/js/operator-linebreak': ['warn', 'before', {
overrides: {
'=': 'none',
'==': 'none',
'!=': 'none',
'>=': 'none',
'<=': 'none',
'===': 'none',
'+=': 'none'
}
}],
'@stylistic/js/padded-blocks': ['warn', 'never'],
'@stylistic/js/padding-line-between-statements': 'off',
'@stylistic/js/quote-props': ['warn', 'consistent-as-needed'],
'@stylistic/js/quotes': ['warn', 'single', {
avoidEscape: true,
allowTemplateLiterals: true,
ignoreStringLiterals: false
}],
'@stylistic/js/rest-spread-spacing': ['warn', 'never'],
'@stylistic/js/semi': ['warn', 'always'],
'@stylistic/js/semi-spacing': ['warn', {
before: false,
after: true
}],
'@stylistic/js/semi-style': ['warn', 'last'],
'@stylistic/js/space-before-blocks': ['warn', 'always'],
'@stylistic/js/space-before-function-paren': ['warn', {
anonymous: 'always',
named: 'never',
asyncArrow: 'always'
}],
'@stylistic/js/space-in-parens': ['warn', 'never'],
'@stylistic/js/space-infix-ops': ['warn', {
int32Hint: false
}],
'@stylistic/js/space-unary-ops': ['warn', {
words: true,
nonwords: false
}],
'@stylistic/js/spaced-comment': ['warn', 'always', {
line: {
markers: ['/ <reference']
}
}],
'@stylistic/js/switch-colon-spacing': ['warn', {
after: true,
before: false
}],
'@stylistic/js/template-curly-spacing': ['warn', 'never'],
'@stylistic/js/template-tag-spacing': ['warn', 'never'],
'@stylistic/js/wrap-iife': ['warn', 'outside'],
'@stylistic/js/wrap-regex': 'warn',
'@stylistic/js/yield-star-spacing': ['warn', {
before: true,
after: false
}]
}
};
}