Skip to content

Commit

Permalink
chore: upgrade eslint to version 9
Browse files Browse the repository at this point in the history
chore: wip

chore: wip

chore: update next js
  • Loading branch information
jonas-jonas committed Dec 5, 2024
1 parent 0822462 commit 88b0fed
Show file tree
Hide file tree
Showing 79 changed files with 2,451 additions and 2,434 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

42 changes: 0 additions & 42 deletions .eslintrc.cjs

This file was deleted.

185 changes: 185 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
import eslint from "@eslint/js"
import tsParser from "@typescript-eslint/parser"
import formatjs from "eslint-plugin-formatjs"
import playwright from "eslint-plugin-playwright"
import pluginPromise from "eslint-plugin-promise"
import react from "eslint-plugin-react"
import reactHooks from "eslint-plugin-react-hooks"
import storybook from "eslint-plugin-storybook"
import tsdoc from "eslint-plugin-tsdoc"
import globals from "globals"
import tseslint from "typescript-eslint"

const config = tseslint.config([
{
ignores: [
"**/assets/*.js",
"!.storybook",
"**/dist/**",
"**/storybook-static/**",
"babel.config.js",
"eslint.config.mjs",
"**/playwright-report/**",
"examples/nextjs-spa/**", // This project is not maintained
"**/playwright.config.{js,ts}",
"**/playwright-ct.config.ts",
"**/jest.config.{js,ts}",
"**/jest.preset.{cjs,ts}",
"playwright/**",
"**/tsup.config.{js,ts}",
],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
pluginPromise.configs["flat/recommended"],
storybook.configs["flat/recommended"],
{
rules: {
"@typescript-eslint/no-unused-vars": [
"error",
{
args: "all",
argsIgnorePattern: "^_",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_",
destructuredArrayIgnorePattern: "^_",
varsIgnorePattern: "^_",
ignoreRestSiblings: true,
},
],
},
},
{
files: ["**/src/**/*.{js,jsx,mjs,cjs,ts,tsx}"],
plugins: {
react,
tsdoc,
formatjs,
},

languageOptions: {
globals: {
...globals.browser,
...globals.node,
},

parser: tsParser,
ecmaVersion: 2021,
sourceType: "module",

parserOptions: {
tsconfigRootDir: "./",

ecmaFeatures: {
jsx: true,
},
},
},

rules: {
"tsdoc/syntax": "warn",
"formatjs/no-offset": "error",
"@typescript-eslint/no-floating-promises": "error",
// The legacy elements is written with lots of any types
"no-unused-vars": "off",
"no-undef": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"react/prop-types": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-member-access": "off",

"@typescript-eslint/no-unused-vars": [
"error",
{
argsIgnorePattern: "^_",
varsIgnorePattern: "^_",
caughtErrorsIgnorePattern: "^_",
},
],

"no-extra-semi": "off",
},
},
{
name: "elements-react",
files: ["packages/elements-react/**"],
plugins: {
"react-hooks": reactHooks,
},
rules: {
...reactHooks.configs.recommended.rules,
},
},
{
name: "playwright-tests",
files: ["src/**/*.spec.ts"],
...playwright.configs["flat/recommended"],
rules: {
...playwright.configs["flat/recommended"].rules,
"no-empty-pattern": "off",
},
},
{
name: "legacy-examples",
files: ["examples/preact-spa/**", "examples/react-spa/**"],
languageOptions: {
parserOptions: {
tsconfigRootDir: "./",
ecmaVersion: 2021,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
react,
tsdoc,
},
rules: {
"tsdoc/syntax": "warn",
// The legacy examples violate these rule a ton, so we disable it
"promise/always-return": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-explicit-any": "off",
},
},
{
files: ["packages/elements-react-stories/**"],
rules: {
// The stories need to be able to require the JSON files, at the moment
"@typescript-eslint/no-require-imports": "off",
},
},
{
name: "legacy-elements",
files: ["src/react-components/**", "src/ui/**"],
rules: {
"@typescript-eslint/unbound-method": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-argument": "off",
"tsdoc/syntax": "off",
"@typescript-eslint/no-explicit-any": "off",
},
},
{
name: "tests",
files: ["**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unsafe-call": "off",
},
},
])

export default config
4 changes: 0 additions & 4 deletions examples/nextjs-spa/.eslintrc.json

This file was deleted.

5 changes: 2 additions & 3 deletions examples/nextjs-spa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
"dev": "NODE_OPTIONS='--inspect' next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"debug": "playwright test --ui"
},
"dependencies": {
"@next/font": "13.4.13",
"next": "14.2.10",
"next": "15.0.3",
"react": "18.3.1",
"react-dom": "18.3.1"
},
Expand All @@ -22,7 +21,7 @@
"@types/node": "18.16.19",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"eslint-config-next": "13.1.5",
"eslint-config-next": "15.0.3",
"typescript": "5.2.2",
"vite": "5.4.10"
}
Expand Down
31 changes: 0 additions & 31 deletions examples/preact-spa/.eslintrc.cjs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright © 2023 Ory Corp
// SPDX-License-Identifier: Apache-2.0

