Skip to content

Commit bc1ea13

Browse files
authored
Merge pull request #20 from shopwareLabs/feat/eslint-10
feat: eslint 10 upgrade
2 parents 0c7cc03 + 2c854d0 commit bc1ea13

30 files changed

+645
-467
lines changed

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ jobs:
1313
steps:
1414
- name: Checkout code
1515
uses: actions/checkout@v6
16-
16+
1717
- name: Setup pnpm
1818
uses: pnpm/action-setup@v4
1919

2020
- name: Setup Node.js
2121
uses: actions/setup-node@v6
2222
with:
2323
node-version: "24"
24-
cache: 'pnpm'
24+
cache: "pnpm"
2525
registry-url: "https://registry.npmjs.org"
2626

2727
- name: Update npm

.github/workflows/test.yml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,49 @@ on:
77
pull_request:
88

99
jobs:
10-
biome:
11-
name: Biome
10+
oxlint:
11+
name: oxlint
1212
runs-on: ubuntu-latest
1313
steps:
14-
- name: Checkout
15-
uses: actions/checkout@v6
14+
- name: Checkout
15+
uses: actions/checkout@v6
16+
17+
- name: Setup pnpm
18+
uses: pnpm/action-setup@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v6
22+
with:
23+
node-version: "24"
24+
cache: "pnpm"
1625

17-
- name: Setup Biome
18-
uses: biomejs/setup-biome@v2
19-
with:
20-
version: latest
26+
- name: Install dependencies
27+
run: pnpm install
28+
29+
- name: Run oxlint
30+
run: pnpm oxlint
31+
32+
oxfmt:
33+
name: oxfmt
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v6
38+
39+
- name: Setup pnpm
40+
uses: pnpm/action-setup@v4
41+
42+
- name: Setup Node.js
43+
uses: actions/setup-node@v6
44+
with:
45+
node-version: "24"
46+
cache: "pnpm"
47+
48+
- name: Install dependencies
49+
run: pnpm install
2150

22-
- name: Run Biome
23-
run: biome ci .
51+
- name: Run oxfmt
52+
run: pnpm oxfmt:check
2453

2554
test:
2655
name: Vitest
@@ -37,7 +66,7 @@ jobs:
3766
uses: actions/setup-node@v6
3867
with:
3968
node-version: "24"
40-
cache: 'pnpm'
69+
cache: "pnpm"
4170

4271
- name: Install dependencies
4372
run: pnpm install

.github/workflows/update-biome-schema.yml

Lines changed: 0 additions & 66 deletions
This file was deleted.

.oxfmtrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"useTabs": true,
4+
"singleQuote": false
5+
}

.oxlintrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"categories": {
4+
"correctness": "error"
5+
},
6+
"plugins": ["eslint", "typescript", "unicorn", "oxc", "import"]
7+
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ This repository is a monorepo for ESLint and Stylelint rules for Shopware.
1010

1111
## License
1212

13-
[MIT](./LICENSE)
13+
[MIT](./LICENSE)

biome.json

Lines changed: 0 additions & 46 deletions
This file was deleted.

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{
2-
"packageManager": "[email protected]",
2+
"scripts": {
3+
"oxlint": "oxlint .",
4+
"oxlint:fix": "oxlint --fix .",
5+
"oxfmt": "oxfmt .",
6+
"oxfmt:check": "oxfmt --check"
7+
},
38
"devDependencies": {
4-
"@biomejs/biome": "~2.3.11"
9+
"oxfmt": "^0.33.0",
10+
"oxlint": "^1.48.0"
511
},
6-
"scripts": {
7-
"biome": "biome",
8-
"biome:fix": "biome format --write . && biome lint --fix --unsafe . && biome check --fix --unsafe .",
9-
"biome:check": "biome ci ."
10-
}
12+
"packageManager": "[email protected]"
1113
}

packages/admin-eslint-rules/6.7/require-explict-emits.js

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ export default {
4949
if (isComponentDefinition(objectNode)) {
5050
componentNode = objectNode;
5151
emitsNode = objectNode.properties.find(
52-
(property) =>
53-
property.key?.name === "emits" &&
54-
property.value.type === "ArrayExpression",
52+
(property) => property.key?.name === "emits" && property.value.type === "ArrayExpression",
5553
)?.value;
5654
}
5755
}
@@ -70,15 +68,10 @@ export default {
7068
function getEmitCallsFromTemplate(importNode) {
7169
if (importNode.name === "template") {
7270
const templateFileName = importNode.parent.parent.source.value;
73-
const directoryPath = dirname(context.getFilename());
74-
const templateSource = readFileSync(
75-
resolve(directoryPath, templateFileName),
76-
"utf8",
77-
);
78-
79-
const templateEventsNames = Array.from(
80-
templateSource.matchAll(EVENT_NAME_REGEXP),
81-
)
71+
const directoryPath = dirname(context.filename);
72+
const templateSource = readFileSync(resolve(directoryPath, templateFileName), "utf8");
73+
74+
const templateEventsNames = Array.from(templateSource.matchAll(EVENT_NAME_REGEXP))
8275
.map(([, capturedGroup]) => capturedGroup)
8376
.filter(Boolean);
8477

@@ -145,8 +138,7 @@ export default {
145138
}
146139

147140
function fixMissingEmitDefinitions(programNode) {
148-
const emitsDefinition =
149-
emitsNode?.elements.map((element) => element.value) ?? [];
141+
const emitsDefinition = emitsNode?.elements.map((element) => element.value) ?? [];
150142
const pendingEmitDefinitions = Array.from(emittedEvents).filter(
151143
(e) => e && !emitsDefinition.includes(e),
152144
);
@@ -170,10 +162,7 @@ export default {
170162
// emits with already some event in the component
171163
const lastElement = emitsNode.elements.at(-1);
172164
if (lastElement) {
173-
return fixer.insertTextAfter(
174-
lastElement,
175-
`, ${stringEmitEvents}`,
176-
);
165+
return fixer.insertTextAfter(lastElement, `, ${stringEmitEvents}`);
177166
}
178167

179168
// emits without any event in
@@ -201,15 +190,12 @@ export default {
201190
"provide",
202191
];
203192

204-
const nodeAfterWhichToInsert = componentNode.properties.findLast(
205-
(property) => fieldsBeforeEmits.includes(property.key.name),
193+
const nodeAfterWhichToInsert = componentNode.properties.findLast((property) =>
194+
fieldsBeforeEmits.includes(property.key.name),
206195
);
207196

208197
if (nodeAfterWhichToInsert) {
209-
return fixer.insertTextAfter(
210-
nodeAfterWhichToInsert,
211-
`,\n\nemits: [${stringEmitEvents}]`,
212-
);
198+
return fixer.insertTextAfter(nodeAfterWhichToInsert, `,\n\nemits: [${stringEmitEvents}]`);
213199
}
214200

215201
// in the case there is no fields that should be before emits, then we insert at the beginning of the component

0 commit comments

Comments
 (0)