Skip to content

Commit be3beb9

Browse files
committed
Update eslint and fix some lint errors
1 parent 0d63300 commit be3beb9

12 files changed

+505
-272
lines changed

.eslintrc.cjs

-114
This file was deleted.

.ncurc.json

-3
This file was deleted.

eslint.config.js

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import babelParser from '@babel/eslint-parser'
2+
import globals from 'globals'
3+
import js from '@eslint/js'
4+
import pluginImport from 'eslint-plugin-import'
5+
6+
export default [
7+
js.configs.recommended,
8+
pluginImport.flatConfigs.recommended,
9+
{
10+
languageOptions: {
11+
globals: {
12+
...globals.browser,
13+
...globals.node,
14+
$: true,
15+
jQuery: true
16+
},
17+
parser: babelParser,
18+
parserOptions: {
19+
requireConfigFile: false
20+
},
21+
ecmaVersion: 'latest',
22+
sourceType: 'module'
23+
},
24+
rules: {
25+
'array-bracket-newline': ['error', 'consistent'],
26+
'array-bracket-spacing': ['error', 'never'],
27+
'array-element-newline': 'off',
28+
'arrow-body-style': ['error', 'as-needed'],
29+
'arrow-parens': ['error', 'as-needed'],
30+
'arrow-spacing': ['error', { after: true, before: true }],
31+
'block-spacing': 'error',
32+
'brace-style': ['error', '1tbs'],
33+
camelcase: 'off',
34+
'comma-dangle': ['error', 'never'],
35+
'comma-spacing': ['error', { after: true, before: false }],
36+
'comma-style': 'off',
37+
'computed-property-spacing': ['error', 'never'],
38+
'default-case': 'error',
39+
'dot-location': ['error', 'property'],
40+
'eol-last': ['error', 'always'],
41+
eqeqeq: 'error',
42+
'func-call-spacing': ['error', 'never'],
43+
'guard-for-in': 'warn',
44+
indent: ['error', 2, {
45+
ArrayExpression: 1,
46+
CallExpression: { arguments: 1 },
47+
FunctionDeclaration: { parameters: 'first' },
48+
ImportDeclaration: 'first',
49+
MemberExpression: 1,
50+
ObjectExpression: 1,
51+
SwitchCase: 1
52+
}],
53+
'import/extensions': 'off',
54+
'import/no-named-as-default-member': 'off',
55+
'import/no-unresolved': 'off',
56+
'key-spacing': ['error', { afterColon: true, beforeColon: false, mode: 'strict' }],
57+
'keyword-spacing': ['error', { after: true, before: true }],
58+
'linebreak-style': ['error', 'unix'],
59+
'line-comment-position': 'off',
60+
'lines-around-comment': 'off',
61+
'lines-between-class-members': ['error', 'always'],
62+
'max-len': 'off',
63+
'max-statements-per-line': ['error', { max: 1 }],
64+
'multiline-ternary': 'off',
65+
'no-alert': 'error',
66+
'no-async-promise-executor': 'off',
67+
'no-case-declarations': 'off',
68+
'no-console': ['warn', { allow: ['warn', 'error', 'trace'] }],
69+
'no-duplicate-imports': 'error',
70+
'no-else-return': ['error', { allowElseIf: false }],
71+
'no-extra-parens': 'error',
72+
'no-lonely-if': 'error',
73+
'no-mixed-spaces-and-tabs': 'error',
74+
'no-multi-spaces': 'error',
75+
'no-multi-str': 'error',
76+
'no-multiple-empty-lines': 'error',
77+
'no-new-func': 'error',
78+
'no-param-reassign': 'off',
79+
'no-prototype-builtins': 'off',
80+
'no-return-assign': 'error',
81+
'no-return-await': 'error',
82+
'no-sequences': 'error',
83+
'no-tabs': 'error',
84+
'no-throw-literal': 'error',
85+
'no-trailing-spaces': 'error',
86+
'no-undef-init': 'error',
87+
'no-unused-vars': 'error',
88+
'no-use-before-define': 'warn',
89+
'no-useless-constructor': 'warn',
90+
'no-var': 'error',
91+
'no-void': 'error',
92+
'no-whitespace-before-property': 'error',
93+
'object-curly-spacing': ['error', 'always'],
94+
'object-shorthand': 'error',
95+
'one-var': ['error', 'never'],
96+
'operator-assignment': ['error', 'always'],
97+
'operator-linebreak': ['error', 'after'],
98+
'padding-line-between-statements': [
99+
'error',
100+
{ blankLine: 'always', next: '*', prev: ['const', 'let', 'var'] },
101+
{ blankLine: 'any', next: ['const', 'let', 'var'], prev: ['const', 'let', 'var'] },
102+
{ blankLine: 'always', next: 'export', prev: '*' }
103+
],
104+
'prefer-const': 'error',
105+
'prefer-spread': 'error',
106+
'prefer-template': 'error',
107+
'quote-props': ['error', 'as-needed'],
108+
quotes: ['error', 'single'],
109+
semi: ['error', 'never'],
110+
'semi-spacing': ['error', { after: true, before: false }],
111+
'semi-style': ['error', 'last'],
112+
'sort-imports': ['error', {
113+
ignoreCase: false,
114+
ignoreDeclarationSort: true,
115+
ignoreMemberSort: false,
116+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
117+
allowSeparatedGroups: true
118+
}],
119+
'space-before-blocks': ['error', { classes: 'always', functions: 'always', keywords: 'always' }],
120+
'space-before-function-paren': ['error', 'always'],
121+
'space-in-parens': ['error', 'never'],
122+
'space-infix-ops': 'error',
123+
'spaced-comment': ['error', 'always'],
124+
'switch-colon-spacing': 'error',
125+
'template-curly-spacing': ['error', 'never']
126+
}
127+
}
128+
]

