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

Add ESLint 9 to support oxlint #834

Merged
merged 15 commits into from
Feb 19, 2025
Merged
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
31 changes: 13 additions & 18 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"ignorePatterns": [
"node_modules/**",
".github/**",
".husky/**",
"build/**",
"public/build/**",
"docker/volumes/**",
"docs/img/**",
"config/**",
"dev-secrets/**",
"playwright-report/**"
"docker/volumes/**",
"docs/**",
"node_modules/**",
"playwright-report/**",
"public/build/**",
"test/e2e/**",
"test-results/**",
"playwright.config.ts"
],
"plugins": ["react", "unicorn", "typescript", "oxc", "react-hooks", "import", "jsx-a11y"],
"rules": {
"no-console": ["warn"],
"no-else-return": ["error"],
"curly": ["error"],
"no-unused-vars": [
"error",
{
"caughtErrors": "none"
}
]
},
"settings": {
"jest": {
"version": 28
}
"no-else-return": ["error"]
}
}
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"oxc.oxc-vscode",
"ms-playwright.playwright",
"yoavbls.pretty-ts-errors",
"waderyan.gitblame"
"waderyan.gitblame",
"dbaeumer.vscode-eslint"
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"editor.tabSize": 2,
"editor.detectIndentation": false,
"typescript.tsdk": "node_modules/typescript/lib",
"cSpell.words": ["Starchart"]
"cSpell.words": ["oxlint", "oxlintrc", "Starchart"],
"eslint.useFlatConfig": true
}
1 change: 1 addition & 0 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { PassThrough } from 'stream';
import type { EntryContext } from '@remix-run/node';
import { Response } from '@remix-run/node';
import { RemixServer } from '@remix-run/react';
// eslint-disable-next-line import/no-named-as-default
import isbot from 'isbot';
import logger from '~/lib/logger.server';
import { renderToPipeableStream } from 'react-dom/server';
Expand Down
4 changes: 2 additions & 2 deletions app/lib/lets-encrypt.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getHostedZoneForDomain = async (incomingDomain: string): Promise<string> =
try {
await dnsPromises.resolveSoa(domainName);
found = true;
} catch (e) {
} catch {
// remove one level, i.e., c.b.a.com => b.a.com
domainName = domainName.replace(/^.*?\./, '');
}
Expand Down Expand Up @@ -153,7 +153,7 @@ class LetsEncrypt {
.flat();

return txtRecords.includes(key);
} catch (e) {
} catch {
/**
* Noop, this is expected
* example: {
Expand Down
12 changes: 8 additions & 4 deletions app/routes/_auth.admin._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const action = async ({ request }: ActionArgs) => {

const { intent } = actionParams.data;
switch (intent) {
case 'search-users':
case 'search-users': {
const { searchText } = actionParams.data;

const users = await searchUsers(searchText ?? '');
Expand All @@ -93,19 +93,23 @@ export const action = async ({ request }: ActionArgs) => {
});

return typedjson({ users: usersWithStats });
case 'impersonate-user':
}
case 'impersonate-user': {
const { newEffectiveUsername } = actionParams.data;
if (!newEffectiveUsername) {
throw new Response('Missing username for impersonation', { status: 400 });
}
return startImpersonation(request, newEffectiveUsername);
case 'delete-user':
}
case 'delete-user': {
const { username } = actionParams.data;
await deleteUser(username ?? '');

return typedjson({ isUserDeleted: true });
default:
}
default: {
return typedjson({ result: 'error', message: 'Unknown intent' });
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion app/routes/_auth.certificate.download.$part.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function loader({ request, params }: LoaderArgs) {
default:
throw new Response(`Unknown certificate part: ${params.part}`, { status: 400 });
}
} catch (e) {
} catch {
throw new Response('Certificate Not Found', { status: 404 });
}
}
2 changes: 1 addition & 1 deletion app/routes/healthcheck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function loader({ request }: LoaderArgs) {
}),
]);
return json({ status: 'ok ' });
} catch (error: unknown) {
} catch {
return json({ status: 'error' }, { status: 500 });
}
}
2 changes: 1 addition & 1 deletion app/routes/sp.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { LoaderArgs } from '@remix-run/node';
import { metadata } from '~/lib/saml.server';

// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export async function loader({ params }: LoaderArgs) {
const meta = metadata();
return new Response(meta, {
Expand Down
12 changes: 7 additions & 5 deletions app/session.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,21 @@ export async function setEffectiveUsername(
// This is an admin user, figure out what to do based on effectiveUsername.
switch (effectiveUsername) {
/* Existing session, so we're ending impersonation */
case null:
case null: {
logger.info(`Admin (${username}) ending impersonation`);
// falls through
// falls through
}

/* New or Lost Session */
case undefined:
case undefined: {
// (re)set the effectiveUsername to null
return await effectiveUsernameCookie.serialize(null);

}
/* Starting impersonation of specified user */
default:
default: {
logger.info(`Admin (${username}) started impersonating user: ${effectiveUsername}`);
return await effectiveUsernameCookie.serialize(effectiveUsername);
}
}
}

