Skip to content

Migrate to ESLint 9 with flat config and fix monorepo linting #7418

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 10 additions & 6 deletions .changeset/changelog-github-custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ const changelogFunctions: ChangelogFunctions = {
'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]'
);
}
if (dependenciesUpdated.length === 0) return '';
if (dependenciesUpdated.length === 0) {
return '';
}

const changesetLink = `- Updated dependencies [${(
await Promise.all(
changesets.map(async (cs) => {
if (cs.commit) {
let { links } = await getInfo({
const { links } = await getInfo({
repo: options.repo,
commit: cs.commit,
});
Expand All @@ -45,12 +47,14 @@ const changelogFunctions: ChangelogFunctions = {

let prFromSummary: number | undefined;
let commitFromSummary: string | undefined;
let usersFromSummary: string[] = [];
const usersFromSummary: string[] = [];

const replacedChangelog = changeset.summary
.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/im, (_, pr) => {
let num = Number(pr);
if (!isNaN(num)) prFromSummary = num;
const num = Number(pr);
if (!isNaN(num)) {
prFromSummary = num;
}
return '';
})
.replace(/^\s*commit:\s*([^\s]+)/im, (_, commit) => {
Expand Down Expand Up @@ -91,7 +95,7 @@ const changelogFunctions: ChangelogFunctions = {
}
const commitToFetchFrom = commitFromSummary || changeset.commit;
if (commitToFetchFrom) {
let { links } = await getInfo({
const { links } = await getInfo({
repo: options.repo,
commit: commitToFetchFrom,
});
Expand Down
7 changes: 7 additions & 0 deletions .changeset/giant-carpets-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'create-qwik': patch
'@builder.io/qwik-city': patch
'@builder.io/qwik': patch
---

Fix linting errors which were previously being ignored across the monorepo.
5 changes: 5 additions & 0 deletions .changeset/grumpy-ladybugs-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-qwik': patch
---

Improve types and README documentation with clear configuration examples for ESLint 9+ (flat config). Added `globalIgnores` for more clarity and `tseslint.config` for better type inference inside the `parserOptions` option.
33 changes: 0 additions & 33 deletions .eslintignore

This file was deleted.

45 changes: 0 additions & 45 deletions .eslintrc.cjs

This file was deleted.

112 changes: 112 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import globals from 'globals';
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import noOnlyTests from 'eslint-plugin-no-only-tests';
import { globalIgnores } from 'eslint/config';
// import { qwikEslint9Plugin } from 'eslint-plugin-qwik';

const ignores = [
'**/.history',
'**/.vscode',
'**/dist',
'**/dist-dev',
'**/lib',
'**/node_modules',
'**/tsc-out',
'**/external',
'**/*.',
'**/*.log',
'**/etc',
'**/target',
'**/temp',
'**/tsdoc-metadata.json',
'**/.DS_Store',
'**/*.mp4',
'scripts',
'**/server/**/*.js',
'**/*.tsbuildinfo',
'packages/docs/api',
'packages/docs/public/repl/repl-sw.js*',
'packages/docs/src/routes/examples/apps',
'packages/docs/src/routes/playground/app',
'packages/docs/src/routes/tutorial',
'packages/qwik-labs/lib',
'packages/qwik-labs/lib-types',
'packages/qwik-labs/vite',
'packages/insights/drizzle.config.ts',
'packages/insights/panda.config.ts',
'starters/apps/base',
'starters/apps/library',
'starters/templates',
'**/vite.config.ts',
// packages with eslint.config.mjs
'packages/qwik-labs',
'packages/insights',
'starters',
// eslint.config.*
'**/eslint.config.mjs',
'**/eslint.config.js',
];

export default tseslint.config(
globalIgnores(ignores),
js.configs.recommended,
tseslint.configs.recommended,
// qwikEslint9Plugin.configs.recommended,
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
...globals.es2021,
},
parserOptions: {
// Needed when using the qwik plugin
// projectService: true,
// tsconfigRootDir: import.meta.dirname,
},
},
},
{
plugins: {
'no-only-tests': noOnlyTests,
},
rules: {
'no-only-tests/no-only-tests': 'error',
},
name: 'no-only-tests',
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'prefer-spread': 'off',
'no-case-declarations': 'off',
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-only-tests/no-only-tests': 'error',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-var-requires': 'off',
curly: 'error',
'no-new-func': 'error',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
},
},
{
files: ['packages/docs/**/*.{ts,tsx}'],
rules: {
'no-console': 'off',
},
}
);
25 changes: 7 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
"config": {
"syncpack": {
"versionGroups": [
{
"label": "Allow ESLint 9 types in eslint-plugin-qwik",
"dependencies": [
"@types/eslint"
],
"packages": [
"eslint-plugin-qwik"
],
"policy": "matches@9.6.1"
},
{
"label": "Be lenient in vite versions for prod. v4 is broken, v5 is good",
"dependencyTypes": [
Expand Down Expand Up @@ -115,7 +105,7 @@
"@changesets/get-github-info": "0.6.0",
"@changesets/types": "6.0.0",
"@clack/prompts": "0.7.0",
"@eslint/eslintrc": "3.1.0",
"@eslint/js": "9.22.0",
"@mdx-js/mdx": "3.0.1",
"@microsoft/api-documenter": "7.24.2",
"@microsoft/api-extractor": "7.43.1",
Expand All @@ -127,7 +117,6 @@
"@types/brotli": "1.3.4",
"@types/bun": "1.1.6",
"@types/cross-spawn": "6.0.6",
"@types/eslint": "8.56.10",
"@types/express": "4.17.21",
"@types/node": "20.14.11",
"@types/path-browserify": "1.0.2",
Expand All @@ -136,8 +125,6 @@
"@types/semver": "7.5.8",
"@types/tmp": "0.2.6",
"@types/which-pm-runs": "1.0.2",
"@typescript-eslint/eslint-plugin": "7.16.1",
"@typescript-eslint/parser": "7.16.1",
"all-contributors-cli": "6.26.1",
"brotli": "1.3.3",
"concurrently": "8.2.2",
Expand All @@ -146,11 +133,12 @@
"csstype": "3.1.3",
"dotenv": "16.4.5",
"esbuild": "0.20.2",
"eslint": "8.57.0",
"eslint-plugin-no-only-tests": "3.1.0",
"eslint": "9.22.0",
"eslint-plugin-no-only-tests": "3.3.0",
"eslint-plugin-qwik": "workspace:^",
"execa": "8.0.1",
"express": "4.20.0",
"globals": "16.0.0",
"install": "0.13.0",
"memfs": "4.14.0",
"monaco-editor": "0.45.0",
Expand All @@ -172,6 +160,7 @@
"tree-kill": "1.2.2",
"tsx": "4.19.1",
"typescript": "5.4.5",
"typescript-eslint": "8.26.1",
"undici": "*",
"vfile": "6.0.2",
"vite": "5.3.5",
Expand Down Expand Up @@ -237,8 +226,8 @@
"link.dist.npm": "cd packages/qwik && npm link && cd ../qwik-city && npm link && cd ../eslint-plugin-qwik && npm link && cd ../qwik-react && npm link",
"link.dist.yarn": "cd packages/qwik && yarn link && cd ../qwik-city && yarn link && cd ../eslint-plugin-qwik && yarn link && cd ../qwik-react && yarn link",
"lint": "pnpm lint.eslint && pnpm lint.prettier && pnpm lint.rust",
"lint.eslint": "eslint --cache \"**/*.ts*\"",
"lint.fix": "eslint --fix \"**/*.ts*\" && pnpm prettier.fix",
"lint.eslint": "eslint --cache \"**/*.ts*\" && pnpm -r --parallel lint",
"lint.fix": "eslint --fix \"**/*.ts*\" && pnpm -r --parallel lint.fix && pnpm prettier.fix",
"lint.prettier": "prettier --cache --check .",
"lint.rust": "make lint",
"lint.syncpack": "syncpack list-mismatches",
Expand Down
1 change: 0 additions & 1 deletion packages/create-qwik/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { runCreateCli } from './src/run-create-cli';
import { runCreateInteractiveCli } from './src/run-create-interactive-cli';
import { panic, printHeader } from '../qwik/src/cli/utils/utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/create-qwik/src/run-create-interactive-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { join, relative } from 'node:path';
import type { CreateAppResult } from '../../qwik/src/cli/types';
import { clearDir } from './helpers/clearDir';
import { createApp } from './create-app';
/* eslint-disable no-console */

import fs from 'node:fs';
import { getRandomJoke } from './helpers/jokes';
import { installDepsCli } from './helpers/installDepsCli';
Expand Down
1 change: 0 additions & 1 deletion packages/docs/codesandbox.sync.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { readdirSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';

Expand Down
1 change: 0 additions & 1 deletion packages/docs/contributors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { fetch } from 'undici';
import fs from 'node:fs';
import path from 'node:path';
Expand Down
10 changes: 5 additions & 5 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"@mui/system": "5.16.4",
"@mui/x-data-grid": "6.20.4",
"@qwik-ui/headless": "0.5.0",
"@shikijs/colorized-brackets": "3.1.0",
"@shikijs/rehype": "3.1.0",
"@shikijs/transformers": "3.1.0",
"@shikijs/types": "3.1.0",
"@supabase/supabase-js": "2.44.4",
"@types/leaflet": "1.9.12",
"@types/prismjs": "1.26.4",
Expand All @@ -43,6 +47,7 @@
"qwik-image": "0.0.10",
"react": "18.3.1",
"react-dom": "18.3.1",
"shiki": "3.1.0",
"snarkdown": "2.0.0",
"tailwindcss": "3.4.6",
"terser": "5.31.3",
Expand All @@ -52,11 +57,6 @@
"valibot": "0.33.3",
"vite": "5.3.5",
"vite-plugin-inspect": "0.8.5",
"shiki": "3.1.0",
"@shikijs/rehype": "3.1.0",
"@shikijs/transformers": "3.1.0",
"@shikijs/colorized-brackets": "3.1.0",
"@shikijs/types": "3.1.0",
"wrangler": "3.65.1"
},
"engines": {
Expand Down
1 change: 0 additions & 1 deletion packages/docs/src/components/router-head/router-head.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { component$ } from '@builder.io/qwik';
import { useDocumentHead, useLocation } from '@builder.io/qwik-city';
import { Social } from './social';
Expand Down
1 change: 0 additions & 1 deletion packages/docs/src/repl/repl-version.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { QWIK_PKG_NAME, bundled } from './bundled';

const bundledVersion = bundled[QWIK_PKG_NAME].version;
Expand Down
1 change: 0 additions & 1 deletion packages/docs/src/repl/repl.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import {
component$,
noSerialize,
Expand Down
Loading