Skip to content

Commit

Permalink
chore(frontend-react): Upgrade to ESLint v9
Browse files Browse the repository at this point in the history
  • Loading branch information
pklaschka committed Dec 6, 2024
1 parent 2cbf848 commit c9ef75c
Show file tree
Hide file tree
Showing 8 changed files with 133 additions and 56 deletions.
49 changes: 0 additions & 49 deletions frontend-react/.eslintrc.cjs

This file was deleted.

87 changes: 87 additions & 0 deletions frontend-react/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import globals from 'globals';
import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';
import pluginReact from 'eslint-plugin-react';
import pluginReactHooks from 'eslint-plugin-react-hooks';
import pluginPrettier from 'eslint-plugin-prettier/recommended';
import pluginJsxA11y from 'eslint-plugin-jsx-a11y';
import pluginTsDoc from 'eslint-plugin-tsdoc';

const TS_CONFIG = [
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
// projectService: true,
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: import.meta.dirname
}
}
},
{
rules: {
'@typescript-eslint/no-throw-literal': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/consistent-type-definitions': 'off'
}
}
];

const REACT_CONFIG = [
pluginReact.configs.flat.recommended,
pluginReact.configs.flat['jsx-runtime'],
{
rules: {
'react/no-unescaped-entities': 'off'
}
},
{
settings: {
react: {
version: 'detect'
}
}
}, // eslint-plugin-react-hooks:
{
files: ['src/**/*.{js,ts,jsx,tsx}'],
plugins: {
'react-hooks': pluginReactHooks
},
rules: {
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',
...pluginReactHooks.configs.recommended.rules
}
}
];

/** @type {import('eslint').Linter.Config[]} */
export default [
{
files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}']
},
{
languageOptions: {
globals: {
...globals.browser
}
}
},
pluginJs.configs.recommended,
...TS_CONFIG,
...REACT_CONFIG,
pluginPrettier,
pluginJsxA11y.flatConfigs.strict,
{
plugins: {
tsdoc: pluginTsDoc
},
rules: {
'tsdoc/syntax': 'warn'
}
},
{
ignores: ['dist', 'types', 'node_modules', 'features', 'eslint.config.js']
}
];
8 changes: 5 additions & 3 deletions frontend-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
"test": "vitest --ui",
"style": "prettier --write .",
"preview": "vite preview",
Expand Down Expand Up @@ -110,6 +110,7 @@
},
"devDependencies": {
"@cucumber/cucumber": "^11.1.0",
"@eslint/js": "^9.16.0",
"@types/node": "^20.17.9",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.1",
Expand All @@ -123,9 +124,9 @@
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-react-refresh": "^0.4.16",
"eslint-plugin-react-hooks": "^5.1.0-rc.1",
"eslint-plugin-tsdoc": "^0.4.0",
"globals": "^15.13.0",
"happy-dom": "^15.11.7",
"prettier": "3.4.2",
"react": "^19.0.0",
Expand All @@ -135,6 +136,7 @@
"typedoc-plugin-mdn-links": "^4.0.3",
"typedoc-plugin-zod": "^1.3.0",
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0",
"vite": "^6.0.3",
"vite-plugin-banner": "^0.8.0",
"vitest": "^2.1.8"
Expand Down
38 changes: 37 additions & 1 deletion frontend-react/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend-react/src/lib/application/hooks/use-widget-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { widgetConfigContext } from '../../widget';
* @returns The widget configuration retrieved from the widgetConfigContext.
* @throws Error Throws an error if useWidgetConfig is not used within a WidgetConfigProvider.
*/
// The type is safe due to the surrounding application structure.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
export function useWidgetConfig<T>(): T {
const widgetConfig = useContext(widgetConfigContext);
if (!widgetConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export function resizeGrid(

if (columns < 1 || rows < 1) {
throw new InvalidBoundsError(
`Invalid grid size while resizing the grid. Must be at least 1x1, got ${columns}x${rows}`
`Invalid grid size while resizing the grid. Must be at least 1x1, got ${columns.toString()}x${rows.toString()}`
);
}

Expand Down
1 change: 0 additions & 1 deletion frontend-react/src/lib/auth/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export async function login(
setUser({ natsUrl, username });
setNatsConnection(nc);

// eslint-disable-next-line @typescript-eslint/no-deprecated
setAutoLoginCredentials({
natsUrl,
username,
Expand Down
2 changes: 1 addition & 1 deletion frontend-react/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"strictNullChecks": true,
"resolveJsonModule": true
},
"include": ["vite.config.ts", "package.json"]
"include": ["vite.config.ts", "eslint.config.js", "package.json"]
}

0 comments on commit c9ef75c

Please sign in to comment.