Expand Down
125 changes: 125 additions & 0 deletions eslint.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
const path = require('node:path');

const js = require('@eslint/js');
const { includeIgnoreFile } = require('@eslint/compat');

const typescriptEslint = require('@typescript-eslint/eslint-plugin');
const typescriptParser = require('@typescript-eslint/parser');

const importPlugin = require('eslint-plugin-import');
const reactPlugin = require('eslint-plugin-react');
const jsxA11yPlugin = require('eslint-plugin-jsx-a11y');
const reactHooksPlugin = require('eslint-plugin-react-hooks');
const oxlint = require('eslint-plugin-oxlint');

const globals = require('globals');

const gitignorePath = path.resolve(__dirname, '.gitignore');

/** @type {import('eslint').Linter.Config[]} */
module.exports = [
js.configs.recommended,
importPlugin.flatConfigs.recommended,
includeIgnoreFile(gitignorePath),
{
ignores: [
'.github/**',
'.husky/**',
'config/**',
'dev-secrets/**',
'docs/**',
'test/e2e/**',
'playwright.config.ts',
],
},
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
globals: {
...globals.browser,
...globals.commonjs,
...globals.es6,
...globals.jest,
process: 'readonly',
},
},
linterOptions: {
reportUnusedDisableDirectives: 'off',
},
plugins: {
'react': reactPlugin,
'jsx-a11y': jsxA11yPlugin,
'react-hooks': reactHooksPlugin,
},
rules: {
...reactHooksPlugin.configs.recommended.rules,
...reactPlugin.configs.recommended.rules,
...jsxA11yPlugin.configs.recommended.rules,
'react/no-unescaped-entities': 'off',
'react/display-name': 'off',
'react/prop-types': 'off',
'no-prototype-builtins': 'off',
},
settings: {
'react': {
version: 'detect',
},
'jest': {
version: 27,
},
'formComponents': ['Form'],
'linkComponents': [
{ name: 'Link', linkAttribute: 'to' },
{ name: 'NavLink', linkAttribute: 'to' },
],
'import/resolver': {
typescript: {
alwaysTryTypes: true,
},
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
'import/ignore': ['.(css)$'],
},
},
// TypeScript configuration
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
globals: {
...globals.node,
React: 'readonly',
NodeJS: 'readonly',
},
},
plugins: {
'@typescript-eslint': typescriptEslint,
},
rules: {
...typescriptEslint.configs.recommended.rules,
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'no-undef': 'off',
},
},
// Node environment for eslint.config.cjs
{
files: ['eslint.config.cjs'],
languageOptions: {
globals: {
...globals.node,
},
},
},
...oxlint.buildFromOxlintConfigFile('./.oxlintrc.json'),
];
Loading
Loading