Skip to content

Commit ac484d8

Browse files
authored
chore: Align lint configuration with JavaScript repo (#933)
1 parent 97f657c commit ac484d8

58 files changed

Lines changed: 509 additions & 1104 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/checks.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ jobs:
187187
- name: Install dependencies
188188
run: yarn --frozen-lockfile --ignore-engines
189189
if: steps.dependency-cache.outputs.cache-hit != 'true'
190+
- name: Download build artifacts
191+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
192+
with:
193+
name: dist-artifacts-${{ github.run_id }}
194+
path: packages
190195
- run: yarn lint
191196

192197
artifacts:

.oxlintrc.base.json

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["typescript", "import", "jsdoc", "vitest"],
4+
"rules": {
5+
"no-unused-vars": [
6+
"warn",
7+
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_", "caughtErrorsIgnorePattern": "^_" }
8+
],
9+
10+
// === Base rules from eslint-config-sdk/base.js ===
11+
"no-console": "error",
12+
"no-alert": "error",
13+
"no-param-reassign": "error",
14+
"prefer-template": "error",
15+
"no-bitwise": "error",
16+
"complexity": ["error", { "max": 33 }],
17+
"no-unused-expressions": ["error", { "allowShortCircuit": true }],
18+
"guard-for-in": "error",
19+
"array-callback-return": ["error", { "allowImplicit": true }],
20+
"quotes": ["error", "single", { "avoidEscape": true }],
21+
"no-return-await": "error",
22+
"max-lines": ["error", { "max": 300, "skipComments": true, "skipBlankLines": true }],
23+
24+
// === Import rules ===
25+
"import/namespace": "off",
26+
"import/no-unresolved": "off",
27+
28+
// === Rules turned off (not enforced in ESLint or causing false positives) ===
29+
"no-control-regex": "off",
30+
"jsdoc/check-tag-names": "off",
31+
"jsdoc/require-yields": "off",
32+
"no-useless-rename": "off",
33+
"no-constant-binary-expression": "off",
34+
"vitest/hoisted-apis-on-top": "off",
35+
"vitest/no-conditional-tests": "off",
36+
"no-unsafe-optional-chaining": "off",
37+
"no-eval": "off",
38+
"no-import-assign": "off",
39+
"typescript/no-duplicate-type-constituents": "off"
40+
},
41+
"overrides": [
42+
{
43+
"files": ["**/*.ts", "**/*.tsx", "**/*.d.ts"],
44+
"rules": {
45+
"typescript/ban-ts-comment": "error",
46+
"typescript/consistent-type-imports": "error",
47+
"typescript/no-unnecessary-type-assertion": "error",
48+
"typescript/prefer-for-of": "error",
49+
"typescript/no-floating-promises": ["error", { "ignoreVoid": true }],
50+
"typescript/no-dynamic-delete": "error",
51+
"typescript/no-unsafe-member-access": "error",
52+
"typescript/unbound-method": "error",
53+
"typescript/no-explicit-any": "error",
54+
"typescript/no-empty-function": "off",
55+
"typescript/prefer-optional-chain": ["error"],
56+
"typescript/no-redundant-type-constituents": "off",
57+
"typescript/restrict-template-expressions": "off",
58+
"typescript/await-thenable": "warn",
59+
"typescript/no-base-to-string": "off"
60+
}
61+
},
62+
{
63+
"files": ["**/*.js", "**/*.mjs", "**/*.cjs"],
64+
"rules": {
65+
"typescript/ban-ts-comment": "off",
66+
"typescript/consistent-type-imports": "off",
67+
"typescript/prefer-optional-chain": "off",
68+
"typescript/no-unnecessary-type-assertion": "off",
69+
"typescript/prefer-for-of": "off",
70+
"typescript/no-floating-promises": "off",
71+
"typescript/no-dynamic-delete": "off",
72+
"typescript/no-unsafe-member-access": "off",
73+
"typescript/unbound-method": "off",
74+
"typescript/no-explicit-any": "off"
75+
}
76+
},
77+
{
78+
"files": [
79+
"**/*.test.ts",
80+
"**/*.test.tsx",
81+
"**/*.test.js",
82+
"**/*.test.jsx",
83+
"**/test/**",
84+
"**/tests/**",
85+
"**/suites/**",
86+
"**/loader-suites/**"
87+
],
88+
"rules": {
89+
"typescript/explicit-function-return-type": "off",
90+
"no-unused-expressions": "off",
91+
"typescript/no-unused-expressions": "off",
92+
"typescript/no-unnecessary-type-assertion": "off",
93+
"typescript/no-unsafe-member-access": "off",
94+
"typescript/no-explicit-any": "off",
95+
"typescript/no-non-null-assertion": "off",
96+
"typescript/no-floating-promises": "off",
97+
"typescript/unbound-method": "off",
98+
"max-lines": "off",
99+
"complexity": "off",
100+
"typescript/prefer-optional-chain": "off",
101+
"typescript/no-misused-spread": "off",
102+
"typescript/require-array-sort-compare": "off",
103+
"typescript/no-base-to-string": "off",
104+
"typescript/await-thenable": "off"
105+
}
106+
},
107+
{
108+
"files": ["*.tsx"],
109+
"rules": {
110+
"jsdoc/require-jsdoc": "off"
111+
}
112+
},
113+
{
114+
"files": ["*.config.js", "*.config.mjs", "*.config.ts", "vite.config.ts", ".size-limit.js"],
115+
"rules": {
116+
"no-console": "off",
117+
"max-lines": "off"
118+
}
119+
},
120+
{
121+
"files": ["**/integrations/node-fetch/vendored/**/*.ts"],
122+
"rules": {
123+
"typescript/consistent-type-imports": "off",
124+
"typescript/no-unnecessary-type-assertion": "off",
125+
"typescript/no-unsafe-member-access": "off",
126+
"typescript/no-explicit-any": "off",
127+
"typescript/prefer-for-of": "off",
128+
"max-lines": "off",
129+
"complexity": "off",
130+
"no-param-reassign": "off"
131+
}
132+
},
133+
{
134+
"files": ["**/integrations/tracing/redis/vendored/**/*.ts"],
135+
"rules": {
136+
"typescript/no-explicit-any": "off",
137+
"typescript/no-unsafe-member-access": "off",
138+
"typescript/no-this-alias": "off",
139+
"max-lines": "off",
140+
"no-bitwise": "off"
141+
}
142+
},
143+
{
144+
"files": [
145+
"**/scenarios/**",
146+
"**/fixtures/**",
147+
"**/playground/**",
148+
"**/rollup-utils/**",
149+
"**/bundle-analyzer-scenarios/**",
150+
"**/bundle-analyzer-scenarios/*.cjs",
151+
"**/bundle-analyzer-scenarios/*.js"
152+
],
153+
"rules": {
154+
"no-console": "off"
155+
}
156+
},
157+
{
158+
"files": ["**/src/**"],
159+
"rules": {
160+
"no-restricted-globals": ["error", "window", "document", "location", "navigator"]
161+
}
162+
}
163+
]
164+
}

