Skip to content

Commit

Permalink
Update eslint and fix some lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhixin committed Dec 10, 2024
1 parent 0d63300 commit be3beb9
Show file tree
Hide file tree
Showing 12 changed files with 505 additions and 272 deletions.
114 changes: 0 additions & 114 deletions .eslintrc.cjs

This file was deleted.

3 changes: 0 additions & 3 deletions .ncurc.json

This file was deleted.

128 changes: 128 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import babelParser from '@babel/eslint-parser'
import globals from 'globals'
import js from '@eslint/js'
import pluginImport from 'eslint-plugin-import'

export default [
js.configs.recommended,
pluginImport.flatConfigs.recommended,
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
$: true,
jQuery: true
},
parser: babelParser,
parserOptions: {
requireConfigFile: false
},
ecmaVersion: 'latest',
sourceType: 'module'
},
rules: {
'array-bracket-newline': ['error', 'consistent'],
'array-bracket-spacing': ['error', 'never'],
'array-element-newline': 'off',
'arrow-body-style': ['error', 'as-needed'],
'arrow-parens': ['error', 'as-needed'],
'arrow-spacing': ['error', { after: true, before: true }],
'block-spacing': 'error',
'brace-style': ['error', '1tbs'],
camelcase: 'off',
'comma-dangle': ['error', 'never'],
'comma-spacing': ['error', { after: true, before: false }],
'comma-style': 'off',
'computed-property-spacing': ['error', 'never'],
'default-case': 'error',
'dot-location': ['error', 'property'],
'eol-last': ['error', 'always'],
eqeqeq: 'error',
'func-call-spacing': ['error', 'never'],
'guard-for-in': 'warn',
indent: ['error', 2, {
ArrayExpression: 1,
CallExpression: { arguments: 1 },
FunctionDeclaration: { parameters: 'first' },
ImportDeclaration: 'first',
MemberExpression: 1,
ObjectExpression: 1,
SwitchCase: 1
}],
'import/extensions': 'off',
'import/no-named-as-default-member': 'off',
'import/no-unresolved': 'off',
'key-spacing': ['error', { afterColon: true, beforeColon: false, mode: 'strict' }],
'keyword-spacing': ['error', { after: true, before: true }],
'linebreak-style': ['error', 'unix'],
'line-comment-position': 'off',
'lines-around-comment': 'off',
'lines-between-class-members': ['error', 'always'],
'max-len': 'off',
'max-statements-per-line': ['error', { max: 1 }],
'multiline-ternary': 'off',
'no-alert': 'error',
'no-async-promise-executor': 'off',
'no-case-declarations': 'off',
'no-console': ['warn', { allow: ['warn', 'error', 'trace'] }],
'no-duplicate-imports': 'error',
'no-else-return': ['error', { allowElseIf: false }],
'no-extra-parens': 'error',
'no-lonely-if': 'error',
'no-mixed-spaces-and-tabs': 'error',
'no-multi-spaces': 'error',
'no-multi-str': 'error',
'no-multiple-empty-lines': 'error',
'no-new-func': 'error',
'no-param-reassign': 'off',
'no-prototype-builtins': 'off',
'no-return-assign': 'error',
'no-return-await': 'error',
'no-sequences': 'error',
'no-tabs': 'error',
'no-throw-literal': 'error',
'no-trailing-spaces': 'error',
'no-undef-init': 'error',
'no-unused-vars': 'error',
'no-use-before-define': 'warn',
'no-useless-constructor': 'warn',
'no-var': 'error',
'no-void': 'error',
'no-whitespace-before-property': 'error',
'object-curly-spacing': ['error', 'always'],
'object-shorthand': 'error',
'one-var': ['error', 'never'],
'operator-assignment': ['error', 'always'],
'operator-linebreak': ['error', 'after'],
'padding-line-between-statements': [
'error',
{ blankLine: 'always', next: '*', prev: ['const', 'let', 'var'] },
{ blankLine: 'any', next: ['const', 'let', 'var'], prev: ['const', 'let', 'var'] },
{ blankLine: 'always', next: 'export', prev: '*' }
],
'prefer-const': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'quote-props': ['error', 'as-needed'],
quotes: ['error', 'single'],
semi: ['error', 'never'],
'semi-spacing': ['error', { after: true, before: false }],
'semi-style': ['error', 'last'],
'sort-imports': ['error', {
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: true
}],
'space-before-blocks': ['error', { classes: 'always', functions: 'always', keywords: 'always' }],
'space-before-function-paren': ['error', 'always'],
'space-in-parens': ['error', 'never'],
'space-infix-ops': 'error',
'spaced-comment': ['error', 'always'],
'switch-colon-spacing': 'error',
'template-curly-spacing': ['error', 'never']
}
}
]
20 changes: 12 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,37 @@
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/eslint-parser": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@eslint/js": "^9.16.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^28.0.1",
"@rollup/plugin-inject": "^5.0.5",
"@rollup/plugin-multi-entry": "^6.0.1",
"@rollup/plugin-node-resolve": "^15.3.0",
"@rollup/plugin-terser": "^0.4.4",
"@vitejs/plugin-vue": "^5.2.0",
"@vitejs/plugin-vue": "^5.2.1",
"chalk": "^5.3.0",
"clean-css-cli": "^5.6.3",
"core-js": "^3.39.0",
"cross-env": "^7.0.3",
"cspell": "^8.16.0",
"cypress": "^13.16.0",
"cspell": "^8.16.1",
"cypress": "^13.16.1",
"editorconfig-checker": "^6.0.0",
"eslint": "^8.57.0",
"eslint": "^9.16.0",
"eslint-plugin-import": "^2.31.0",
"foreach-cli": "^1.8.1",
"glob": "^11.0.0",
"globals": "^15.13.0",
"headr": "^0.0.4",
"npm-run-all": "^4.1.5",
"rimraf": "^6.0.1",
"rollup": "^4.27.3",
"rollup": "^4.28.1",
"rollup-plugin-copy": "^3.5.0",
"sass": "^1.81.0",
"stylelint": "^16.10.0",
"sass": "^1.82.0",
"stylelint": "^16.11.0",
"stylelint-config-standard-scss": "^14.0.0",
"vite": "^6.0.1",
"vite": "^6.0.3",
"vue": "^3.5.13"
},
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions src/extensions/cookie/bootstrap-table-cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
try {
filterByCookie = JSON.parse(filterByCookieValue)
} catch (e) {
console.error(e)
throw new Error('Could not parse the json of the filterBy cookie!')
}
this.filterColumns = filterByCookie ? filterByCookie : {}
Expand Down Expand Up @@ -461,12 +462,14 @@ $.BootstrapTable = class extends $.BootstrapTable {
hiddenColumnsCookie = JSON.parse(hiddenColumnsCookieValue)
columnsCookie = JSON.parse(columnsCookieValue)
} catch (e) {
console.error(e)
throw new Error('Could not parse the json of the columns cookie!')
}