package.json

+12-8
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,37 @@
1111
},
1212
"devDependencies": {
1313
"@babel/core": "^7.26.0",
14+
"@babel/eslint-parser": "^7.25.9",
1415
"@babel/preset-env": "^7.26.0",
16+
"@eslint/js": "^9.16.0",
1517
"@rollup/plugin-babel": "^6.0.4",
1618
"@rollup/plugin-commonjs": "^28.0.1",
1719
"@rollup/plugin-inject": "^5.0.5",
1820
"@rollup/plugin-multi-entry": "^6.0.1",
1921
"@rollup/plugin-node-resolve": "^15.3.0",
2022
"@rollup/plugin-terser": "^0.4.4",
21-
"@vitejs/plugin-vue": "^5.2.0",
23+
"@vitejs/plugin-vue": "^5.2.1",
2224
"chalk": "^5.3.0",
2325
"clean-css-cli": "^5.6.3",
2426
"core-js": "^3.39.0",
2527
"cross-env": "^7.0.3",
26-
"cspell": "^8.16.0",
27-
"cypress": "^13.16.0",
28+
"cspell": "^8.16.1",
29+
"cypress": "^13.16.1",
2830
"editorconfig-checker": "^6.0.0",
29-
"eslint": "^8.57.0",
31+
"eslint": "^9.16.0",
32+
"eslint-plugin-import": "^2.31.0",
3033
"foreach-cli": "^1.8.1",
3134
"glob": "^11.0.0",
35+
"globals": "^15.13.0",
3236
"headr": "^0.0.4",
3337
"npm-run-all": "^4.1.5",
3438
"rimraf": "^6.0.1",
35-
"rollup": "^4.27.3",
39+
"rollup": "^4.28.1",
3640
"rollup-plugin-copy": "^3.5.0",
37-
"sass": "^1.81.0",
38-
"stylelint": "^16.10.0",
41+
"sass": "^1.82.0",
42+
"stylelint": "^16.11.0",
3943
"stylelint-config-standard-scss": "^14.0.0",
40-
"vite": "^6.0.1",
44+
"vite": "^6.0.3",
4145
"vue": "^3.5.13"
4246
},
4347
"scripts": {

src/extensions/cookie/bootstrap-table-cookie.js

+3
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
232232
try {
233233
filterByCookie = JSON.parse(filterByCookieValue)
234234
} catch (e) {
235+
console.error(e)
235236
throw new Error('Could not parse the json of the filterBy cookie!')
236237
}
237238
this.filterColumns = filterByCookie ? filterByCookie : {}
@@ -461,12 +462,14 @@ $.BootstrapTable = class extends $.BootstrapTable {
461462
hiddenColumnsCookie = JSON.parse(hiddenColumnsCookieValue)
462463
columnsCookie = JSON.parse(columnsCookieValue)
463464
} catch (e) {
465+
console.error(e)
464466
throw new Error('Could not parse the json of the columns cookie!')
465467
}
466468

467469
try {
468470
sortPriorityCookie = JSON.parse(sortPriorityCookie)
469471
} catch (e) {
472+
console.error(e)
470473
throw new Error('Could not parse the json of the sortPriority cookie!', sortPriorityCookie)
471474
}
472475

src/extensions/copy-rows/bootstrap-table-copy-rows.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const copyText = text => {
3131
try {
3232
document.execCommand('copy')
3333
} catch (e) {
34-
console.warn('Oops, unable to copy')
34+
console.warn('Oops, unable to copy', e)
3535
}
3636
$(textField).remove()
3737
}

src/extensions/filter-control/utils.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ export function sortSelectControl (selectControl, orderBy, options) {
9393
tmpAry[i][2] = $selectControl.options[i].selected
9494
}
9595

96-
tmpAry.sort((a, b) => {
97-
return Utils.sort(a[0], b[0], orderBy === 'desc' ? -1 : 1, options)
98-
})
96+
tmpAry.sort((a, b) => Utils.sort(a[0], b[0], orderBy === 'desc' ? -1 : 1, options))
9997
while ($selectControl.options.length > 0) {
10098
$selectControl.options[0] = null
10199
}
@@ -177,7 +175,7 @@ export function setCaretPosition (elem, caretPos) {
177175
}
178176
}
179177
} catch (ex) {
180-
// ignored
178+
console.error(ex)
181179
}
182180
}
183181

