Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint 9 #717

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 170 additions & 0 deletions .eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
import path from 'node:path';
import js from '@eslint/js';

import { createRequire } from 'node:module';

import tsParser from '@typescript-eslint/parser';

const require = createRequire(import.meta.url);

const firstPartEslintPlugin = require('./eslint/index.cjs');

export default [
js.configs.recommended,
{
files: ['**/*.ts'],
languageOptions: {
parser: tsParser,
parserOptions: {
project: './tsconfig.json',
},
},
// extends: [
// 'plugin:@typescript-eslint/recommended',
// 'plugin:@typescript-eslint/recommended-requiring-type-checking',
// 'plugin:@typescript-eslint/strict',
// ],
plugins: {
'@typescript-eslint': {},
tsdoc: {},
'first-part': firstPartEslintPlugin,
import: {},
unicorn: {},
'unused-imports': {},
'simple-import-sort': {},
},
rules: {
'unicorn/import-style': 'off',
'first-part/no-relative-parent-import': 'error',
'unused-imports/no-unused-imports': 'error',
curly: ['error'],
'tsdoc/syntax': 'error',
'no-new-object': 'error',
'no-console': 'error',
'no-new-wrappers': 'error',
'unicorn/no-null': 'off',
'unicorn/no-unsafe-regex': 'error',
'unicorn/numeric-separators-style': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/better-regex': 'error',
'unicorn/prefer-ternary': 'off',
'unicorn/no-instanceof-array': 'error',
'unicorn/no-new-array': 'error',
'unicorn/no-new-buffer': 'error',
'unicorn/no-unnecessary-await': 'error',
'unicorn/throw-new-error': 'off',
'unicorn/no-useless-promise-resolve-reject': 'error',
'unicorn/prefer-string-starts-ends-with': 'error',
'unicorn/prefer-string-slice': 'error',
'unicorn/prefer-regexp-test': 'error',
'unicorn/prefer-module': 'error',
'unicorn/prefer-modern-math-apis': 'error',
'unicorn/prefer-includes': 'error',
quotes: 'off',
'@typescript-eslint/quotes': 'off',
'n/no-missing-import': 'off',
'linebreak-style': ['error', 'unix'],
indent: 'off',
'array-element-newline': ['error', 'consistent'],
'array-bracket-newline': ['error', 'consistent'],
'promise/catch-or-return': ['error', { allowFinally: true }],
'@typescript-eslint/restrict-plus-operands': ['error', { skipCompoundAssignments: false }],
'@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
'@typescript-eslint/object-curly-spacing': ['error', 'always'],
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
'@typescript-eslint/no-unsafe-enum-comparison': 'off',
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
fixStyle: 'separate-type-imports',
},
],
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/member-delimiter-style': [
'error',
{
multiline: {
delimiter: 'semi',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
multilineDetection: 'brackets',
},
],
'@typescript-eslint/space-before-function-paren': 'off',
'@typescript-eslint/semi': ['error', 'always'],
semi: ['error', 'always'],
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'ignore',
},
],
'import/first': 'error',
'import/no-duplicates': 'error',
'import/newline-after-import': 'error',
'import/no-named-as-default': 'off',
'simple-import-sort/imports': [
'error',
{
groups: [
// Side effect imports.
[String.raw`^\u0000`],
// Node.js builtins prefixed with `node:`.
['^node:'],
// Absolute imports and other imports such as Vue-style `@/foo`.
// Anything not matched in another group.
['^'],
// Packages.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
['^@app/.*'],
// Relative imports.
// Anything that starts with a dot.
[String.raw`^\.`],
],
},
],
'simple-import-sort/exports': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ args: 'after-used', varsIgnorePattern: '_', destructuredArrayIgnorePattern: '^_' },
],
'@typescript-eslint/strict-boolean-expressions': 'off',
},
},
{
files: ['tests/**/*', '*.test.ts'],
rules: {
'@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }],
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
},
{
files: ['**/*.cjs'],
rules: {
'@typescript-eslint/consistent-type-imports': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
},
];
7 changes: 0 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ on:
merge_group:

jobs:
license:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-js-env
- run: pnpm run license-check

lint:
runs-on: ubuntu-latest
steps:
Expand Down
7 changes: 7 additions & 0 deletions eslint/index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const noRelativeParentImport = require('./no-relative-parent-import.cjs');

module.exports = {
rules: {
'no-relative-parent-import': noRelativeParentImport,
},
};

Check warning on line 7 in eslint/index.cjs

View check run for this annotation

Codecov / codecov/patch

eslint/index.cjs#L2-L7

Added lines #L2 - L7 were not covered by tests
1 change: 0 additions & 1 deletion lint-staged.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ export default {
'eslint --quiet --fix',
'prettier -w',
],
'pnpm-lock.yaml': () => 'pnpm run license-check',
};
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
"scripts": {
"format": "prettier --list-different -w ./",
"tsc": "tsc",
"lint": "eslint --ext ts,cjs,js ./",
"lint": "eslint -c .eslint.config.js ./",
"start": "nodemon ./bin/main.ts",
"test": "vitest --run",
"vitest": "vitest",
"file": "node --no-warnings --import tsx/esm",
"license-check": "license-checker --excludePrivatePackages --production --summary --onlyAllow=\"0BSD;Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC;MIT;Python-2.0;BlueOak-1.0.0\"",
"e": "node --no-warnings -r dotenv/config --import tsx/esm",
"lint-staged": "lint-staged",
"prepare": "husky"
Expand Down Expand Up @@ -69,20 +68,21 @@
"typeorm": "^0.3.20"
},
"devDependencies": {
"@eslint/js": "^9.10.0",
"@shopify/prettier-plugin-liquid": "^1.5.0",
"@types/ioredis-mock": "^8.2.5",
"@types/js-yaml": "^4.0.9",
"@types/lodash-es": "^4.17.12",
"@types/luxon": "^3.4.2",
"@types/mime-types": "^2.1.4",
"@types/node": "^20.16.3",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@typescript-eslint/utils": "^7.18.0",
"@typescript-eslint/eslint-plugin": "^8.5.0",
"@typescript-eslint/parser": "^8.5.0",
"@typescript-eslint/utils": "^8.5.0",
"@vitest/coverage-v8": "^2.0.5",
"@vitest/ui": "^2.0.5",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.30.0",
Expand All @@ -96,7 +96,6 @@
"graphql-tag": "^2.12.6",
"husky": "^9.1.5",
"ioredis-mock": "^8.9.0",
"license-checker": "^25.0.1",
"lint-staged": "^15.2.10",
"mercurius-integration-testing": "^8.2.0",
"nodemon": "^3.1.4",
Expand Down
Loading
Loading