Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to ESLint Flat Config #344

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dprint.json → .dprint.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
"**/*/android/app",
"**/*/ios/App",
// TODO: Test and update configs for scss (Malva)
"**/*.scss"
]
"**/*.scss",
],
}
95 changes: 0 additions & 95 deletions canopeum_frontend/.eslintrc.cjs

This file was deleted.

115 changes: 115 additions & 0 deletions canopeum_frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'

import beslogicExtraStrict from 'eslint-config-beslogic/extra-strict.mjs'
import beslogicReact from 'eslint-config-beslogic/react.mjs'
import beslogicTypeScript from 'eslint-config-beslogic/typescript.mjs'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

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

export default tseslint.config(
beslogicReact,
beslogicTypeScript,
beslogicExtraStrict,
{
ignores: [
// Not found by the project service. Isn't included in any TSConfig
'index.html',
// Auto-generated
'src/services/api.ts',
],
},
{
files: [
'**/*.ts',
'**/*.tsx',
],
languageOptions: {
parserOptions: {
useProjectService: true,
// Still needed for plugins that haven't updated to typescript-eslint@8 yet
// Namely: eslint-plugin-sonarjs
EXPERIMENTAL_useProjectService: true,
// eslint-disable-next-line no-undef -- false-positive
tsconfigRootDir: __dirname,
},
},
rules: {
// FIXME: These started failing from a recent typescript-eslint update

Check warning on line 41 in canopeum_frontend/eslint.config.mjs

View workflow job for this annotation

GitHub Actions / Lint-Autofixes

Unexpected 'FIXME' comment: 'FIXME: These started failing from a...'
'@typescript-eslint/no-unsafe-type-assertion': 'warn',
'@typescript-eslint/no-misused-spread': 'warn',
},
},
{
plugins: { 'react-refresh': reactRefresh },
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true }, // Works fine in Vite
],

/*
* Beslogic presets overrides
*/
'simple-import-sort/imports': [
'error',
{
groups: [
// Side effect imports.
['^\\u0000'],
// Node.js builtins prefixed with `node:`.
['^node:'],
// Packages.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter
['^@?\\w'],
// Absolute imports and other imports such as Vue-style `@/foo`.
// Anything not matched in another group.
['^'],
// Relative imports.
// Anything that starts with a dot or src/
[
// KEEP IN SYNC WITH
// canopeum_frontend/tsconfig.json & canopeum_frontend/vite.config.ts
'^(\\.'
+ '|src/'
+ '|@assets'
+ '|@components'
+ '|@constants'
+ '|@hooks'
+ '|@models'
+ '|@pages'
+ '|@services'
+ '|@store'
+ '|@utils'
+ ')',
],
],
},
],
// Using Bootraps directly without a React wrapper
// will cause us to have to add classes to React Components
'react/forbid-component-props': 'off',
// Extremely slow rule
'etc/no-commented-out-code': 'off',
},
},
{
files: ['src/locale/**/*.ts'],
rules: {
// These are not credentials
'sonarjs/no-hardcoded-credentials': 'off',
// We prefer avoiding line-breaks in translation files
'@stylistic/max-len': 'off',
// Imports across languages to use the "satisfies" keyword on object literals
// We need to apply it directly on object literals to check for excess properties
// https://www.typescriptlang.org/docs/handbook/2/objects.html#excess-property-checks
'no-autofix/no-relative-import-paths/no-relative-import-paths': 'off',
// i18next uses snake_case for special handling
// https://www.i18next.com/translation-function/plurals#singular-plural
camelcase: 'off',
},
},
)
Loading
Loading