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

[PoC] Migrate eslint and prettier to biome #554

Open
wants to merge 1 commit 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
8 changes: 0 additions & 8 deletions .prettierignore

This file was deleted.

5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

3 changes: 3 additions & 0 deletions addon/devtools/loader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// biome-ignore lint/correctness/noUndeclaredVariables: <explanation>
chrome.devtools.panels.create('Autoconsent', '/icons/cookie.png', '/devtools/panel.html');

// biome-ignore lint/correctness/noUndeclaredVariables: <explanation>
if (chrome.devtools?.recorder) {
class MyPlugin {
stringify(recording) {
Expand Down Expand Up @@ -48,6 +50,7 @@ if (chrome.devtools?.recorder) {
}
}

// biome-ignore lint/correctness/noUndeclaredVariables: <explanation>
chrome.devtools.recorder.registerRecorderExtensionPlugin(
new MyPlugin(),
/* name= */ 'Autoconsent',
Expand Down
306 changes: 306 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,306 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
"files": { "ignoreUnknown": false, "ignore": [] },
"formatter": {
"enabled": true,
"useEditorconfig": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 4,
"lineEnding": "lf",
"lineWidth": 140,
"attributePosition": "auto",
"bracketSpacing": true,
"ignore": [
"lib/consentomatic",
"**/dist",
"**/data",
"**/package.json",
"**/package-lock.json",
"addon/manifest.*.json",
"**/*.md",
"**/*.har",
"lib/filterlist-engine.ts"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

]
},
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": false,
"complexity": {
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "error",
"noUselessConstructor": "error",
"noUselessLoneBlockStatements": "error",
"noUselessRename": "error",
"noUselessTernary": "error",
"noUselessTypeConstraint": "error",
"noUselessUndefinedInitialization": "error",
"noVoid": "error",
"noWith": "error",
"useLiteralKeys": "error",
"useRegexLiterals": "error"
},
"correctness": {
"noConstAssign": "error",
"noConstantCondition": "error",
"noEmptyCharacterClassInRegex": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInnerDeclarations": "error",
"noInvalidBuiltinInstantiation": "error",
"noInvalidConstructorSuper": "error",
"noInvalidUseBeforeDeclaration": "error",
"noNewSymbol": "error",
"noNonoctalDecimalEscape": "error",
"noPrecisionLoss": "error",
"noSelfAssign": "error",
"noSetterReturn": "error",
"noSwitchDeclarations": "error",
"noUndeclaredVariables": "error",
"noUnreachable": "error",
"noUnreachableSuper": "error",
"noUnsafeFinally": "error",
"noUnsafeOptionalChaining": "error",
"noUnusedLabels": "error",
"noUnusedPrivateClassMembers": "error",
"noUnusedVariables": "error",
"useArrayLiterals": "off",
"useIsNan": "error",
"useValidForDirection": "error",
"useYield": "error"
},
"security": { "noGlobalEval": "error" },
"style": {
"noCommaOperator": "error",
"noNamespace": "error",
"noVar": "warn",
"noYodaExpression": "error",
"useAsConstAssertion": "error",
"useBlockStatements": "off",
"useConsistentBuiltinInstantiation": "error",
"useConst": "error",
"useSingleVarDeclarator": "error"
},
"suspicious": {
"noAsyncPromiseExecutor": "error",
"noCatchAssign": "error",
"noClassAssign": "error",
"noCompareNegZero": "error",
"noControlCharactersInRegex": "error",
"noDebugger": "error",
"noDoubleEquals": "error",
"noDuplicateCase": "error",
"noDuplicateClassMembers": "error",
"noDuplicateObjectKeys": "error",
"noDuplicateParameters": "error",
"noEmptyBlockStatements": "error",
"noExplicitAny": "off",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this from error to off, as I'm not sure if you'd like to use this in new code. If yes, then I'd change back to "error" and add inline biome-igore comments to the preexisting places.

"noExtraNonNullAssertion": "error",
"noFallthroughSwitchClause": "error",
"noFunctionAssign": "error",
"noGlobalAssign": "error",
"noImportAssign": "error",
"noLabelVar": "error",
"noMisleadingCharacterClass": "error",
"noMisleadingInstantiator": "error",
"noPrototypeBuiltins": "error",
"noRedeclare": "error",
"noSelfCompare": "error",
"noShadowRestrictedNames": "error",
"noSparseArray": "error",
"noUnsafeDeclarationMerging": "error",
"noUnsafeNegation": "error",
"useDefaultSwitchClauseLast": "error",
"useGetterReturn": "error",
"useNamespaceKeyword": "error",
"useValidTypeof": "error"
}
},
"ignore": ["lib/consentomatic/**/*", "dist/**/*", "lib/filterlist-engine.ts"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lib/filterlist-engine.ts was not in ignored files, but biome warned that it's really big and as it's apparently autogenerated, I suppose we could ignore it even in eslint+prettier in case you don't want to go through with Biome :)

},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "asNeeded",
"arrowParentheses": "always",
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto",
"bracketSpacing": true
},
"globals": [
"onscrollend",
"onpointerleave",
"oncontextrestored",
"onemptied",
"ongamepaddisconnected",
"onkeypress",
"onloadeddata",
"onmouseup",
"onvolumechange",
"onpaste",
"onstorage",
"onkeyup",
"onabort",
"oncut",
"ontransitionrun",
"onafterprint",
"onblur",
"ondurationchange",
"ontransitionstart",
"oncanplaythrough",
"onanimationend",
"onmouseleave",
"ondragleave",
"onplay",
"onunhandledrejection",
"onbeforeprint",
"onpointercancel",
"onsubmit",
"ondragstart",
"onmessage",
"location",
"onoffline",
"onappinstalled",
"onwheel",
"onended",
"onkeydown",
"onclick",
"onfocus",
"onscroll",
"ongamepadconnected",
"oncanplay",
"onpointerdown",
"ondeviceorientationabsolute",
"onauxclick",
"ondevicemotion",
"onratechange",
"ontransitionend",
"onscrollsnapchanging",
"onchange",
"onselect",
"onbeforeinstallprompt",
"onbeforetoggle",
"onmouseout",
"ontimeupdate",
"ondragover",
"oncuechange",
"ontransitioncancel",
"onprogress",
"onbeforeinput",
"onpointerenter",
"onmouseenter",
"oninvalid",
"onpointerout",
"onpagereveal",
"onpause",
"onanimationstart",
"onwaiting",
"onscrollsnapchange",
"ondeviceorientation",
"onclose",
"onbeforeunload",
"oncancel",
"onseeked",
"onpointerover",
"ongotpointercapture",
"onloadedmetadata",
"onpageshow",
"onstalled",
"oncontextmenu",
"onreset",
"ondrag",
"onbeforematch",
"onload",
"onlostpointercapture",
"onsuspend",
"onselectionchange",
"onpagehide",
"onrejectionhandled",
"onunload",
"onanimationcancel",
"onmousedown",
"onpointerup",
"onmouseover",
"onformdata",
"oncontentvisibilityautostatechange",
"onresize",
"onsearch",
"ontoggle",
"exports",
"onpageswap",
"onbeforexrselect",
"onlanguagechange",
"ondragenter",
"onerror",
"onpointermove",
"onmousemove",
"ondrop",
"onhashchange",
"onsecuritypolicyviolation",
"onslotchange",
"oncopy",
"onanimationiteration",
"ondblclick",
"ondragend",
"onpointerrawupdate",
"onpopstate",
"onplaying",
"oncontextlost",
"onloadstart",
"onseeking",
"oninput",
"onmessageerror",
"onselectstart",
"onmousewheel",
"ononline"
]
},
"overrides": [
{
"include": ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"],
"linter": {
"rules": {
"correctness": {
"noConstAssign": "off",
"noGlobalObjectCalls": "off",
"noInvalidBuiltinInstantiation": "off",
"noInvalidConstructorSuper": "off",
"noNewSymbol": "off",
"noSetterReturn": "off",
"noUndeclaredVariables": "off",
"noUnreachable": "off",
"noUnreachableSuper": "off"
},
"style": {
"noArguments": "error",
"noVar": "error",
"useConst": "error"
},
"suspicious": {
"noClassAssign": "off",
"noDuplicateClassMembers": "off",
"noDuplicateObjectKeys": "off",
"noDuplicateParameters": "off",
"noFunctionAssign": "off",
"noImportAssign": "off",
"noRedeclare": "off",
"noUnsafeNegation": "off",
"useGetterReturn": "off"
}
}
}
},
{ "include": ["addon/**/*"], "javascript": { "globals": [] } },
{
"include": ["tests/**/*", "tests-wtr/**/*"],
"javascript": { "globals": ["expect", "before", "should", "assert"] }
}
]
}
3 changes: 1 addition & 2 deletions ci/asana-create-tasks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable camelcase */
const timersPromises = require('node:timers/promises');
const Asana = require('asana');
const MarkdownIt = require('markdown-it');
Expand Down Expand Up @@ -73,7 +72,7 @@ const waitForJobSuccess = async (job_gid) => {
const interval = 1000;
const maxAttempts = 20;

// eslint-disable-next-line no-async-promise-executor -- legacy code
// biome-ignore lint/suspicious/noAsyncPromiseExecutor: legacy code
return new Promise(async (resolve, reject) => {
const innerFn = async function (job_gid, attempts) {
console.error(`Waiting for job ${job_gid} to complete...`);
Expand Down
2 changes: 1 addition & 1 deletion ci/asana-update-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const asanaUpdateTasks = async () => {
let asanaOutput;
try {
asanaOutput = JSON.parse(asanaOutputRaw || '');
} catch (e) {
} catch (_e) {
throw new Error(`Unable to parse Asana output JSON: ${asanaOutputRaw}`);
}

Expand Down
Loading