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

Merge next branch #2186

Merged
merged 9 commits into from
Oct 27, 2024
Merged
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
105 changes: 54 additions & 51 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,104 +1,100 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true },
"organizeImports": { "enabled": true },
"formatter": {
"formatWithErrors": true,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80
},
"organizeImports": { "enabled": true },
"javascript": {
"globals": ["chrome"],
"formatter": {
"semicolons": "always",
"trailingCommas": "all",
"quoteStyle": "single"
}
},
"linter": {
"rules": {
"recommended": true,
"complexity": {
"noForEach": "off",
"useSimplifiedLogicExpression": "info"
"noUselessStringConcat": "warn",
"noUselessUndefinedInitialization": "warn",
"useSimplifiedLogicExpression": "info",
"useDateNow": "error"
},
"correctness": {
"noUndeclaredDependencies": "warn",
"noUndeclaredVariables": "warn",
"noUnusedFunctionParameters": "warn",
"noUnusedImports": "error"
},
"performance": {
"noBarrelFile": "info",
"noReExportAll": "info"
},
"style": {
"noDoneCallback": "warn",
"noNamespace": "error",
"noNamespaceImport": "warn",
"noNegationElse": "error",
"noNonNullAssertion": "off",
"noParameterProperties": "error",
"noRestrictedGlobals": "error",
"noShoutyConstants": "error",
"noYodaExpression": "warn",
"useCollapsedElseIf": "error",
"useConsistentBuiltinInstantiation": "error",
"useDefaultSwitchClause": "warn",
"useEnumInitializers": "off",
"useExplicitLengthCheck": "warn",
"useNamingConvention": {
"level": "error",
"options": { "strictCase": false }
},
"useShorthandArrayType": "error",
"useShorthandAssign": "error",
"useSingleCaseStatement": "info",
"useTemplate": "off"
"useTemplate": "off",
"useThrowNewError": "error",
"useThrowOnlyError": "warn"
},
"suspicious": {
"noApproximativeNumericConstant": "error",
"noAssignInExpressions": "off",
"noConfusingVoidType": "off",
"noConsoleLog": "warn",
"noConstEnum": "off",
"noExplicitAny": "off",
"noFocusedTests": "error",
"noMisrefactoredShorthandAssign": "error"
},
"nursery": {
"noDoneCallback": "warn",
"noDuplicateAtImportRules": "error",
"noDuplicateElseIf": "error",
"noDuplicateFontNames": "error",
"noDuplicateJsonKeys": "error",
"noDuplicateSelectorsKeyframeBlock": "error",
"noEmptyBlock": "warn",
"noEvolvingTypes": "warn",
"noImportantInKeyframe": "error",
"noInvalidDirectionInLinearGradient": "error",
"noInvalidPositionAtImportRule": "error",
"noLabelWithoutControl": "warn",
"noExplicitAny": "off",
"noFocusedTests": "error",
"noMisplacedAssertion": "error",
"noShorthandPropertyOverrides": "warn",
"noMisrefactoredShorthandAssign": "error",
"useErrorMessage": "warn"
},
"nursery": {
"noCommonJs": "error",
"noDuplicateElseIf": "error",
"noDynamicNamespaceImportAccess": "error",
"noEnum": "error",
"noExportedImports": "error",
"noSecrets": "warn", // TODO: Change to "error" when more stable
"noSubstr": "warn",
"noUndeclaredDependencies": "warn",
"noUnknownFunction": "warn",
"noUnknownMediaFeatureName": "warn",
"noUnknownProperty": "warn",
"noUnknownPseudoClassSelector": "warn",
"noUnknownSelectorPseudoElement": "warn",
"noUnknownUnit": "error",
"noUnmatchableAnbSelector": "warn",
"noUnusedFunctionParameters": "warn",
"noUselessStringConcat": "warn",
"noUselessUndefinedInitialization": "warn",
"noYodaExpression": "warn",
"noUnknownPseudoClass": "warn",
"noUnknownPseudoElement": "warn",
"useAdjacentOverloadSignatures": "error",
"useConsistentBuiltinInstantiation": "error",
"useConsistentGridAreas": "warn",
"useDateNow": "error",
"useDefaultSwitchClause": "warn",
"useErrorMessage": "warn",
// "useExplicitLengthCheck": "warn",
"useFocusableInteractive": "warn",
"useGenericFontNames": "error",
"useThrowNewError": "error",
"useThrowOnlyError": "warn",
"useValidAutocomplete": "warn"
}
}
},
"javascript": {
"globals": ["chrome", "Timer"], // TODO: Remove `Timer`; only used as type (from Bun globals)
"formatter": {
"semicolons": "always",
"trailingCommas": "all",
"quoteStyle": "single"
}
},
"overrides": [
{
"include": [".vscode/*.json", "tsconfig*.json"],
Expand All @@ -116,26 +112,33 @@
},
"linter": {
"rules": {
"nursery": {
"correctness": {
"noUndeclaredDependencies": "off"
}
}
},
"javascript": {
"globals": ["$console", "Bun", "chrome", "happyDOM", "Loader"]
}
},
{
"include": ["build.ts", "*.config.ts"],
"include": ["*.config.mjs", "*.config.ts", "*.d.ts", "build.ts"],
"linter": {
"rules": {
"correctness": {
"noUndeclaredDependencies": "off"
},
"style": {
"noNamespaceImport": "off",
"useNamingConvention": "off"
},
"suspicious": {
"noConsoleLog": "off"
},
"nursery": {
"noUndeclaredDependencies": "off"
}
}
},
"javascript": {
"globals": ["Bun", "chrome"]
}
}
]
Expand Down
8 changes: 5 additions & 3 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ function compileCSS(src: string, from: string) {
}
}