try {
sortPriorityCookie = JSON.parse(sortPriorityCookie)
} catch (e) {
console.error(e)
throw new Error('Could not parse the json of the sortPriority cookie!', sortPriorityCookie)
}

Expand Down
2 changes: 1 addition & 1 deletion src/extensions/copy-rows/bootstrap-table-copy-rows.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const copyText = text => {
try {
document.execCommand('copy')
} catch (e) {
console.warn('Oops, unable to copy')
console.warn('Oops, unable to copy', e)
}
$(textField).remove()
}
Expand Down
6 changes: 2 additions & 4 deletions src/extensions/filter-control/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ export function sortSelectControl (selectControl, orderBy, options) {
tmpAry[i][2] = $selectControl.options[i].selected
}

tmpAry.sort((a, b) => {
return Utils.sort(a[0], b[0], orderBy === 'desc' ? -1 : 1, options)
})
tmpAry.sort((a, b) => Utils.sort(a[0], b[0], orderBy === 'desc' ? -1 : 1, options))
while ($selectControl.options.length > 0) {
$selectControl.options[0] = null
}
Expand Down Expand Up @@ -177,7 +175,7 @@ export function setCaretPosition (elem, caretPos) {
}
}
} catch (ex) {
// ignored
console.error(ex)
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/extensions/print/bootstrap-table-print.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
}

doPrint (data) {
const canPrint = column => {
return !column.printIgnore && column.visible
}
const canPrint = column => !column.printIgnore && column.visible

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

const columns = columnsArray.flat(1)

columns.sort((c1, c2) => {
return c1.colspanIndex - c2.colspanIndex
})
columns.sort((c1, c2) => c1.colspanIndex - c2.colspanIndex)

for (let j = 0; j < columns.length; j++) {
if (columns[j].colspanGroup > 0) continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
try {
$(this.$el).dragtable('destroy')
} catch (e) {
// do nothing
console.error(e)
}
$(this.$el).dragtable({
maxMovingRows: this.options.maxMovingRows,
Expand Down Expand Up @@ -179,7 +179,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
this.columns = columns

filterFn() // Support <IE9
$.each(this.columns, (i, column) => {
for (const column of this.columns) {
let found = false
const field = column.field

Expand All @@ -191,7 +191,7 @@ $.BootstrapTable = class extends $.BootstrapTable {
}
return true
})
})
}

this.options.columns[0] = optionsColumns

Expand Down
Loading

0 comments on commit be3beb9

Please sign in to comment.