const globlSetup = async () => {
const globlSetup = () => {
process.env.APPLICATION_URL =
process.env.APPLICATION_URL || "http://localhost:3200"

Expand Down
2 changes: 1 addition & 1 deletion examples/preact-spa/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default defineConfig({
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',

globalSetup: "./global-setup",
globalSetup: "./e2e/global-setup",
//globalTeardown: "./global-teardown",

/* Run your local dev server before starting the tests */
Expand Down
2 changes: 1 addition & 1 deletion examples/preact-spa/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { sdk, sdkError } from "./sdk"
export const Dashboard = () => {
const [session, setSession] = useState<Session | null>(null)
const [logoutUrl, setLogoutUrl] = useState<string>()
const [location, setLocation] = useLocation()
const [_, setLocation] = useLocation()

const sdkErrorHandler = sdkError(undefined, undefined, "/login")

Expand Down
2 changes: 1 addition & 1 deletion examples/preact-spa/src/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const Error = () => {
setError(
JSON.stringify(JSON.parse(decodeURIComponent(queryError)), null, 2),
)
} catch (error) {
} catch (_error) {
setError(queryError)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion examples/preact-spa/src/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const Login = () => {
sdk
.updateLoginFlow({
flow: flow.id,
updateLoginFlowBody: body as UpdateLoginFlowBody,
updateLoginFlowBody: body,
})
.then(() => {
// we successfully submitted the login flow, so lets redirect to the dashboard
Expand Down
4 changes: 2 additions & 2 deletions examples/preact-spa/src/recovery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getSearchParam, sdk, sdkError } from "./sdk"
export const Recovery = () => {
const [flow, setFlow] = useState<RecoveryFlow | null>(null)

const [location, setLocation] = useLocation()
const [_, setLocation] = useLocation()

const getFlow = useCallback(
(flowId: string) =>
Expand Down Expand Up @@ -41,7 +41,7 @@ export const Recovery = () => {
sdk
.updateRecoveryFlow({
flow: flow.id,
updateRecoveryFlowBody: body as UpdateRecoveryFlowBody,
updateRecoveryFlowBody: body,
})
.then(({ data: flow }) => {
// Form submission was successful, show the message to the user!
Expand Down
2 changes: 1 addition & 1 deletion examples/preact-spa/src/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useLocation } from "wouter-preact"
export const Register = () => {
const [flow, setFlow] = useState<RegistrationFlow | null>(null)

const [location, setLocation] = useLocation()
const [_, setLocation] = useLocation()

// Get the flow based on the flowId in the URL (.e.g redirect to this page after flow initialized)
const getFlow = useCallback(
Expand Down
5 changes: 2 additions & 3 deletions examples/preact-spa/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useLocation } from "wouter-preact"
export const sdk = new FrontendApi(
new Configuration({
//https://vitejs.dev/guide/env-and-mode.html#env-files
basePath: import.meta.env.VITE_ORY_SDK_URL,
basePath: import.meta.env.VITE_ORY_SDK_URL as string,
baseOptions: {
withCredentials: true,
},
Expand All @@ -25,12 +25,11 @@ export const sdk = new FrontendApi(
*/
export const sdkError = (
getFlow: ((flowId: string) => Promise<void | AxiosError>) | undefined,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setFlow: StateUpdater<any> | undefined,
defaultNav: string | undefined,
fatalToDash = false,
) => {
const [location, setLocation] = useLocation()
const [_, setLocation] = useLocation()

return useCallback(
(error: AxiosError<any, unknown>): Promise<AxiosError | void> => {
Expand Down
2 changes: 1 addition & 1 deletion examples/preact-spa/src/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const Settings = () => {
sdk
.updateSettingsFlow({
flow: flow.id,
updateSettingsFlowBody: body as UpdateSettingsFlowBody,
updateSettingsFlowBody: body,
})
.then(({ data: flow }) => {
setFlow(flow)
Expand Down
Loading

0 comments on commit 88b0fed

Please sign in to comment.