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 eb519eb commit 430d396
Show file tree
Hide file tree
Showing 3 changed files with 104 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
96 changes: 96 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// @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 react from 'eslint-plugin-react';
import globals from 'globals';
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',
},

languageOptions: {
globals: { ...globals.browser },
},

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'],

rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ varsIgnorePattern: '[iI]gnored', argsIgnorePattern: '^_' },
],
'@typescript-eslint/explicit-module-boundary-types': 'off',

'no-void': ['error', { allowAsStatement: true }],
'@typescript-eslint/no-floating-promises': [
'error',
{ ignoreVoid: true },
],

'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, classes: false },
],

'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
},
},
{
files: ['**/*.spec.ts', '**/*.spec.tsx'],

rules: {
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/unbound-method': 'off',
},
},
);
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@
"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-react": "^7.34.2",
"prettier": "^3.3.1",
"typescript-eslint": "^7.12.0",
"webpack-cli": "^5.1.4"
},
"peerDependencies": {
Expand Down

0 comments on commit 430d396

Please sign in to comment.