Skip to content

Commit 4f42d6e

Browse files
renovate[bot]RayBB
andauthored
chore(deps): update eslint (major) (#12306)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: RayBB <RayBB@users.noreply.github.com>
1 parent 12c1bbf commit 4f42d6e

26 files changed

Lines changed: 793 additions & 489 deletions

File tree

.eslintignore

Lines changed: 0 additions & 12 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 49 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,20 @@ repos:
9393
- id: validate-pyproject
9494

9595
- repo: https://github.com/pre-commit/mirrors-eslint
96-
rev: v10.0.2
96+
rev: v9.9.1
9797
hooks:
9898
- id: eslint
9999
types: [file]
100100
types_or: [javascript, vue]
101101
additional_dependencies:
102-
- eslint@8.49.0
103-
- eslint-plugin-no-jquery@2.7.0
102+
- eslint@9.39.4
103+
- "@eslint/js@9.39.4"
104+
- eslint-plugin-no-jquery@3.1.1
104105
- eslint-plugin-vue@9.32.0
105-
- "@babel/eslint-parser@7.28.0"
106-
- "@babel/plugin-syntax-dynamic-import@7.8.3"
107-
- "@babel/preset-env@7.29.0"
106+
- globals@15.14.0
107+
- "@babel/eslint-parser@7.24.7"
108+
- "@babel/core@7.24.7"
109+
- "@babel/preset-env@7.24.7"
108110
args: [--fix]
109111

110112
- repo: https://github.com/awebdeveloper/pre-commit-stylelint

conf/svgo.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-env node, es6 */
21
const {extendDefaultPlugins} = require('svgo');
32
module.exports = {
43
plugins: extendDefaultPlugins([

eslint.config.cjs

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
const js = require("@eslint/js");
2+
const vuePlugin = require("eslint-plugin-vue");
3+
const globals = require("globals");
4+
const babelParser = require("@babel/eslint-parser");
5+
6+
/** @type {import('eslint').Linter.Config[]} */
7+
module.exports = [
8+
// Ignore patterns from .eslintignore
9+
{
10+
ignores: [
11+
".*",
12+
"*.config.js",
13+
"*.config.mjs",
14+
"conf/",
15+
"config/",
16+
"docker/",
17+
"infogami/",
18+
"node_modules/",
19+
"scripts/",
20+
"static/build/",
21+
"build/",
22+
"coverage/",
23+
"provisioning/",
24+
"vendor/",
25+
"tests/screenshots/",
26+
"venv/",
27+
"eslint.config.cjs",
28+
],
29+
},
30+
31+
// Configuration for build and config files (CommonJS) - MUST come before js.configs.recommended
32+
{
33+
files: [
34+
"webpack.config.js",
35+
"webpack.config.css.js",
36+
"vue.config.js",
37+
"openlibrary/components/dev/serve-component.js",
38+
"conf/svgo.config.js",
39+
"stories/.storybook/main.js",
40+
],
41+
languageOptions: {
42+
sourceType: "script",
43+
ecmaVersion: "latest",
44+
globals: {
45+
...globals.node,
46+
},
47+
},
48+
rules: {
49+
"no-console": "off",
50+
},
51+
},
52+
53+
// Configuration for Vite config files (ES modules) - MUST come before js.configs.recommended
54+
{
55+
files: [
56+
"openlibrary/components/vite.config.mjs",
57+
"openlibrary/components/vite-lit.config.mjs",
58+
],
59+
languageOptions: {
60+
ecmaVersion: "latest",
61+
sourceType: "module",
62+
globals: {
63+
...globals.node,
64+
},
65+
},
66+
rules: {
67+
"no-console": "off",
68+
},
69+
},
70+
71+
// Configuration for Storybook preview files (ES modules) - MUST come before js.configs.recommended
72+
{
73+
files: ["stories/.storybook/preview.js"],
74+
languageOptions: {
75+
sourceType: "module",
76+
ecmaVersion: "latest",
77+
globals: {
78+
...globals.node,
79+
},
80+
},
81+
rules: {
82+
"no-console": "off",
83+
},
84+
},
85+
86+
// Base recommended config
87+
js.configs.recommended,
88+
89+
// Vue plugin configuration
90+
...vuePlugin.configs["flat/recommended"],
91+
92+
// Base configuration for all JS/Vue files (except config and build files)
93+
{
94+
files: ["**/*.js", "**/*.vue"],
95+
plugins: {
96+
"no-jquery": require("eslint-plugin-no-jquery"),
97+
},
98+
languageOptions: {
99+
parserOptions: {
100+
sourceType: "module",
101+
ecmaVersion: "latest",
102+
babelOptions: {
103+
configFile: "./.babelrc",
104+
},
105+
},
106+
globals: {
107+
...globals.browser,
108+
$: "readonly",
109+
jQuery: "readonly",
110+
},
111+
},
112+
rules: {
113+
"prefer-template": "error",
114+
eqeqeq: ["error", "always"],
115+
quotes: ["error", "single"],
116+
"eol-last": ["error", "always"],
117+
indent: 2,
118+
"no-console": "error",
119+
"no-mixed-spaces-and-tabs": "error",
120+
"no-extra-semi": "error",
121+
"no-redeclare": "error",
122+
"no-trailing-spaces": "error",
123+
"no-undef": "error",
124+
"no-unused-vars": [
125+
"error",
126+
{
127+
caughtErrors: "none",
128+
},
129+
],
130+
"no-useless-escape": "error",
131+
"space-in-parens": "error",
132+
"vars-on-top": "error",
133+
"prefer-const": "error",
134+
"template-curly-spacing": "error",
135+
"quote-props": ["error", "as-needed"],
136+
"keyword-spacing": ["error", { before: true, after: true }],
137+
"key-spacing": ["error", { mode: "strict" }],
138+
"vue/no-mutating-props": "off",
139+
"vue/multi-word-component-names": [
140+
"error",
141+
{
142+
ignores: ["Bookshelf", "Shelf"],
143+
},
144+
],
145+
// jQuery deprecated rules (from plugin:no-jquery/deprecated)
146+
"no-jquery/no-box-model": "warn",
147+
"no-jquery/no-browser": "warn",
148+
"no-jquery/no-live": "warn",
149+
"no-jquery/no-sub": "warn",
150+
"no-jquery/no-selector-prop": "warn",
151+
"no-jquery/no-and-self": "warn",
152+
"no-jquery/no-error-shorthand": "warn",
153+
"no-jquery/no-load-shorthand": "warn",
154+
"no-jquery/no-on-ready": "warn",
155+
"no-jquery/no-size": "warn",
156+
"no-jquery/no-unload-shorthand": "warn",
157+
"no-jquery/no-support": "warn",
158+
"no-jquery/no-context-prop": "warn",
159+
"no-jquery/no-bind": "warn",
160+
"no-jquery/no-delegate": "warn",
161+
"no-jquery/no-fx-interval": "warn",
162+
"no-jquery/no-parse-json": "warn",
163+
"no-jquery/no-ready-shorthand": "warn",
164+
"no-jquery/no-unique": "warn",
165+
"no-jquery/no-hold-ready": "warn",
166+
"no-jquery/no-is-array": "warn",
167+
"no-jquery/no-node-name": "warn",
168+
"no-jquery/no-camel-case": "warn",
169+
"no-jquery/no-event-shorthand": ["warn", {}],
170+
"no-jquery/no-is-function": "warn",
171+
"no-jquery/no-is-numeric": "warn",
172+
"no-jquery/no-is-window": "warn",
173+
"no-jquery/no-now": "warn",
174+
"no-jquery/no-proxy": "warn",
175+
"no-jquery/no-type": "warn",
176+
"no-jquery/no-sizzle": [
177+
"warn",
178+
{ allowPositional: false, allowOther: true },
179+
],
180+
"no-jquery/no-trim": "warn",
181+
},
182+
},
183+
184+
// Vue-specific configuration
185+
{
186+
files: ["**/*.vue"],
187+
languageOptions: {
188+
parserOptions: {
189+
parser: babelParser,
190+
sourceType: "module",
191+
ecmaVersion: "latest",
192+
babelOptions: {
193+
configFile: "./.babelrc",
194+
},
195+
},
196+
},
197+
},
198+
199+
// JavaScript-specific configuration
200+
{
201+
files: ["**/*.js"],
202+
languageOptions: {
203+
parser: babelParser,
204+
parserOptions: {
205+
sourceType: "module",
206+
ecmaVersion: "latest",
207+
babelOptions: {
208+
configFile: "./.babelrc",
209+
},
210+
},
211+
},
212+
},
213+
214+
// Configuration for test files
215+
{
216+
files: ["tests/unit/**/*.{js,vue}", "tests/unit/js/setup.js"],
217+
languageOptions: {
218+
globals: {
219+
...globals.es2021,
220+
...globals.jest,
221+
...globals.node,
222+
},
223+
},
224+
},
225+
];

openlibrary/components/BulkSearch/components/BulkSearchControls.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ export default {
228228
const data = await fetch(buildSearchUrl(book, matchOptions, true))
229229
return await data.json()
230230
}
231-
catch (error) {}
231+
catch (error) {
232+
// Silence errors - failing to match a book is expected
233+
}
232234
}
233235
this.loadingMatchedBooks = true
234236
for (const bookMatch of this.bulkSearchState.matchedBooks) {

openlibrary/components/MergeUI/utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ export async function fetchWithRetry(input, init = {}, maxRetries = 5, initialDe
4646
*/
4747
function hash_subel(field, value) {
4848
switch (field) {
49-
case 'authors':
49+
case 'authors':{
5050
// Handle the two possible formats for authors in works and editions
5151
const authorKey = value.author ? value.author.key : value.key;
5252
return (value.type.key || value.type) + authorKey;
53+
}
5354
case 'covers':
5455
case 'subjects':
5556
case 'subject_people':
@@ -103,13 +104,14 @@ export function merge(master, dupes) {
103104
if (!(result[key] instanceof Array))
104105
continue;
105106
switch (key) {
106-
case 'authors':
107+
case 'authors':{
107108
const authors = _.cloneDeep(result.authors);
108109
authors
109110
.filter(a => typeof a.type === 'string')
110111
.forEach(a => a.type = { key: a.type });
111112
result.authors = _.uniqWith(authors, _.isEqual);
112113
break;
114+
}
113115
case 'covers':
114116
case 'subjects':
115117
case 'subject_people':

openlibrary/components/dev/serve-component.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-env node */
21
/*
32
Creates the js files to be imported for the dev server
43
*/
@@ -11,7 +10,7 @@ import { createApp } from 'vue'
1110
import HelloWorld from '../HelloWorld.vue'
1211
1312
createApp(HelloWorld).mount('#app')
14-
`
13+
`;
1514

1615
const result = data.replace(/HelloWorld/g, componentName);
1716
fs.writeFileSync('openlibrary/components/dev/_dev.js', result);

openlibrary/components/vite-lit.config.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-env node, es6 */
21
/**
32
* Vite config for Lit web components. (for Vue components see vite.config.mjs)
43
*
@@ -51,4 +50,3 @@ export default defineConfig({
5150
sourcemap: true
5251
}
5352
});
54-

openlibrary/components/vite.config.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-env node, es6 */
21
/**
32
* Vite config for Vue components. (for Lit components see vite-lit.config.mjs)
43
*/
@@ -65,7 +64,6 @@ createWebComponentSimple(rootComponent, '${componentName}');`;
6564
try {
6665
writeFileSync(getTemporaryVueInputPath(componentName), template);
6766
} catch (error) {
68-
// eslint-disable-next-line no-console
6967
console.error(`Failed to generate Vite entry file: ${error.message}`);
7068
process.exit(1);
7169
}

0 commit comments

Comments
 (0)