src/extensions/print/bootstrap-table-print.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
137137
}
138138

139139
doPrint (data) {
140-
const canPrint = column => {
141-
return !column.printIgnore && column.visible
142-
}
140+
const canPrint = column => !column.printIgnore && column.visible
143141

144142
const formatValue = (row, i, column) => {
145143
const value_ = Utils.getItemField(row, column.field, this.options.escape, column.escape)
@@ -194,9 +192,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
194192

195193
const columns = columnsArray.flat(1)
196194

197-
columns.sort((c1, c2) => {
198-
return c1.colspanIndex - c2.colspanIndex
199-
})
195+
columns.sort((c1, c2) => c1.colspanIndex - c2.colspanIndex)
200196

201197
for (let j = 0; j < columns.length; j++) {
202198
if (columns[j].colspanGroup > 0) continue

src/extensions/reorder-columns/bootstrap-table-reorder-columns.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
124124
try {
125125
$(this.$el).dragtable('destroy')
126126
} catch (e) {
127-
// do nothing
127+
console.error(e)
128128
}
129129
$(this.$el).dragtable({
130130
maxMovingRows: this.options.maxMovingRows,
@@ -179,7 +179,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
179179
this.columns = columns
180180

181181
filterFn() // Support <IE9
182-
$.each(this.columns, (i, column) => {
182+
for (const column of this.columns) {
183183
let found = false
184184
const field = column.field
185185

@@ -191,7 +191,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
191191
}
192192
return true
193193
})
194-
})
194+
}
195195

196196
this.options.columns[0] = optionsColumns
197197

0 commit comments

Comments
 (0)