|
11 | 11 | }, |
12 | 12 | "plugins": ["import", "unicorn", "oxc", "promise", "jsdoc", "vitest", "node"], |
13 | 13 | "rules": { |
14 | | - "catch-error-name": ["warn", { "name": "err" }], |
15 | | - "curly": ["off", "multi-line"], |
| 14 | + // we should not enforce capitalized comments |
| 15 | + "capitalized-comments": "off", |
| 16 | + // prefer to export declarations instead of exporting at the end |
16 | 17 | "group-exports": "off", |
17 | | - "id-length": "off", |
| 18 | + // this rule is too restrictive |
18 | 19 | "init-declarations": "off", |
19 | | - "max-dependencies": "off", |
20 | | - "max-lines": "off", |
21 | | - "max-lines-per-function": "off", |
22 | | - "max-params": ["warn", 4], |
| 20 | + // allow continue in complicated loops |
23 | 21 | "no-continue": "off", |
| 22 | + // warn about console usage but allow it |
24 | 23 | "no-console": "warn", |
25 | | - "no-duplicate-imports": "off", |
| 24 | + // type imports can be duplicated with value imports |
| 25 | + "no-duplicate-imports": ["error", { "allowSeparateTypeImports": true }], |
| 26 | + // inline comments shall be allowed |
| 27 | + "no-inline-comments": "off", |
26 | 28 | "no-magic-numbers": "off", |
27 | | - // "no-magic-numbers": ["warn", { "ignore": [-1, 0, 1, 2] }], |
| 29 | + // allow nested ternary for better readability in some cases |
28 | 30 | "no-nested-ternary": "off", |
| 31 | + // allow null usage |
29 | 32 | "no-null": "off", |
| 33 | + // ternary operator shall be allowed for simple expressions |
30 | 34 | "no-ternary": "off", |
31 | | - "no-warning-comments": "off", |
| 35 | + // normally we do not enforce numeric separator usage |
| 36 | + "numeric-separators-style": "off", |
| 37 | + // we prefer to sort imports with its pkg name |
32 | 38 | "sort-imports": "off", |
| 39 | + // object keys are not supposed to be sorted in many cases |
33 | 40 | "sort-keys": "off", |
34 | 41 |
|
| 42 | + // import plugin rules |
| 43 | + |
35 | 44 | "import/exports-last": "off", |
36 | 45 | // usually we just export vue components as default export without naming it |
37 | 46 | "import/no-anonymous-default-export": "off", |
38 | 47 | // a rule that shall not be enabled anyway |
39 | 48 | "import/no-named-export": "off", |
| 49 | + // allow importing stylesheets |
40 | 50 | "import/no-unassigned-import": ["error", { "allow": ["**/*.css", "**/*.scss"] }], |
41 | | - // named export is preferred in our codebase |
| 51 | + // named export is preferred |
42 | 52 | "import/prefer-default-export": "off", |
43 | 53 |
|
44 | | - "jsdoc/check-tag-names": ["error", { "typed": true }], |
45 | | - "jsdoc/require-param": "off", |
| 54 | + // jsdoc plugin rules |
| 55 | + |
| 56 | + // duplicated typescript related jsdoc shall be warned |
| 57 | + "jsdoc/check-tag-names": ["warn", { "typed": true }], |
| 58 | + // we do not require types in jsdoc since we use TypeScript |
46 | 59 | "jsdoc/require-param-type": "off", |
47 | | - "jsdoc/require-returns": "off", |
| 60 | + // we do not require types in jsdoc since we use TypeScript |
48 | 61 | "jsdoc/require-returns-type": "off", |
49 | 62 |
|
50 | 63 | "promise/always-return": "off", |
| 64 | + // we sometimes need to create new Promise instance |
51 | 65 | "promise/avoid-new": "off", |
| 66 | + // we prefer async/await syntax |
52 | 67 | "promise/prefer-await-to-then": "off", |
| 68 | + |
| 69 | + // unicorn plugin rules |
| 70 | + // filename should not be enforced strictly, e.g. Vue SFC files shall be PascalCased |
| 71 | + // we shall expect a project level setting |
53 | 72 | "unicorn/filename-case": "off", |
54 | | - // toReversed can introduce memory overhead |
| 73 | + // toReversed can introduce memory overhead, |
| 74 | + // in some chained calls it is better to use reverse as the "reversed" array is also a temp variable. |
55 | 75 | "unicorn/no-array-reverse": "off", |
56 | 76 | // toSorted can introduce memory overhead |
| 77 | + // in some chained calls it is better to use reverse as the "sorted" array is also a temp variable. |
57 | 78 | "unicorn/no-array-sort": "off", |
58 | | - "unicorn/no-nested-ternary": "off", |
59 | | - // at is not supported by our target environments |
| 79 | + // sometimes nested ternary is considerable |
| 80 | + "unicorn/no-nested-ternary": "warn", |
| 81 | + // Array.at() is too modern for browser targets |
60 | 82 | "unicorn/prefer-at": "off", |
61 | | - "unicorn/prefer-global-this": "off", |
| 83 | + // support starts with chrome71, firefox68. safari12.1, node12 |
| 84 | + // leaving it to warn for edge cases |
| 85 | + "unicorn/prefer-global-this": "warn", |
62 | 86 |
|
63 | | - // seems conflicts with prettier |
64 | | - "number-literal-case": "off", |
65 | | - "numeric-separators-style": "off", |
| 87 | + // stylistic rules with default being tweaked |
66 | 88 |
|
67 | | - // style rules |
68 | | - "capitalized-comments": "off", |
69 | | - "max-statements": ["warn", { "max": 30 }], |
70 | | - "no-inline-comments": "off" |
| 89 | + "catch-error-name": ["warn", { "name": "err" }], |
| 90 | + "curly": ["warn", "multi-line"], |
| 91 | + "id-length": "off", |
| 92 | + "max-dependencies": ["warn", { "ignoreTypeImports": true, "max": 15 }], |
| 93 | + "max-lines": ["warn", { "max": 500, "skipBlankLines": true, "skipComments": true }], |
| 94 | + "max-lines-per-function": [ |
| 95 | + "warn", |
| 96 | + { "max": 100, "skipBlankLines": true, "skipComments": true } |
| 97 | + ], |
| 98 | + "max-params": ["warn", 4], |
| 99 | + "max-statements": ["warn", { "max": 30 }] |
71 | 100 | }, |
72 | 101 | "overrides": [ |
73 | 102 | { |
|
0 commit comments