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

feat(eslint-plugin): support Eslint 9 and 8 simultaneously #7072

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
33904d7
feat: let eslint-plugin-qwink support Eslint 9 and 8 simultaneously
Nov 19, 2024
93f850e
feat: let eslint-plugin-qwink support Eslint 9 and 8 simultaneously
Nov 19, 2024
83909c4
Merge branch 'main' into 6048_eslint-flag
JerryWu1234 Nov 19, 2024
6953229
Merge branch 'main' into 6048_eslint-flag
JerryWu1234 Nov 22, 2024
efb017d
support 8 and 9
Nov 22, 2024
f2bdd0d
Merge branch '6048_eslint-flag' of https://github.com/JerryWu1234/qwi…
Nov 22, 2024
5c0723e
upgrade
Nov 22, 2024
0738804
upgrade
Nov 22, 2024
5ed62c5
upgrade
Nov 22, 2024
35ccf83
upgrade
Nov 22, 2024
df6f8f9
Merge branch '6048_eslint-flag' of https://github.com/JerryWu1234/qwi…
Nov 22, 2024
fc3aa53
Update qwik-binding-map.ts
JerryWu1234 Nov 22, 2024
f6d7862
upgrade
Nov 22, 2024
af55f94
upgrade
Nov 22, 2024
64b5c11
upgrade
Nov 22, 2024
cce51f0
upgrade
Nov 22, 2024
20a6fd4
upgrade
Nov 22, 2024
0bda546
upgrade
Nov 22, 2024
02cba46
fix
Nov 22, 2024
5701e52
Merge branch 'main' into 6048_eslint-flag
JerryWu1234 Nov 27, 2024
0f75492
Merge branch 'main' into 6048_eslint-flag
JerryWu1234 Nov 28, 2024
2458862
fix
Nov 28, 2024
b82a195
Merge branch '6048_eslint-flag' of https://github.com/JerryWu1234/qwi…
Nov 28, 2024
278a5df
Merge branch 'main' into 6048_eslint-flag
JerryWu1234 Nov 29, 2024
d378168
Merge branch 'main' into 6048_eslint-flag
JerryWu1234 Dec 6, 2024
0dab706
Merge branch 'main' into 6048_eslint-flag
JerryWu1234 Dec 10, 2024
fc93083
fix
JerryWu1234 Dec 11, 2024
07427ad
Merge branch 'main' into 6048_eslint-flag
JerryWu1234 Dec 11, 2024
13efa82
fix
JerryWu1234 Dec 11, 2024
939f856
Merge branch '6048_eslint-flag' of https://github.com/JerryWu1234/qwi…
JerryWu1234 Dec 11, 2024
13421f3
fix
JerryWu1234 Dec 12, 2024
88efe1b
Merge branch 'main' into 6048_eslint-flag
JerryWu1234 Dec 13, 2024
3a5aae2
Merge branch 'main' into 6048_eslint-flag
JerryWu1234 Dec 27, 2024
1276d1e
Merge branch 'main' into 6048_eslint-flag
JerryWu1234 Dec 31, 2024
aa1d5fb
fix
Dec 31, 2024
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
5 changes: 5 additions & 0 deletions .changeset/breezy-toes-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-qwik': major
---

