Skip to content

Commit

Permalink
Merge pull request #1332 from research-software-directory/eslint-upgrade
Browse files Browse the repository at this point in the history
chore: upgrade eslint to v9
  • Loading branch information
dmijatovic authored Oct 31, 2024
2 parents 49c0401 + 408db5c commit b92e9f1
Show file tree
Hide file tree
Showing 7 changed files with 230 additions and 213 deletions.
53 changes: 0 additions & 53 deletions frontend/.eslintrc.json

This file was deleted.

7 changes: 0 additions & 7 deletions frontend/.eslintrc.json.license

This file was deleted.

2 changes: 0 additions & 2 deletions frontend/components/admin/logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export default function ScraperErrorLogs() {
// here we pass deleteLog method to columns
const cols = createColumns(deleteLog)
setColumns(cols)
// do not include deleteLog to avoid loop
// eslint-disable-next-line react-hooks/exhaustive-deps
},[deleteLog])

return (
Expand Down
68 changes: 68 additions & 0 deletions frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import {dirname} from 'node:path'
import {fileURLToPath} from 'node:url'
import {FlatCompat} from '@eslint/eslintrc'

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

const compat = new FlatCompat({
baseDirectory: __dirname,
})

const eslintConfig = [
// Note! it does not work if only core-web-vitals are used
...compat.extends('next/core-web-vitals', 'next/typescript'),
// add custom rules
{
rules: {
'no-debugger': 'warn',
'no-console': 'warn',
// use direct imports on material-ui to improve
// performance in unit tests with jest
// see https://blog.bitsrc.io/why-is-my-jest-suite-so-slow-2a4859bb9ac0
'no-restricted-imports': ['warn', {
name: '@mui/material',
message: 'Please use "import foo from \'@mui/material/foo\'" instead.',
}],
// do not warn for use of img element
'@next/next/no-img-element': 'off',

// ---------------------------------------
// disable specific typescript rules
// we will use generic rules instead
'@typescript-eslint/no-explicit-any':'off',
'@typescript-eslint/no-unused-vars':'off',

// ---------------------------------------
// ENABLE LATER
// dissable rules we did not used in the past
// we can enable these rules in the future
// and fix the linter errors
'@typescript-eslint/no-empty-object-type' :'off',
'@typescript-eslint/prefer-as-const':'off',
'@typescript-eslint/no-unused-expressions':'off',
'@typescript-eslint/no-unsafe-function-type':'off',
'prefer-const':'off',
'no-unused-vars':'off',
'no-var':'off',

// ---------------------------------------
// FORMATTING (this rules are deprecated)
// Though it seems these still work for me in VS Code?
'eol-last': ['warn', 'always'],
'quotes': ['warn', 'single'],
'semi': ['warn', 'never'],
'indent': ['warn', 2, {
SwitchCase: 1,
}],
'no-trailing-spaces': 'warn',
'no-multi-spaces': 'warn',
'no-multiple-empty-lines': 'warn',
'object-curly-spacing': ['warn', 'never'],
'array-bracket-spacing': ['warn', 'never'],
// ---------------------------------------
},
}
]

export default eslintConfig
Loading

0 comments on commit b92e9f1

Please sign in to comment.