Skip to content

Commit

Permalink
Setup eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
amitsingh-007 committed Oct 12, 2024
1 parent 6561173 commit 7ecfdb1
Show file tree
Hide file tree
Showing 50 changed files with 1,382 additions and 593 deletions.
105 changes: 105 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { fixupPluginRules } from '@eslint/compat';
import eslint from '@eslint/js';
import gitignore from 'eslint-config-flat-gitignore';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
import reactJsxRuntime from 'eslint-plugin-react/configs/jsx-runtime.js';
import reactRecommended from 'eslint-plugin-react/configs/recommended.js';
import eslintPluginUnicorn from 'eslint-plugin-unicorn';
import globals from 'globals';
import tseslint from 'typescript-eslint';

// !NOTE: Add types to eslint-mocked-types.d.ts if getting TS error for plugins

export default tseslint.config(
gitignore(),
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
{
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
files: ['**/*.js'],
...tseslint.configs.disableTypeChecked,
},
{
ignores: ['**/*.js', '**/*.mjs', '**/*.cjs'],
},
eslintPluginUnicorn.configs['flat/recommended'],
// react eslint config
{
files: ['**/*.{ts,tsx}'],
...reactRecommended,
...reactJsxRuntime,
languageOptions: {
...reactRecommended.languageOptions,
globals: {
...globals.serviceworker,
...globals.browser,
...globals.webextensions,
},
},
},
// react hooks eslint config
{
plugins: {
'react-hooks': fixupPluginRules(eslintPluginReactHooks),
},
rules: {
...eslintPluginReactHooks.configs.recommended.rules,
},
},
// configure & override all rules
{
rules: {
/**
* TODO: Remove once this is closed
* @link https://github.com/typescript-eslint/typescript-eslint/issues/9902#issuecomment-2316722449
*/
'@typescript-eslint/no-deprecated': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/no-dynamic-delete': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unnecessary-type-parameters': 'off',
'@typescript-eslint/no-base-to-string': [
'error',
{
ignoredTypeNames: ['TRPCError'],
},
],
'@typescript-eslint/no-unused-vars': [
'warn',
{
args: 'after-used',
ignoreRestSiblings: true,
argsIgnorePattern: '^_',
},
],
'unicorn/prevent-abbreviations': 'off',
'unicorn/filename-case': 'off',
'unicorn/no-null': 'off',
'unicorn/no-array-for-each': 'off',
'unicorn/no-array-reduce': 'off',
'unicorn/prefer-ternary': 'off',
'unicorn/prefer-query-selector': 'off',
'unicorn/prefer-dom-node-dataset': 'off',
'unicorn/explicit-length-check': 'off',
'unicorn/no-useless-undefined': 'off',
},
},
// ? NOTE: always keep this at last; prettier eslint config.
eslintPluginPrettierRecommended
);
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "cards",
"version": "0.1.0",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "pnpm build && next start",
"lint": "next lint",
"lint": "eslint . --fix",
"deploy:preview": "vercel",
"env": "vercel env pull .env"
},
Expand Down Expand Up @@ -47,14 +48,22 @@
"zod": "3.23.8"
},
"devDependencies": {
"@eslint/compat": "1.2.0",
"@types/node": "20.6.0",
"@types/react": "18.3.10",
"@types/react-dom": "18.3.0",
"eslint": "8.57.1",
"eslint-config-flat-gitignore": "0.3.0",
"eslint-config-next": "14.2.14",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-react": "7.37.1",
"eslint-plugin-react-hooks": "5.0.0",
"eslint-plugin-unicorn": "56.0.0",
"globals": "15.11.0",
"postcss": "8.4.47",
"tailwindcss": "3.4.1",
"typescript": "5.6.2",
"typescript-eslint": "8.8.1",
"vercel": "37.6.0"
}
}
Loading

0 comments on commit 7ecfdb1

Please sign in to comment.