Skip to content

Commit

Permalink
Merge pull request #1808 from serlo/chore/eslint9
Browse files Browse the repository at this point in the history
chore: eslint9
  • Loading branch information
hugotiburtino authored Nov 14, 2024
2 parents 92b293d + 18769c3 commit 473e8cf
Show file tree
Hide file tree
Showing 48 changed files with 404 additions and 252 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

125 changes: 0 additions & 125 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.
1 change: 0 additions & 1 deletion esbuild-transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ async function processAsync(src, filename) {
}
}

// eslint-disable-next-line import/no-default-export
export default { processAsync }
177 changes: 177 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin'
import _import from 'eslint-plugin-import'
import react from 'eslint-plugin-react'
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 [
{
ignores: [
'packages/server/src/types.ts',
'packages/types/src/index.ts',
'**/transform-graphql-jest-28-shim.cjs',
],
},
...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:react/recommended',
'prettier',
),
{
plugins: {
'@typescript-eslint': typescriptEslint,
import: fixupPluginRules(_import),
react,
},

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/ban-ts-comment': 'warn',
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
'@typescript-eslint/explicit-module-boundary-types': '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',
'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/no-deprecated': 'error',

'import/no-internal-modules': [
'error',
{
allow: [
'@pact-foundation/pact/src/dsl/matchers',
'msw/node',
'msw/lib/**',
'mysql2/promise',
'io-ts/lib/*',
'io-ts-types/lib/*',
'fp-ts/lib/*',
'ts-jest/utils',
'@apollo/server/plugin/disabled',
'@apollo/server/express4',
],
},
],

'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/prop-types': 'off',
},
},
{
files: [
'__fixtures__/**/*',
'__tests-pacts__/**/*',
'__tests__/**/*',
'**/jest.setup.ts',
'**/jest.setup-pacts.ts',
],

rules: {
'@typescript-eslint/no-non-null-assertion': 'off',
'import/no-extraneous-dependencies': 'off',
},
},
]
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line import/no-default-export
export default {
modulePaths: ['<rootDir>/packages'],
moduleNameMapper: {
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
"graphql": "^16.9.0"
},
"devDependencies": {
"@eslint/compat": "^1.2.2",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.14.0",
"@luckycatfactory/esbuild-graphql-loader": "^3.8.1",
"@tsconfig/node20": "^20.1.4",
"@types/jest": "^29.5.12",
Expand All @@ -98,10 +101,11 @@
"default-import": "^2.0.1",
"depcheck": "^1.4.7",
"esbuild": "^0.24.0",
"eslint": "^8.57.0",
"eslint": "^9.14.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-react": "^7.35.2",
"globals": "^15.12.0",
"graphql-tag": "^2.12.6",
"jest": "^29.7.0",
"jest-transform-graphql": "^2.1.0",
Expand Down
1 change: 0 additions & 1 deletion packages/server/src/schema/authorization/roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export function getRolesWithInheritance(initialRoles: Role[] = []): Role[] {
const allRoles: Role[] = []
const queue = [...initialRoles]

// eslint-disable-next-line no-constant-condition
while (true) {
const role = queue.pop()
if (!role) return allRoles
Expand Down
1 change: 0 additions & 1 deletion packages/server/src/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ declare module '*.graphql' {
import { DocumentNode } from 'graphql'

const node: DocumentNode
// eslint-disable-next-line import/no-default-export
export default node
}
Loading

0 comments on commit 473e8cf

Please sign in to comment.