Skip to content

Commit

Permalink
eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
yaroslav-ilin committed Jun 10, 2024
1 parent 4bcc7b8 commit 7957016
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ lib/maxmind :
.PHONY : fmt
fmt :
bun x prettier --write .
bun x eslint --fix .
@ git diff-index --quiet HEAD

.PHONY : test
Expand Down
76 changes: 76 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// @ts-check

import fs from 'node:fs';

import eslint from '@eslint/js';
import prettierConfig from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';
import jest from 'eslint-plugin-jest';
import react from 'eslint-plugin-react';
import tseslint from 'typescript-eslint';

export default tseslint.config(
{
ignores: ['eslint.config.js'].concat(
fs.readFileSync('.gitignore', 'utf8').split('\n').filter(Boolean),
),
},

eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
{
languageOptions: {
parserOptions: {
project: true,
ecmaFeatures: { jsx: true },
},
},
},
prettierConfig,

{
linterOptions: {
reportUnusedDisableDirectives: 'error',
},
plugins: {
import: importPlugin,
react,
},
},

{
settings: {
'import/core-modules': ['bun:test'],
},

rules: {
'import/order': [
'error',
{ alphabetize: { order: 'asc' }, 'newlines-between': 'always' },
],
'no-unused-vars': [
'error',
{ varsIgnorePattern: '[iI]gnored', argsIgnorePattern: '^_' },
],
curly: 'error',
'default-case': 'error',
},
},
{
files: ['**/*.ts', '**/*.tsx', '**/*.mts'],
rules: {
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ varsIgnorePattern: '[iI]gnored', argsIgnorePattern: '^_' },
],
'no-void': ['error', { allowAsStatement: true }],
},
},
{
files: ['**/*.spec.ts', '**/*.spec.tsx'],
plugins: { jest },
settings: { jest: { version: 29 } },
...jest.configs['flat/recommended'],
},
);
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@
"mmdb-lib": "^2.1.1"
},
"devDependencies": {
"@eslint/js": "^9.4.0",
"@types/bun": "latest",
"@types/eslint__js": "^8.42.3",
"eslint": "^9.4.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-react": "^7.34.2",
"prettier": "^3.3.1",
"typescript-eslint": "^7.13.0",
"webpack-cli": "^5.1.4"
},
"peerDependencies": {
Expand Down

0 comments on commit 7957016

Please sign in to comment.