// TODO: Migrate to bun CSS handling (which is based on lightningcss).
const minified = lightningcss.transform({
filename: from,
code: Buffer.from(compiled.css),
code: new TextEncoder().encode(compiled.css),
minify: !dev,
// eslint-disable-next-line no-bitwise
targets: { chrome: 116 << 16 }, // matches manifest minimum_chrome_version
targets: { chrome: 123 << 16 }, // matches manifest minimum_chrome_version
});

for (const warning of minified.warnings) {
Expand Down Expand Up @@ -136,7 +137,7 @@ const out = await Bun.build({
outdir: 'dist',
target: 'browser',
minify: !dev,
sourcemap: dev ? 'external' : 'none',
sourcemap: dev ? 'linked' : 'none',
});
console.timeEnd('build');
console.log(out);
Expand All @@ -148,6 +149,7 @@ const out2 = await Bun.build({
outdir: 'dist',
target: 'browser',
minify: !dev,
sourcemap: dev ? 'linked' : 'none',
});
console.timeEnd('build2');
console.log(out2);
Expand Down
Binary file modified bun.lockb
Binary file not shown.
81 changes: 18 additions & 63 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,69 +1,35 @@
import { fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import eslint from '@eslint/js';
import mm from '@maxmilton/eslint-config';
import unicorn from 'eslint-plugin-unicorn';
// eslint-disable-next-line import/no-unresolved
import tseslint from 'typescript-eslint';

const compat = new FlatCompat({
baseDirectory: import.meta.dirname,
});
import ts from 'typescript-eslint';

const OFF = 0;
const WARN = 1;
// const WARN = 1;
const ERROR = 2;

export default tseslint.config(
export default ts.config(
eslint.configs.recommended,
...compat.extends('airbnb-base').map((config) => ({
...config,
plugins: {}, // delete
})),
...compat.extends('airbnb-typescript/base'),
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
// @ts-expect-error - no types
// eslint-disable-next-line
...ts.configs.strictTypeChecked,
...ts.configs.stylisticTypeChecked,
unicorn.configs['flat/recommended'],
mm.configs.recommended,
{
linterOptions: {
reportUnusedDisableDirectives: WARN,
reportUnusedDisableDirectives: ERROR,
},
languageOptions: {
parserOptions: {
project: ['tsconfig.json', 'tsconfig.node.json'],
projectService: {
allowDefaultProject: ['*.js', '*.cjs', '*.mjs'],
// defaultProject: './tsconfig.node.json',
},
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
import: fixupPluginRules(
compat.plugins('eslint-plugin-import')[0].plugins?.import ?? {},
),
},
rules: {
'@typescript-eslint/explicit-module-boundary-types': ERROR,
'@typescript-eslint/no-confusing-void-expression': WARN,
'@typescript-eslint/no-non-null-assertion': WARN,
'@typescript-eslint/no-use-before-define': WARN,
'import/prefer-default-export': OFF,
'no-restricted-syntax': OFF,
'no-void': OFF,
'unicorn/filename-case': OFF,
'unicorn/import-style': WARN,
'unicorn/no-abusive-eslint-disable': WARN,
'unicorn/no-null': OFF,
'unicorn/prefer-module': WARN,
'unicorn/prefer-top-level-await': WARN,
'unicorn/prevent-abbreviations': OFF,

/* Covered by biome formatter */
'@typescript-eslint/indent': OFF,
'function-paren-newline': OFF,
'implicit-arrow-linebreak': OFF,
'max-len': OFF,
'object-curly-newline': OFF,
'operator-linebreak': OFF,
'unicorn/no-nested-ternary': OFF,
// FIXME: Remove this once fixed upstream (incorrectly reports chrome as deprecated).
'@typescript-eslint/no-deprecated': OFF,

/* Performance and byte savings */
// alternatives offer byte savings and better performance
Expand All @@ -89,6 +55,9 @@ export default tseslint.config(
// byte savings (minification doesn't currently automatically remove)
'unicorn/switch-case-braces': [ERROR, 'avoid'],

// prefer to clearly separate Bun and DOM
'unicorn/prefer-global-this': OFF,

/* stage1 */
// underscores in synthetic event handler names
'no-underscore-dangle': OFF,
Expand All @@ -97,20 +66,6 @@ export default tseslint.config(
'unicorn/prefer-query-selector': OFF,
},
},
{
files: [
'*.config.mjs',
'*.config.ts',
'*.d.ts',
'**/*.spec.ts',
'**/*.test.ts',
'build.ts',
'test/**',
],
rules: {
'import/no-extraneous-dependencies': OFF,
},
},
{
files: ['build.ts'],
rules: {
Expand All @@ -119,6 +74,6 @@ export default tseslint.config(
},
},
{
ignores: ['**/*.bak', 'dist/**'],
ignores: ['**/*.bak', 'coverage/**', 'dist/**'],
},
);
3 changes: 2 additions & 1 deletion manifest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const createManifest = (
version: pkg.version,
// shippable releases should not have a named version
version_name: debug ? gitRef() : undefined,
minimum_chrome_version: '116', // for new password manager link
minimum_chrome_version: '123', // for light-dark() CSS function
icons: {
16: 'icon16.png',
48: 'icon48.png',
Expand Down Expand Up @@ -80,5 +80,6 @@ export const createManifest = (
cross_origin_opener_policy: { value: 'same-origin' },

// https://chrome.google.com/webstore/detail/new-tab/cpcibnbdmpmcmnkhoiilpnlaepkepknb
// biome-ignore lint/nursery/noSecrets: not a secret
key: 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk9BfRa5CXuCX1ElY0yu9kJSqxFirFtSy79ZR/fyKHdOzZurQXNmhIyxVnQXd2bxHvuKUyZGahm/gwgyyzGuxhsQEue6wTD9TnOvvM2vusXpnoCr6Ili7sBwUo9vA2aPI77NB0eArXz9WWNmoDWW5WEqI/rk26Tinl8SNU9iDJISbL+dMses1QPw64oYFWB1J4JeB1MhXnzTxECpGZTn33LhgBU4J3ooT6eoqrsJdRvuc0vjPMxq/jfqLkdBbzlsnrMbgtDoJ9WiWj2lA0MzHGDAQ8HgnMEi3SpXRNnod9CCBnxmkHqv3u4u7Tvp/WLAgJ+QjCt+9yYyw3nOYHpEweQIDAQAB',
});
Loading
Loading