Skip to content

Commit

Permalink
Updated eslint settings
Browse files Browse the repository at this point in the history
Fixes #144
  • Loading branch information
tombeckenham committed Nov 7, 2024
1 parent 2293750 commit 54e724b
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 45 deletions.
7 changes: 0 additions & 7 deletions .eslintignore

This file was deleted.

31 changes: 0 additions & 31 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.20.4
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"singleQuote": true
"singleQuote": true,
"printWidth": 100
}
95 changes: 95 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import js from '@eslint/js';
import globals from 'globals';
import typescriptParser from '@typescript-eslint/parser';
import typescriptPlugin from '@typescript-eslint/eslint-plugin';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import importPlugin from 'eslint-plugin-import';

export default [
// Base config for all files
{
ignores: ['**/dist/**', '**/build/**', '**/node_modules/**', '**/.git/**', '**/coverage/**'],
},

// JavaScript and TypeScript files
{
files: ['**/*.{js,jsx,ts,tsx}'],
languageOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
parser: typescriptParser,
parserOptions: {
project: true,
},
globals: {
...globals.browser,
...globals.es2021,
...globals.node,
chrome: 'readonly',
},
},
plugins: {
'@typescript-eslint': typescriptPlugin,
react: reactPlugin,
'react-hooks': reactHooksPlugin,
import: importPlugin,
},
settings: {
'import/resolver': {
typescript: true,
node: true,
},
react: {
version: '17',
},
},
rules: {
// TypeScript specific rules
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],

// React rules
'react/react-in-jsx-scope': 'error', // Required for React 17
'react/prop-types': 'off',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',

// Import rules
'import/no-unresolved': 'error',
'import/order': [
'error',
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],

// General rules
'no-console': ['warn', { allow: ['warn', 'error'] }],
'prefer-const': 'error',
'no-var': 'error',
eqeqeq: ['error', 'always'],
'no-unused-expressions': 'error',
'no-duplicate-imports': 'error',

// Chrome extension specific
'no-restricted-globals': ['error', 'window', 'document'],
},
},

// Test files specific config
{
files: ['**/*.test.{js,jsx,ts,tsx}', '**/*.spec.{js,jsx,ts,tsx}'],
rules: {
'no-restricted-globals': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
},
];
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@eslint/js": "^9.14.0",
"@svgr/webpack": "^5.5.0",
"@types/chrome": "^0.0.183",
"@types/events": "^3.0.0",
Expand All @@ -148,24 +149,27 @@
"@types/react": "^17.0.4",
"@types/react-dom": "^17.0.3",
"@types/react-router-dom": "^5.1.7",
"@typescript-eslint/eslint-plugin": "^4.22.1",
"@typescript-eslint/parser": "^4.22.1",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
"@welldone-software/why-did-you-render": "^6.2.1",
"autoprefixer": "latest",
"css-loader": "^5.1.3",
"dotenv": "^16.3.1",
"dotenv-webpack": "^8.0.1",
"enquirer": "^2.3.6",
"eslint": "^7.25.0",
"eslint-config-prettier": "^8.3.0",
"eslint": "^9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-import": "^2.22.1",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-react": "^7.23.2",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"eslint-webpack-plugin": "^2.5.10",
"file-loader": "^6.2.0",
"fs-extra": "^10.0.0",
"globals": "^15.12.0",
"html-webpack-plugin": "^5.3.1",
"https-browserify": "^1.0.0",
"husky": "^9.1.6",
Expand All @@ -190,6 +194,7 @@
"ts-loader": "^9.1.1",
"tsconfig-paths-webpack-plugin": "^3.5.1",
"typescript": "^4.5.4",
"typescript-eslint": "^8.13.0",
"typescript-transform-paths": "^3.0.0",
"url-loader": "^4.1.1",
"webpack": "^5.26.3",
Expand Down

0 comments on commit 54e724b

Please sign in to comment.