.oxlintrc.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"extends": ["./.oxlintrc.base.json"],
4+
"options": {
5+
"typeAware": true
6+
},
7+
"jsPlugins": [
8+
{
9+
"name": "sdk",
10+
"specifier": "@sentry-internal/eslint-plugin-sdk"
11+
}
12+
],
13+
"categories": {},
14+
"rules": {
15+
"sdk/no-eq-empty": "error"
16+
},
17+
"overrides": [
18+
{
19+
"files": ["**/src/**"],
20+
"rules": {
21+
"sdk/no-class-field-initializers": "error",
22+
"sdk/no-regexp-constructor": "error"
23+
}
24+
}
25+
],
26+
"env": {
27+
"es2017": true,
28+
"node": true
29+
},
30+
"globals": {},
31+
"ignorePatterns": [
32+
"coverage/**",
33+
"build/**",
34+
"dist/**",
35+
"cjs/**",
36+
"esm/**",
37+
"examples/**",
38+
"test/manual/**",
39+
"types/**",
40+
"scripts/*.js",
41+
"node_modules/**"
42+
]
43+
}

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"packages/bundler-plugin-core",
1111
"packages/dev-utils",
1212
"packages/esbuild-plugin",
13-
"packages/eslint-configs",
1413
"packages/playground",
1514
"packages/rollup-plugin",
1615
"packages/vite-plugin",
@@ -28,7 +27,8 @@
2827
"test": "nx run-many --target=test --all",
2928
"test:unit": "nx run-many --target=test --all --exclude=@sentry-internal/integration-tests-next",
3029
"test:integration": "nx run @sentry-internal/integration-tests-next:test",
31-
"lint": "nx run-many --target=lint --all",
30+
"lint": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint .",
31+
"lint:fix": "OXLINT_TSGOLINT_DANGEROUSLY_SUPPRESS_PROGRAM_DIAGNOSTICS=true oxlint . --fix",
3232
"check:formatting": "oxfmt --check .",
3333
"fix:formatting": "oxfmt ."
3434
},
@@ -40,6 +40,8 @@
4040
"npm-run-all": "^4.1.5",
4141
"nx": "22.5.2",
4242
"oxfmt": "^0.33.0",
43+
"oxlint": "1.53.0",
44+
"oxlint-tsgolint": "0.16.0",
4345
"typescript": "~5.8.0"
4446
},
4547
"volta": {

packages/babel-plugin-component-annotate/.eslintrc.js

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

packages/babel-plugin-component-annotate/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,13 @@
4646
"clean:all": "run-p clean clean:deps",
4747
"clean:build": "premove ./dist *.tgz",
4848
"clean:deps": "premove node_modules",
49-
"test": "vitest run",
50-
"lint": "eslint ./src ./test"
49+
"test": "vitest run"
5150
},
5251
"devDependencies": {
5352
"@babel/core": "7.18.5",
5453
"@types/babel__core": "^7.20.5",
5554
"@babel/preset-react": "^7.23.3",
56-
"@sentry-internal/eslint-config": "5.3.0",
5755
"@types/node": "^18.6.3",
58-
"eslint": "^8.18.0",
5956
"vitest": "^4.0.0",
6057
"premove": "^4.0.0",
6158
"rolldown": "^1.0.0"

packages/babel-plugin-component-annotate/src/experimental.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* oxlint-disable max-lines */
12
/**
23
* MIT License
34
*
@@ -103,7 +104,7 @@ export function experimentalComponentNameAnnotatePlugin({
103104
},
104105
},
105106
FunctionDeclaration(path, state) {
106-
if (!path.node.id || !path.node.id.name) {
107+
if (!path.node.id?.name) {
107108
return;
108109
}
109110

@@ -134,7 +135,7 @@ export function experimentalComponentNameAnnotatePlugin({
134135
return prop.isClassMethod() && prop.get("key").isIdentifier({ name: "render" });
135136
});
136137

137-
if (!render || !render.traverse) {
138+
if (!render?.traverse) {
138139
return;
139140
}
140141

@@ -441,10 +442,8 @@ function collectFragmentContext(programPath: Babel.NodePath): FragmentContext {
441442
for (const prop of properties) {
442443
if (
443444
prop.type === "ObjectProperty" &&
444-
prop.key &&
445-
prop.key.type === "Identifier" &&
446-
prop.value &&
447-
prop.value.type === "Identifier" &&
445+
prop.key?.type === "Identifier" &&
446+
prop.value?.type === "Identifier" &&
448447
prop.key.name === "Fragment"
449448
) {
450449
fragmentAliases.add(prop.value.name);

packages/babel-plugin-component-annotate/src/index.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* oxlint-disable max-lines */
12
/**
23
* MIT License
34
*
@@ -109,7 +110,7 @@ export default function componentNameAnnotatePlugin({ types: t }: typeof Babel):
109110
},
110111
},
111112
FunctionDeclaration(path, state) {
112-
if (!path.node.id || !path.node.id.name) {
113+
if (!path.node.id?.name) {
113114
return;
114115
}
115116
if (isKnownIncompatiblePluginFromState(state)) {
@@ -147,7 +148,7 @@ export default function componentNameAnnotatePlugin({ types: t }: typeof Babel):
147148
return prop.isClassMethod() && prop.get("key").isIdentifier({ name: "render" });
148149
});
149150

150-
if (!render || !render.traverse || isKnownIncompatiblePluginFromState(state)) {
151+
if (!render?.traverse || isKnownIncompatiblePluginFromState(state)) {
151152
return;
152153
}
153154

@@ -319,7 +320,7 @@ function processJSX(
319320
return;
320321
}
321322

322-
if (shouldSetComponentName && openingElement && openingElement.node) {
323+
if (shouldSetComponentName && openingElement?.node) {
323324
shouldSetComponentName = false;
324325
processJSX(context, child, currentComponentName);
325326
} else {
@@ -523,10 +524,8 @@ function collectFragmentContext(programPath: Babel.NodePath): FragmentContext {
523524
for (const prop of properties) {
524525
if (
525526
prop.type === "ObjectProperty" &&
526-
prop.key &&
527-
prop.key.type === "Identifier" &&
528-
prop.value &&
529-
prop.value.type === "Identifier" &&
527+
prop.key?.type === "Identifier" &&
528+
prop.value?.type === "Identifier" &&
530529
prop.key.name === "Fragment"
531530
) {
532531
fragmentAliases.add(prop.value.name);
@@ -880,7 +879,7 @@ function maybeInjectSentryLabel(context: JSXProcessingContext, jsxNode: Babel.No
880879
}
881880

882881
if (label.length > MAX_LABEL_LENGTH) {
883-
label = label.substring(0, MAX_LABEL_LENGTH - 3) + "...";
882+
label = `${label.substring(0, MAX_LABEL_LENGTH - 3)}...`;
884883
}
885884

886885
targetElement.openingElement.attributes.push(

packages/babel-plugin-component-annotate/test/sentry-label.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, it, expect } from "vitest";
2-
import { transform, BabelFileResult } from "@babel/core";
2+
import type { BabelFileResult } from "@babel/core";
3+
import { transform } from "@babel/core";
34
import plugin from "../src/index";
45

56
function transformWith(code: string, opts: Record<string, unknown> = {}): BabelFileResult | null {

0 commit comments

Comments
 (0)