Initial ESLint setup

This sets up ESLint and its config, and disables a bunch of recommended
lints that currently do not pass. Later PRs/commits will fix those lints
and re-enable them.
This commit is contained in:
valadaptive 2023-12-02 09:02:57 -05:00
parent 4c4e4caeb7
commit ec0e4026d8
3 changed files with 983 additions and 1 deletions

77
.eslintrc.js Normal file
View File

@ -0,0 +1,77 @@
module.exports = {
root: true,
extends: [
'eslint:recommended'
],
env: {
es6: true
},
parserOptions: {
ecmaVersion: 'latest'
},
overrides: [
{
// Server-side files (plus this configuration file)
files: ["src/**/*.js", "server.js", ".eslintrc.js"],
env: {
node: true
}
},
{
// Browser-side files
files: ["public/**/*.js"],
env: {
browser: true,
jquery: true
},
parserOptions: {
sourceType: 'module'
},
// These scripts are loaded in HTML; tell ESLint not to complain about them being undefined
globals: {
DOMPurify: 'readonly',
droll: 'readonly',
Fuse: 'readonly',
Handlebars: 'readonly',
hljs: 'readonly',
localforage: 'readonly',
moment: 'readonly',
pdfjsLib: 'readonly',
Popper: 'readonly',
showdown: 'readonly',
showdownKatex: 'readonly',
SVGInject: 'readonly',
toastr: 'readonly'
}
}
],
// There are various vendored libraries that shouldn't be linted
ignorePatterns: ['public/lib/**/*', '*.min.js', 'src/ai_horde/**/*'],
// Most, if not all, of these rules should eventually be enabled and the code changed. They're disabled so that
// linting passes.
rules: {
'no-unused-vars': 'off',
'no-useless-escape': 'off',
'no-control-regex': 'off',
'no-redeclare': 'off',
'no-async-promise-executor': 'off',
'no-inner-declarations': 'off',
'no-extra-semi': 'off',
'no-undef': 'off',
'no-prototype-builtins': 'off',
'no-unused-labels': 'off',
'no-extra-boolean-cast': 'off',
'require-yield': 'off',
'no-case-declarations': 'off',
'use-isnan': 'off',
'no-self-assign': 'off',
'no-unsafe-negation': 'off',
'no-constant-condition': 'off',
'no-empty': 'off',
'no-unsafe-finally': 'off',
'no-dupe-keys': 'off',
'no-irregular-whitespace': 'off',
'no-regex-spaces': 'off',
'no-fallthrough': 'off'
}
};

903
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -57,7 +57,8 @@
"start": "node server.js",
"start-multi": "node server.js --disableCsrf",
"pkg": "pkg --compress Gzip --no-bytecode --public .",
"postinstall": "node post-install.js"
"postinstall": "node post-install.js",
"lint": "eslint \"src/**/*.js\" \"public/**/*.js\" ./server.js"
},
"bin": {
"sillytavern": "./server.js"
@ -82,6 +83,7 @@
]
},
"devDependencies": {
"eslint": "^8.55.0",
"jquery": "^3.6.4",
"pkg": "^5.8.1",
"pkg-fetch": "^3.5.2"