let eslint-plugin-qwik support Eslint 9 and 8 simultaneously
2 changes: 1 addition & 1 deletion e2e/qwik-cli-e2e/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function replacePackagesWithLocalOnes(tmpDir: string) {
for (const { name, absolutePath } of tarballConfig) {
patchPackageJsonForPlugin(tmpDir, name, absolutePath);
}
execSync('npm i', {
execSync('pnpm i', {
JerryWu1234 marked this conversation as resolved.
Show resolved Hide resolved
cwd: tmpDir,
// only output errors
stdio: ['ignore', 'ignore', 'inherit'],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,10 @@
"start": "concurrently \"npm:build.watch\" \"npm:tsc.watch\" -n build,tsc -c green,cyan",
"test": "pnpm build.full && pnpm test.unit && pnpm test.e2e",
"test.e2e": "pnpm test.e2e.chromium && pnpm test.e2e.webkit",
"test.e2e.cli": "pnpm --filter qwik-cli-e2e e2e",
"test.e2e.chromium": "playwright test starters --browser=chromium --config starters/playwright.config.ts",
"test.e2e.chromium.debug": "PWDEBUG=1 playwright test starters --browser=chromium --config starters/playwright.config.ts",
"test.e2e.city": "playwright test starters/e2e/qwikcity --browser=chromium --config starters/playwright.config.ts",
"test.e2e.cli": "pnpm --filter qwik-cli-e2e e2e",
"test.e2e.firefox": "playwright test starters --browser=firefox --config starters/playwright.config.ts",
"test.e2e.webkit": "playwright test starters --browser=webkit --config starters/playwright.config.ts",
"test.rust": "make test",
Expand Down
90 changes: 62 additions & 28 deletions packages/eslint-plugin-qwik/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import { preferClasslist } from './src/preferClasslist';
import { unusedServer } from './src/unusedServer';
import { useMethodUsage } from './src/useMethodUsage';
import { validLexicalScope } from './src/validLexicalScope';
import pkg from './package.json';

export const rules = {
const rules = {
'use-method-usage': useMethodUsage,
'valid-lexical-scope': validLexicalScope,
'loader-location': loaderLocation,
Expand All @@ -24,37 +25,70 @@ export const rules = {
'no-use-visible-task': noUseVisibleTask,
};

export const configs = {
const recommendedRules = {
'qwik/use-method-usage': 'error',
'qwik/valid-lexical-scope': 'error',
'qwik/no-react-props': 'error',
'qwik/prefer-classlist': 'warn',
'qwik/jsx-no-script-url': 'warn',
'qwik/loader-location': 'warn',
'qwik/jsx-key': 'warn',
'qwik/unused-server': 'error',
'qwik/jsx-img': 'warn',
'qwik/jsx-a': 'warn',
'qwik/no-use-visible-task': 'warn',
};
const strictRules = {
'qwik/valid-lexical-scope': 'error',
'qwik/use-method-usage': 'error',
'qwik/loader-location': 'error',
'qwik/no-react-props': 'error',
'qwik/prefer-classlist': 'error',
'qwik/jsx-no-script-url': 'error',
'qwik/jsx-key': 'error',
'qwik/unused-server': 'error',
'qwik/jsx-img': 'error',
'qwik/jsx-a': 'error',
'qwik/no-use-visible-task': 'warn',
};

const configs = {
recommended: {
plugins: ['qwik'],
rules: {
'qwik/use-method-usage': 'error',
'qwik/valid-lexical-scope': 'error',
'qwik/no-react-props': 'error',
'qwik/prefer-classlist': 'warn',
'qwik/jsx-no-script-url': 'warn',
'qwik/loader-location': 'warn',
'qwik/jsx-key': 'warn',
'qwik/unused-server': 'error',
'qwik/jsx-img': 'warn',
'qwik/jsx-a': 'warn',
'qwik/no-use-visible-task': 'warn',
},
rules: recommendedRules,
},
strict: {
plugins: ['qwik'],
rules: {
'qwik/valid-lexical-scope': 'error',
'qwik/use-method-usage': 'error',
'qwik/loader-location': 'error',
'qwik/no-react-props': 'error',
'qwik/prefer-classlist': 'error',
'qwik/jsx-no-script-url': 'error',
'qwik/jsx-key': 'error',
'qwik/unused-server': 'error',
'qwik/jsx-img': 'error',
'qwik/jsx-a': 'error',
'qwik/no-use-visible-task': 'warn',
},
rules: strictRules,
},
};

const qwikEslintPlugin = {
configs: {},
meta: {
name: pkg.name,
version: pkg.version,
},
rules,
};

Object.assign(qwikEslintPlugin.configs, {
recommended: [
{
plugins: {
qwik: qwikEslintPlugin,
},
rules: recommendedRules,
},
],
strict: [
{
plugins: {
qwik: qwikEslintPlugin,
},
rules: strictRules,
},
],
});

export { configs, qwikEslintPlugin as default, rules };
10 changes: 5 additions & 5 deletions packages/eslint-plugin-qwik/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
"author": "Builder Team",
"bugs": "https://github.com/QwikDev/qwik/issues",
"dependencies": {
"jsx-ast-utils": "^3.3.5",
"@typescript-eslint/utils": "^8.12.2"
"@typescript-eslint/utils": "^8.12.2",
"jsx-ast-utils": "^3.3.5"
},
"devDependencies": {
"@builder.io/qwik": "workspace:^",
"@builder.io/qwik-city": "workspace:^",
"@types/eslint": "8.56.10",
"@types/estree": "1.0.5",
"@typescript-eslint/rule-tester": "7.8.0",
"@typescript-eslint/rule-tester": "8.14.0",
"redent": "4.0.0"
},
"engines": {
Expand All @@ -32,7 +31,8 @@
"license": "MIT",
"main": "dist/index.js",
"peerDependencies": {
"eslint": "^8.57.0"
"eslint": "9.15.0",
"@types/eslint": "9.6.1"
JerryWu1234 marked this conversation as resolved.
Show resolved Hide resolved
},
"repository": {
"type": "git",
Expand Down
32 changes: 16 additions & 16 deletions packages/eslint-plugin-qwik/qwik.unit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as vitest from 'vitest';
// @ts-ignore
import { RuleTester } from '@typescript-eslint/rule-tester';

import { RuleTester, type RuleTesterConfig } from '@typescript-eslint/rule-tester';
import { fileURLToPath } from 'node:url';
import { rules } from './index';
import { readdir, readFile, stat } from 'node:fs/promises';
Expand All @@ -14,22 +12,24 @@ RuleTester.itOnly = vitest.it.only;
RuleTester.describe = vitest.describe;

const testConfig = {
parser: '@typescript-eslint/parser',
env: {
es6: true,
},
parserOptions: {
tsconfigRootDir: fileURLToPath(new URL('.', import.meta.url)),
project: ['./tests/tsconfig.json'],
ecmaFeatures: {
jsx: true,
languageOptions: {
parserOptions: {
projectService: {
allowDefaultProject: ['*.ts*'],
},
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},

ecmaVersion: 2024,
project: ['./tests/tsconfig.json'],
tsconfigRootDir: fileURLToPath(new URL('.', import.meta.url)),
},
ecmaVersion: 2020,
sourceType: 'module',
},
};
} as RuleTesterConfig;

const ruleTester = new RuleTester(testConfig as any);
const ruleTester = new RuleTester(testConfig);
interface TestCase {
name: string;
filename: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const HelloWorld = component$(() => {
class Stuff {}
const stuff = new Stuff();
useTask$(() => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
JerryWu1234 marked this conversation as resolved.
Show resolved Hide resolved
console.log(stuff);
});
return <div></div>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Expect error: { "messageId": "invalidJsxDollar" }
import { component$, useTask$ } from '@builder.io/qwik';
export const HelloWorld = component$(() => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
const click = () => console.log();
return <button onClick$={click}></button>;
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export const HelloWorld = component$(() => {
return 'string';
} else {
return () => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log();
};
}
}
const a = getValue();
useTask$(() => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log(a);
});
return <div></div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { component$, useTask$ } from '@builder.io/qwik';
export const HelloWorld = component$(() => {
const a = Symbol();
useTask$(() => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log(a);
});
return <div></div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const HelloWorld = component$(() => {
const divRef = useSignal<{ offsetLeft: number }>();

const handleMouseDown = $((e: MouseEvent) => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log('working');
startX = e.pageX - divRef.value!.offsetLeft;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const HelloWorld = component$(() => {
};
const useMethod = getMethod();
useTask$(() => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log(useMethod);
});
return <div></div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { component$, useTask$ } from '@builder.io/qwik';

export const HelloWorld = component$(() => {
function useMethod() {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log('stuff');
}
useTask$(() => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log(useMethod);
});
return <div></div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default component$(() => {
state.foo = <div>Foo</div>;

useTask$(() => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log(state.foo);
});
return <></>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const HelloWorld = component$(() => {
return (
<div
onClick$={() => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log(a);
}}
></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function getFn(): NoSerialize<() => void> {
export const HelloWorld = component$(() => {
const state: Value = { value: 12, fn: getFn() };
useTask$(() => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log(state.value);
});
return <div></div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const HelloWorld = component$(() => {
},
};
useTask$(() => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log(useMethod, obj);
});
return <div></div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const HelloWorld = component$(() => {
}
const a = getValue();
useTask$(() => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log(a);
});
return <div></div>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const HelloWorld = component$(() => {
};
const useMethod = getMethod();
useTask$(() => {
// eslint-disable-next-line no-console
/* eslint no-console: [, { allow: ["log"] }] */
console.log(useMethod);
});
return <div></div>;
Expand Down
4 changes: 2 additions & 2 deletions packages/qwik-labs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
],
"main": "./lib/index.qwik.mjs",
"peerDependencies": {
"zod": "3.22.4",
"vite": "^5"
"vite": "^5",
"zod": "3.22.4"
},
"private": true,
"qwik": "./lib/index.qwik.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"devDependencies": {
"@builder.io/qwik": "workspace:^",
"@builder.io/qwik-dom": "workspace:^",
"ignore": "5.3.1",
"image-size": "1.1.1",
"kleur": "4.1.5",
"ignore": "5.3.1",
"ts-morph": "23.0.0"
},
"engines": {
Expand Down
Loading
Loading