1 | module.exports = {
|
2 | env: {
|
3 | browser: true,
|
4 | node: true,
|
5 | 'jest/globals': true
|
6 | },
|
7 | extends: [
|
8 | 'standard',
|
9 | 'plugin:import/errors',
|
10 | 'plugin:import/warnings',
|
11 | 'plugin:vue/recommended'
|
12 | ],
|
13 | plugins: [
|
14 | 'jest',
|
15 | 'unicorn',
|
16 | 'vue'
|
17 | ],
|
18 | settings: {
|
19 | 'import/resolver': {
|
20 | node: { extensions: ['.js', '.mjs'] }
|
21 | }
|
22 | },
|
23 | rules: {
|
24 |
|
25 | /**********************/
|
26 | /* General Code Rules */
|
27 | /**********************/
|
28 |
|
29 | // Enforce import order
|
30 | 'import/order': 'error',
|
31 |
|
32 | // Imports should come first
|
33 | 'import/first': 'error',
|
34 |
|
35 | // Other import rules
|
36 | 'import/no-mutable-exports': 'error',
|
37 |
|
38 | // Allow unresolved imports
|
39 | 'import/no-unresolved': 'off',
|
40 |
|
41 | // Allow paren-less arrow functions only when there's no braces
|
42 | 'arrow-parens': ['error', 'as-needed', { requireForBlockBody: true }],
|
43 |
|
44 | // Allow async-await
|
45 | 'generator-star-spacing': 'off',
|
46 |
|
47 | // Allow debugger during development
|
48 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
|
49 | 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'warn',
|
50 |
|
51 | // Prefer const over let
|
52 | 'prefer-const': ['error', {
|
53 | destructuring: 'any',
|
54 | ignoreReadBeforeAssign: false
|
55 | }],
|
56 |
|
57 | // No single if in an "else" block
|
58 | 'no-lonely-if': 'error',
|
59 |
|
60 | // Force curly braces for control flow,
|
61 | // including if blocks with a single statement
|
62 | curly: ['error', 'all'],
|
63 |
|
64 | // No async function without await
|
65 | 'require-await': 'error',
|
66 |
|
67 | // Force dot notation when possible
|
68 | 'dot-notation': 'error',
|
69 |
|
70 | 'no-var': 'error',
|
71 |
|
72 | // Force object shorthand where possible
|
73 | 'object-shorthand': 'error',
|
74 |
|
75 | // No useless destructuring/importing/exporting renames
|
76 | 'no-useless-rename': 'error',
|
77 |
|
78 | /**********************/
|
79 | /* Unicorn Rules */
|
80 | /**********************/
|
81 |
|
82 | // Pass error message when throwing errors
|
83 | 'unicorn/error-message': 'error',
|
84 |
|
85 | // Uppercase regex escapes
|
86 | 'unicorn/escape-case': 'error',
|
87 |
|
88 | // Array.isArray instead of instanceof
|
89 | 'unicorn/no-array-instanceof': 'error',
|
90 |
|
91 | // Prevent deprecated `new Buffer()`
|
92 | 'unicorn/no-new-buffer': 'error',
|
93 |
|
94 | // Keep regex literals safe!
|
95 | 'unicorn/no-unsafe-regex': 'off',
|
96 |
|
97 | // Lowercase number formatting for octal, hex, binary (0x12 instead of 0X12)
|
98 | 'unicorn/number-literal-case': 'error',
|
99 |
|
100 | // ** instead of Math.pow()
|
101 | 'unicorn/prefer-exponentiation-operator': 'error',
|
102 |
|
103 | // includes over indexOf when checking for existence
|
104 | 'unicorn/prefer-includes': 'error',
|
105 |
|
106 | // String methods startsWith/endsWith instead of more complicated stuff
|
107 | 'unicorn/prefer-starts-ends-with': 'error',
|
108 |
|
109 | // textContent instead of innerText
|
110 | 'unicorn/prefer-text-content': 'error',
|
111 |
|
112 | // Enforce throwing type error when throwing error while checking typeof
|
113 | 'unicorn/prefer-type-error': 'error',
|
114 |
|
115 | // Use new when throwing error
|
116 | 'unicorn/throw-new-error': 'error',
|
117 |
|
118 | /**********************/
|
119 | /* Vue Rules */
|
120 | /**********************/
|
121 |
|
122 | // Disable template errors regarding invalid end tags
|
123 | 'vue/no-parsing-error': ['error', {
|
124 | 'x-invalid-end-tag': false
|
125 | }],
|
126 |
|
127 | // Maximum 5 attributes per line instead of one
|
128 | 'vue/max-attributes-per-line': ['error', {
|
129 | singleline: 5
|
130 | }]
|
131 | }
|
132 | }
|