| 1 | module.exports = { |
| 2 | root: true, |
| 3 | extends: [ |
| 4 | 'eslint:recommended', |
| 5 | ], |
| 6 | plugins: [ |
| 7 | 'jsdoc', |
| 8 | ], |
| 9 | env: { |
| 10 | es6: true, |
| 11 | }, |
| 12 | parserOptions: { |
| 13 | ecmaVersion: 'latest', |
| 14 | }, |
| 15 | overrides: [ |
| 16 | { |
| 17 | // Server-side files (plus this configuration file) |
| 18 | files: ['src/**/*.js', './*.js', 'plugins/**/*.js'], |
| 19 | env: { |
| 20 | node: true, |
| 21 | }, |
| 22 | parserOptions: { |
| 23 | sourceType: 'module', |
| 24 | }, |
| 25 | globals: { |
| 26 | globalThis: 'readonly', |
| 27 | Deno: 'readonly', |
| 28 | }, |
| 29 | }, |
| 30 | { |
| 31 | files: ['*.cjs'], |
| 32 | parserOptions: { |
| 33 | sourceType: 'commonjs', |
| 34 | }, |
| 35 | env: { |
| 36 | node: true, |
| 37 | }, |
| 38 | }, |
| 39 | { |
| 40 | files: ['src/**/*.mjs'], |
| 41 | parserOptions: { |
| 42 | sourceType: 'module', |
| 43 | }, |
| 44 | env: { |
| 45 | node: true, |
| 46 | }, |
| 47 | }, |
| 48 | { |
| 49 | // Browser-side files |
| 50 | files: ['public/**/*.js'], |
| 51 | env: { |
| 52 | browser: true, |
| 53 | jquery: true, |
| 54 | }, |
| 55 | parserOptions: { |
| 56 | sourceType: 'module', |
| 57 | }, |
| 58 | // These scripts are loaded in HTML; tell ESLint not to complain about them being undefined |
| 59 | globals: { |
| 60 | globalThis: 'readonly', |
| 61 | ePub: 'readonly', |
| 62 | pdfjsLib: 'readonly', |
| 63 | toastr: 'readonly', |
| 64 | SillyTavern: 'readonly', |
| 65 | }, |
| 66 | }, |
| 67 | ], |
| 68 | ignorePatterns: [ |
| 69 | '**/node_modules/**', |
| 70 | '**/dist/**', |
| 71 | '**/.git/**', |
| 72 | 'public/lib/**', |
| 73 | 'backups/**', |
| 74 | 'data/**', |
| 75 | 'cache/**', |
| 76 | 'src/tokenizers/**', |
| 77 | 'docker/**', |
| 78 | 'plugins/**', |
| 79 | '**/*.min.js', |
| 80 | 'public/scripts/extensions/quick-reply/lib/**', |
| 81 | 'public/scripts/extensions/tts/lib/**', |
| 82 | ], |
| 83 | rules: { |
| 84 | 'jsdoc/no-undefined-types': ['warn', { disableReporting: true, markVariablesAsUsed: true }], |
| 85 | 'no-unused-vars': ['error', { args: 'none' }], |
| 86 | 'no-control-regex': 'off', |
| 87 | 'no-constant-condition': ['error', { checkLoops: false }], |
| 88 | 'require-yield': 'off', |
| 89 | 'quotes': ['error', 'single'], |
| 90 | 'semi': ['error', 'always'], |
| 91 | 'indent': ['error', 4, { SwitchCase: 1, FunctionDeclaration: { parameters: 'first' } }], |
| 92 | 'comma-dangle': ['error', 'always-multiline'], |
| 93 | 'eol-last': ['error', 'always'], |
| 94 | 'no-trailing-spaces': 'error', |
| 95 | 'object-curly-spacing': ['error', 'always'], |
| 96 | 'space-infix-ops': 'error', |
| 97 | 'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }], |
| 98 | 'no-cond-assign': 'error', |
| 99 | 'no-unneeded-ternary': 'error', |
| 100 | 'no-irregular-whitespace': ['error', { skipStrings: true, skipTemplates: true }], |
| 101 | 'dot-notation': ['error', { 'allowPattern': '[A-Z]\\w*$' }], |
| 102 | // These rules should eventually be enabled. |
| 103 | 'no-async-promise-executor': 'off', |
| 104 | 'no-inner-declarations': 'off', |
| 105 | // Additional formatting rules based on codebase conventions |
| 106 | 'brace-style': ['error', '1tbs', { allowSingleLine: true }], |
| 107 | 'array-bracket-spacing': ['error', 'never'], |
| 108 | 'computed-property-spacing': ['error', 'never'], |
| 109 | 'block-spacing': ['error', 'always'], |
| 110 | 'keyword-spacing': ['error', { before: true, after: true }], |
| 111 | 'space-before-blocks': ['error', 'always'], |
| 112 | 'space-before-function-paren': ['error', { anonymous: 'always', named: 'never', asyncArrow: 'always' }], |
| 113 | 'space-in-parens': ['error', 'never'], |
| 114 | 'comma-spacing': ['error', { before: false, after: true }], |
| 115 | 'key-spacing': ['error', { beforeColon: false, afterColon: true }], |
| 116 | 'func-call-spacing': ['error', 'never'], |
| 117 | 'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 1, maxBOF: 0 }], |
| 118 | 'padded-blocks': ['error', 'never'], |
| 119 | 'no-whitespace-before-property': 'error', |
| 120 | 'space-unary-ops': ['error', { words: true, nonwords: false }], |
| 121 | 'arrow-spacing': ['error', { before: true, after: true }], |
| 122 | 'template-curly-spacing': ['error', 'never'], |
| 123 | 'rest-spread-spacing': ['error', 'never'], |
| 124 | 'generator-star-spacing': ['error', { before: false, after: true }], |
| 125 | 'yield-star-spacing': ['error', { before: false, after: true }], |
| 126 | 'template-tag-spacing': ['error', 'never'], |
| 127 | 'switch-colon-spacing': ['error', { after: true, before: false }], |
| 128 | }, |
| 129 | }; |