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

feat: Improve eslint config and fix linting errors #41

Closed
wants to merge 4 commits into from
Closed
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.astro
dist
.eslintrc.cjs
.vscode
.vercel
src/db/migrations
Expand Down
59 changes: 39 additions & 20 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,53 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:astro/recommended',
'plugin:jsx-a11y/recommended',
'plugin:typescript-sort-keys/recommended',
],
overrides: [
{
extends: [
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/strict',
],
files: ['*.astro'],
parser: 'astro-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
extraFileExtensions: ['.astro'],
},
rules: {
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'deprecation/deprecation': 'off',
},
},
{
files: ['*.ts', '*.tsx'],
extends: [
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/strict',
],
rules: {
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-misused-promises': 'off',
},
},
{
files: ['*.json', '*.jsonc'],
excludedFiles: ['package.json'],
parser: 'jsonc-eslint-parser',
rules: {
'jsonc/sort-keys': 'error',
},
extends: ['plugin:jsonc/recommended-with-json'],
},
{
extends: ['plugin:markdown/recommended'],
files: ['**/*.md'],
Expand All @@ -33,32 +65,19 @@ module.exports = {
'@typescript-eslint',
'astro',
'deprecation',
'jsx-a11y',
'simple-import-sort',
'typescript-sort-keys',
],
root: true,
rules: {
'simple-import-sort/imports': 'error',
'no-empty-pattern': 'off',
'simple-import-sort/exports': 'error',
'deprecation/deprecation': 'error',

'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/await-thenable': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-empty-function': 'off',
'typescript-sort-keys/interface': 'off',
'no-empty-pattern': 'error',

// Stylistic concerns that don't interfere with Prettier
'padding-line-between-statements': 'off',
'@typescript-eslint/padding-line-between-statements': 'off',
'deprecation/deprecation': 'error',
'jsx-a11y/no-autofocus': 'off',
'no-empty-pattern': 'off',
'padding-line-between-statements': 'off',
'simple-import-sort/exports': 'error',
'simple-import-sort/imports': 'error',
},
};
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"eslint": "^8.40.0",
"eslint-plugin-astro": "^0.27.0",
"eslint-plugin-deprecation": "^1.4.1",
"eslint-plugin-jsonc": "^2.8.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-markdown": "^3.0.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-typescript-sort-keys": "^2.3.0",
Expand Down
1 change: 1 addition & 0 deletions src/components/app/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function Interal() {
e.preventDefault();
const form = e.currentTarget;
const formData = new FormData(form);
//eslint-disable-next-line @typescript-eslint/no-explicit-any , @typescript-eslint/no-unsafe-argument
addKeyMutation.mutate(Object.fromEntries(formData.entries()) as any, {
onSuccess: () => {
form.reset();
Expand Down
1 change: 1 addition & 0 deletions src/components/survey/Survey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function OptionalComments() {
e.preventDefault();
const form = e.currentTarget;
const formData = Object.fromEntries(new FormData(form));
//eslint-disable-next-line @typescript-eslint/no-explicit-any , @typescript-eslint/no-unsafe-argument
postSurveyMutation.mutate(formData as any);
}}
className="w-full px-8 sm:w-96"
Expand Down
1 change: 1 addition & 0 deletions src/components/trpc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function TRPCProvider({
})
);
// TODO: we should be passing dehydratedState to trpcClient not queryClient
//eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
const state = dehydratedState ? superjson.deserialize(dehydratedState as any) : undefined;
return (
<trpc.Provider client={trpcClient} queryClient={queryClient}>
Expand Down
1 change: 1 addition & 0 deletions src/t3-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const x = validateEnv({
// this function would be dead code eliminated
const client = () => {
// add check that values are strings
//eslint-disable-next-line @typescript-eslint/no-unused-vars
const v = (_: (ZodString | ZodOptional<ZodString>)[]) => {};

// this line will error if the client env is not a string
Expand Down
Loading