Skip to content

Commit

Permalink
Merge pull request #917 from serlo/chore/migrate-eslint-config
Browse files Browse the repository at this point in the history
chore: migrate eslint config and update package to 9*
  • Loading branch information
hugotiburtino authored Nov 5, 2024
2 parents 1be07d2 + 571bfb2 commit 49ab370
Show file tree
Hide file tree
Showing 49 changed files with 375 additions and 237 deletions.
117 changes: 0 additions & 117 deletions .eslintrc.json

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
166 changes: 166 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin'
import _import from 'eslint-plugin-import'
import react from 'eslint-plugin-react'
import _deprecation from 'eslint-plugin-deprecation'
import { fixupPluginRules } from '@eslint/compat'
import globals from 'globals'
import tsParser from '@typescript-eslint/parser'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'
import { FlatCompat } from '@eslint/eslintrc'

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
})

export default [
...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:react/recommended',
'prettier',
),
{
plugins: {
'@typescript-eslint': typescriptEslint,
import: fixupPluginRules(_import),
react,
deprecation: fixupPluginRules(_deprecation),
},

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

parser: tsParser,
ecmaVersion: 5,
sourceType: 'commonjs',

parserOptions: {
project: ['tsconfig.json'],
},
},

settings: {
react: {
pragma: 'h',
version: '16.8',
},
},

rules: {
'no-duplicate-imports': 'error',
'no-unused-vars': 'off',
'no-console': 'error',
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/ban-ts-comment': 'warn',
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-extraneous-class': 'error',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/no-this-alias': 'warn',

'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
},
],

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

'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/prefer-ts-expect-error': 'error',
'deprecation/deprecation': 'warn',
'import/export': 'error',

'import/extensions': [
'error',
'never',
{
json: 'always',
},
],

'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-absolute-path': 'error',
'import/no-commonjs': 'error',
'import/no-cycle': 'error',
'import/no-default-export': 'error',
'import/prefer-default-export': 'off',
'import/no-deprecated': 'error',

'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'__stories__/**/*',
'__tests-pacts__/**/*',
'__tests__/**/*',
'scripts/**/*',
'jest.setup.ts',
'webpack.config.js',
],

optionalDependencies: false,
},
],

'import/no-internal-modules': [
'error',
{
allow: ['msw/node'],
},
],

'import/no-mutable-exports': 'error',
'import/no-self-import': 'error',
'import/no-unassigned-import': 'error',

'import/no-useless-path-segments': [
'error',
{
noUselessIndex: true,
},
],

'import/order': [
'error',
{
alphabetize: {
order: 'asc',
},

groups: [
['builtin', 'external', 'internal'],
['parent', 'sibling', 'index', 'unknown'],
],

'newlines-between': 'always',
},
],

'react/jsx-boolean-value': 'error',
'react/jsx-curly-brace-presence': 'error',
'react/jsx-fragments': ['error', 'syntax'],
'react/prop-types': 'off',
},
},
]
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20241018.0",
"@eslint/compat": "^1.2.2",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.14.0",
"@iarna/toml": "^2.2.5",
"@jest/globals": "^29.7.0",
"@sentry/types": "^8.36.0",
Expand All @@ -47,11 +50,12 @@
"@typescript-eslint/parser": "^8.11.0",
"cross-env": "^7.0.3",
"depcheck": "^1.4.7",
"eslint": "^8.57.0",
"eslint": "^9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-deprecation": "^3.0.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-react": "^7.37.2",
"globals": "^15.12.0",
"jest": "^29.7.0",
"msw": "^2.4.3",
"npm-run-all": "^4.1.5",
Expand All @@ -65,6 +69,6 @@
},
"packageManager": "[email protected]",
"engines": {
"node": "^18.0.0"
"node": "^20.0.0"
}
}
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { robotsTxt } from './robots'
import { sentryHelloWorld } from './sentry'
import { SentryFactory, CFEnvironment } from './utils'

// eslint-disable-next-line import/no-default-export
export default {
async fetch(
request: Request,
Expand Down
Loading

0 comments on commit 49ab370

Please sign in to comment.