Skip to content

Commit

Permalink
Added eslint rules and README
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenrahnemoon committed Feb 22, 2022
1 parent 7075c5e commit 3bf022b
Show file tree
Hide file tree
Showing 4 changed files with 984 additions and 1 deletion.
198 changes: 198 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
module.exports = {
extends : [
'plugin:vue/recommended',
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:vue-scoped-css/recommended',
],

parser : require.resolve('vue-eslint-parser'),

parserOptions : {
parser : require.resolve('@typescript-eslint/parser'),
ecmaVersion : 2020,
},

env : { es6 : true },

plugins : [ '@typescript-eslint', 'align-import' ],

rules : {
// Possible Errors
'no-cond-assign' : 'error',
'no-constant-condition' : 'error',
'no-debugger' : 'error', // should be "error" in production builds
'no-dupe-args' : 'error',
'no-dupe-keys' : 'error',
'no-duplicate-case' : 'error',
'no-empty-character-class' : 'error',
'no-extra-boolean-cast' : 'error',
'no-func-assign' : 'error',
'no-inner-declarations' : 'error',
'no-invalid-regexp' : 'error',
'no-irregular-whitespace' : 'error',
'no-negated-in-lhs' : 'error',
'no-obj-calls' : 'error',
'valid-typeof' : 'error',

// Best Practices
'no-eval' : 'error',
'no-else-return' : [ 'error', { allowElseIf : false } ],
'no-loop-func' : 'error',
'no-implied-eval' : 'error',
'no-buffer-constructor' : 'error',
'no-prototype-builtins' : 'off', // turning off because this only slightly improves reliability at the expense of readability

// Stylistic
'arrow-body-style' : [ 'error' ],
'block-spacing' : [ 'error' ],
'brace-style' : [ 'error', 'stroustrup' ],
'no-nested-ternary' : [ 'error' ],
'no-mixed-spaces-and-tabs' : [ 'error', 'smart-tabs' ],
'object-property-newline' : [ 'error', { allowMultiplePropertiesPerLine : true } ],
'func-style' : [ 'error', 'declaration', { allowArrowFunctions : true } ],

// automatically fixable
'align-import/align-import' : [ 'error' ],
'no-undef' : 'off',
'no-unsafe-negation' : [ 'error' ],
'dot-location' : [ 'error', 'property' ],
'dot-notation' : [ 'error', { allowPattern : '^[A-Za-z]+(_[A-Za-z0-9]+)+$' } ],
'no-extra-bind' : [ 'error' ],
'no-floating-decimal' : [ 'error' ],
'no-implicit-coercion' : [ 'error', { allow : [ '!!' ] } ],
'yoda' : [ 'error' ],
'no-undef-init' : [ 'error' ],
'array-bracket-spacing' : [
'error',
'always',
{ objectsInArrays : true, arraysInArrays : true },
],
'comma-dangle' : [
'error',
{ objects : 'always-multiline', arrays : 'always-multiline', functions : 'never' },
],
'comma-spacing' : [ 'error' ],
'comma-style' : [ 'error' ],
'curly' : [ 'error' ],
'eol-last' : [ 'error', 'always' ],
'func-call-spacing' : [ 'error' ],
'key-spacing' : [
'error',
{
beforeColon : true,
afterColon : true,
align : 'colon',
},
],
'keyword-spacing' : [ 'error' ],
'linebreak-style' : [ 'error', 'unix' ],
'new-parens' : [ 'error' ],
'no-lonely-if' : [ 'error' ],
'no-multiple-empty-lines' : [ 'error', { max : 2, maxEOF : 1, maxBOF : 0 } ],
'no-trailing-spaces' : [ 'error' ],
'no-whitespace-before-property' : [ 'error' ],
'object-curly-spacing' : [ 'error', 'always' ],
'operator-linebreak' : [ 'error', 'before' ],
'quote-props' : [ 'error', 'consistent-as-needed' ],
'quotes' : [ 'error', 'single', { avoidEscape : true } ],
'semi' : [ 'error', 'always' ],
'computed-property-spacing' : [ 'error', 'never' ],
'semi-spacing' : [ 'error' ],
'space-before-blocks' : [ 'error' ],
'space-before-function-paren' : [
'error',
{
anonymous : 'never',
named : 'never',
asyncArrow : 'always',
},
],
'space-in-parens' : [ 'error', 'never' ],
'space-infix-ops' : [ 'error' ],
'space-unary-ops' : [ 'error', { words : true, nonwords : false } ],
'spaced-comment' : [ 'error', 'always', { markers : [ '/' ] } ],
'arrow-parens' : [ 'error', 'as-needed' ],
'arrow-spacing' : [ 'error' ],
'generator-star-spacing' : [ 'error', 'neither' ],
'no-useless-rename' : [ 'error' ],
'no-var' : [ 'error' ],
'prefer-const' : [ 'error' ],
'prefer-numeric-literals' : [ 'error' ],
'prefer-template' : [ 'error' ],
'prefer-spread' : [ 'error' ],
'template-curly-spacing' : [ 'error' ],
'yield-star-spacing' : [ 'error' ],
'no-return-await' : [ 'error' ],
'no-return-assign' : [ 'error', 'always' ],
'object-shorthand' : [ 'error', 'properties' ],

// typescript specific rules
'@typescript-eslint/adjacent-overload-signatures' : 'error',
'@typescript-eslint/array-type' : 'error',
'@typescript-eslint/ban-types' : 'error',
'camelcase' : 'off',
'@typescript-eslint/camelcase' : 'error',
'@typescript-eslint/class-name-casing' : 'error',
'@typescript-eslint/explicit-function-return-type' : 'off',
'@typescript-eslint/explicit-member-accessibility' : 'off',
'indent' : 'off',
'@typescript-eslint/indent' : [ 'error', 'tab' ],
'@typescript-eslint/interface-name-prefix' : 'error',
'@typescript-eslint/member-delimiter-style' : 'error',
'no-array-constructor' : 'off',
'@typescript-eslint/no-array-constructor' : 'error',
'@typescript-eslint/no-empty-interface' : 'error',
'@typescript-eslint/no-explicit-any' : 'off',
'@typescript-eslint/no-inferrable-types' : [ 'error', { ignoreProperties : true } ],
'@typescript-eslint/no-misused-new' : 'error',
'@typescript-eslint/no-namespace' : 'error',
'@typescript-eslint/no-non-null-assertion' : 'error',
'@typescript-eslint/consistent-type-assertions' : 'error',
'@typescript-eslint/no-parameter-properties' : 'error',
'no-unused-vars' : 'off',
'@typescript-eslint/no-unused-vars' : 'error',
'no-use-before-define' : 'off',
'@typescript-eslint/no-use-before-define' : [ 'off', { functions : false } ], // off because it keeps flagging too many false positives
'@typescript-eslint/no-var-requires' : 'error',
'@typescript-eslint/consistent-type-definitions' : [ 'error', 'interface' ],
'@typescript-eslint/prefer-namespace-keyword' : 'error',
'@typescript-eslint/type-annotation-spacing' : 'error',
'@typescript-eslint/ban-ts-ignore' : 'off', // allow @ts-ignore since it's useful sometimes

// vue specific rules
'vue/valid-template-root' : 'off',
'vue/html-indent' : [ 'error', 'tab' ],
'vue-scoped-css/require-scoped' : 'off',
'vue/array-bracket-spacing' : [
'error',
'always',
{ objectsInArrays : true, arraysInArrays : true },
],
'vue/arrow-spacing' : [ 'error' ],
'vue/block-spacing' : [ 'error' ],
'vue/brace-style' : [ 'error', 'stroustrup' ],
'vue/camelcase' : [ 'error' ],
'vue/comma-dangle' : [
'error',
{ objects : 'always-multiline', arrays : 'always-multiline', functions : 'never' },
],
'vue/dot-location' : [ 'error', 'property' ],
'vue/key-spacing' : [
'error',
{
beforeColon : true,
afterColon : true,
align : 'colon',
},
],
'vue/keyword-spacing' : [ 'error' ],
'vue/no-irregular-whitespace' : [ 'error' ],
'vue/object-curly-spacing' : [ 'error', 'always' ],
'vue/space-infix-ops' : [ 'error' ],
'vue/space-unary-ops' : [ 'error', { words : true, nonwords : false } ],
'vue/max-attributes-per-line' : [ 'error', { singleline : 3 } ],
'vue/padding-line-between-blocks' : [ 'error' ],
},
};
Loading

0 comments on commit 3bf022b

Please sign in to comment.