diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 9a679aa..0000000 --- a/.eslintrc +++ /dev/null @@ -1,19 +0,0 @@ -{ - "root": true, - "parser": "@typescript-eslint/parser", - "plugins": [ - "@typescript-eslint/eslint-plugin" - ], - "parserOptions": { - "project": "tsconfig.json", - "sourceType": "module" - }, - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended" - ], - "env": { - "node": true - } -} \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100755 index 631975c..0000000 --- a/.prettierrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/prettierrc", - "arrowParens": "avoid", - "bracketSameLine": false, - "bracketSpacing": true, - "endOfLine": "lf", - "semi": true, - "trailingComma": "all", - "printWidth": 120, - "tabWidth": 2, - "useTabs": false, - "singleQuote": true -} \ No newline at end of file diff --git a/audit-ci.json b/audit-ci.json index 960680c..96dabdb 100644 --- a/audit-ci.json +++ b/audit-ci.json @@ -6,4 +6,4 @@ "critical": true, "moderate": false, "low": false -} \ No newline at end of file +} diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..fac1392 --- /dev/null +++ b/biome.json @@ -0,0 +1,94 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", + "files": { + "include": ["src/*"] + }, + "formatter": { + "enabled": true, + "formatWithErrors": false, + "indentStyle": "space", + "indentWidth": 2, + "lineEnding": "lf", + "lineWidth": 120, + "attributePosition": "auto" + }, + "organizeImports": { "enabled": true }, + "linter": { + "enabled": true, + "rules": { + "recommended": false, + "complexity": { + "noBannedTypes": "error", + "noExtraBooleanCast": "error", + "noMultipleSpacesInRegularExpressionLiterals": "error", + "noUselessCatch": "error", + "noUselessThisAlias": "error", + "noUselessTypeConstraint": "error", + "noWith": "error" + }, + "correctness": { + "noConstAssign": "error", + "noConstantCondition": "error", + "noEmptyCharacterClassInRegex": "error", + "noEmptyPattern": "error", + "noGlobalObjectCalls": "error", + "noInnerDeclarations": "error", + "noInvalidConstructorSuper": "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", + "noUnusedVariables": "error", + "useArrayLiterals": "off", + "useIsNan": "error", + "useValidForDirection": "error", + "useYield": "error" + }, + "style": { "noNamespace": "error", "useAsConstAssertion": "error" }, + "suspicious": { + "noAssignInExpressions": "error", + "noAsyncPromiseExecutor": "error", + "noCatchAssign": "error", + "noClassAssign": "error", + "noCompareNegZero": "error", + "noControlCharactersInRegex": "error", + "noDebugger": "error", + "noDuplicateCase": "error", + "noDuplicateClassMembers": "error", + "noDuplicateObjectKeys": "error", + "noDuplicateParameters": "error", + "noEmptyBlockStatements": "error", + "noExplicitAny": "error", + "noExtraNonNullAssertion": "error", + "noFallthroughSwitchClause": "error", + "noFunctionAssign": "error", + "noGlobalAssign": "error", + "noImportAssign": "error", + "noMisleadingCharacterClass": "error", + "noMisleadingInstantiator": "error", + "noPrototypeBuiltins": "error", + "noRedeclare": "error", + "noShadowRestrictedNames": "error", + "noUnsafeDeclarationMerging": "error", + "noUnsafeNegation": "error", + "useGetterReturn": "error", + "useValidTypeof": "error" + } + } + }, + "javascript": { + "formatter": { + "arrowParentheses": "asNeeded", + "bracketSpacing": true, + "quoteStyle": "single" + } + } +} diff --git a/commitlint.config.ts b/commitlint.config.ts index fe34499..5434850 100644 --- a/commitlint.config.ts +++ b/commitlint.config.ts @@ -1,11 +1,11 @@ import { UserConfig, RuleConfigSeverity } from '@commitlint/types'; export default { - extends: ['@commitlint/config-conventional'], - rules: { - "body-empty": [RuleConfigSeverity.Disabled, 'never'], - "body-leading-blank": [RuleConfigSeverity.Disabled, 'never'], - "footer-empty": [RuleConfigSeverity.Disabled, 'never'], - "footer-leading-blank": [RuleConfigSeverity.Disabled, 'never'], - } -} satisfies UserConfig; \ No newline at end of file + extends: ['@commitlint/config-conventional'], + rules: { + 'body-empty': [RuleConfigSeverity.Disabled, 'never'], + 'body-leading-blank': [RuleConfigSeverity.Disabled, 'never'], + 'footer-empty': [RuleConfigSeverity.Disabled, 'never'], + 'footer-leading-blank': [RuleConfigSeverity.Disabled, 'never'], + }, +} satisfies UserConfig; diff --git a/package-lock.json b/package-lock.json old mode 100755 new mode 100644 index 1d335d9..4550f3e --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "hasInstallScript": true, "license": "MIT", "devDependencies": { + "@biomejs/biome": "^1.8.3", "@commitlint/cli": "^19.3.0", "@commitlint/config-conventional": "^19.2.2", "@stencil/core": "~4.18.3", @@ -105,6 +106,68 @@ "node": ">=0.8.0" } }, + "node_modules/@biomejs/biome": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.8.3.tgz", + "integrity": "sha512-/uUV3MV+vyAczO+vKrPdOW0Iaet7UnJMU4bNMinggGJTAnBPjCoLEYcyYtYHNnUNYlv4xZMH6hVIQCAozq8d5w==", + "dev": true, + "hasInstallScript": true, + "license": "MIT OR Apache-2.0", + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.21.3" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-darwin-arm64": "1.8.3", + "@biomejs/cli-darwin-x64": "1.8.3", + "@biomejs/cli-linux-arm64": "1.8.3", + "@biomejs/cli-linux-arm64-musl": "1.8.3", + "@biomejs/cli-linux-x64": "1.8.3", + "@biomejs/cli-linux-x64-musl": "1.8.3", + "@biomejs/cli-win32-arm64": "1.8.3", + "@biomejs/cli-win32-x64": "1.8.3" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.8.3.tgz", + "integrity": "sha512-I8G2QmuE1teISyT8ie1HXsjFRz9L1m5n83U1O6m30Kw+kPMPSKjag6QGUn+sXT8V+XWIZxFFBoTDEDZW2KPDDw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64-musl": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.8.3.tgz", + "integrity": "sha512-UHrGJX7PrKMKzPGoEsooKC9jXJMa28TUSMjcIlbDnIO4EAavCoVmNQaIuUSH0Ls2mpGMwUIf+aZJv657zfWWjA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, "node_modules/@commitlint/cli": { "version": "19.3.0", "resolved": "https://registry.npmjs.org/@commitlint/cli/-/cli-19.3.0.tgz", @@ -629,160 +692,6 @@ "node": ">=14" } }, - "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.18.1.tgz", - "integrity": "sha512-lncuC4aHicncmbORnx+dUaAgzee9cm/PbIqgWz1PpXuwc+sa1Ct83tnqUDy/GFKleLiN7ZIeytM6KJ4cAn1SxA==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-android-arm64": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.18.1.tgz", - "integrity": "sha512-F/tkdw0WSs4ojqz5Ovrw5r9odqzFjb5LIgHdHZG65dFI1lWTWRVy32KDJLKRISHgJvqUeUhdIvy43fX41znyDg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ] - }, - "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.18.1.tgz", - "integrity": "sha512-vk+ma8iC1ebje/ahpxpnrfVQJibTMyHdWpOGZ3JpQ7Mgn/3QNHmPq7YwjZbIE7km73dH5M1e6MRRsnEBW7v5CQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.18.1.tgz", - "integrity": "sha512-IgpzXKauRe1Tafcej9STjSSuG0Ghu/xGYH+qG6JwsAUxXrnkvNHcq/NL6nz1+jzvWAnQkuAJ4uIwGB48K9OCGA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ] - }, - "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.18.1.tgz", - "integrity": "sha512-P9bSiAUnSSM7EmyRK+e5wgpqai86QOSv8BwvkGjLwYuOpaeomiZWifEos517CwbG+aZl1T4clSE1YqqH2JRs+g==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.18.1.tgz", - "integrity": "sha512-5RnjpACoxtS+aWOI1dURKno11d7krfpGDEn19jI8BuWmSBbUC4ytIADfROM1FZrFhQPSoP+KEa3NlEScznBTyQ==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.18.1.tgz", - "integrity": "sha512-8mwmGD668m8WaGbthrEYZ9CBmPug2QPGWxhJxh/vCgBjro5o96gL04WLlg5BA233OCWLqERy4YUzX3bJGXaJgQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.18.1.tgz", - "integrity": "sha512-dJX9u4r4bqInMGOAQoGYdwDP8lQiisWb9et+T84l2WXk41yEej8v2iGKodmdKimT8cTAYt0jFb+UEBxnPkbXEQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.18.1.tgz", - "integrity": "sha512-V72cXdTl4EI0x6FNmho4D502sy7ed+LuVW6Ym8aI6DRQ9hQZdp5sj0a2usYOlqvFBNKQnLQGwmYnujo2HvjCxQ==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.18.1.tgz", - "integrity": "sha512-f+pJih7sxoKmbjghrM2RkWo2WHUW8UbfxIQiWo5yeCaCM0TveMEuAzKJte4QskBp1TIinpnRcxkquY+4WuY/tg==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, - "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.18.1.tgz", - "integrity": "sha512-qb1hMMT3Fr/Qz1OKovCuUM11MUNLUuHeBC2DPPAWUYYUAOFWaxInaTwTQmc7Fl5La7DShTEpmYwgdt2hG+4TEg==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, "node_modules/@rollup/rollup-linux-x64-gnu": { "version": "4.18.1", "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.18.1.tgz", @@ -811,48 +720,6 @@ "linux" ] }, - "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.18.1.tgz", - "integrity": "sha512-W2ZNI323O/8pJdBGil1oCauuCzmVd9lDmWBBqxYZcOqWD6aWqJtVBQ1dFrF4dYpZPks6F+xCZHfzG5hYlSHZ6g==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.18.1.tgz", - "integrity": "sha512-ELfEX1/+eGZYMaCIbK4jqLxO1gyTSOIlZr6pbC4SRYFaSIDVKOnZNMdoZ+ON0mrFDp4+H5MhwNC1H/AhE3zQLg==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, - "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.18.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.18.1.tgz", - "integrity": "sha512-yjk2MAkQmoaPYCSu35RLJ62+dz358nE83VfTePJRp8CG7aMg25mEJYpXFiD+NcevhX8LxD5OP5tktPXnXN7GDw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ] - }, "node_modules/@stencil/core": { "version": "4.18.3", "resolved": "https://registry.npmjs.org/@stencil/core/-/core-4.18.3.tgz", @@ -2205,20 +2072,6 @@ "dev": true, "license": "ISC" }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, - "hasInstallScript": true, - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", diff --git a/package.json b/package.json index 71c5089..59b6f96 100755 --- a/package.json +++ b/package.json @@ -5,22 +5,12 @@ "main": "dist/index.js", "module": "dist/index.mjs", "types": "dist/index.d.ts", - "files": [ - "dist/", - "scripts/", - "template/" - ], + "files": ["dist/", "scripts/", "template/"], "publishConfig": { "access": "public" }, "author": "https://github.com/CheeseGrinder", - "keywords": [ - "stencil", - "custom", - "custom-target-output", - "component", - "config" - ], + "keywords": ["stencil", "custom", "custom-target-output", "component", "config"], "license": "MIT", "homepage": "https://github.com/CheeseGrinder/stencil-component-config#readme", "repository": { @@ -34,13 +24,14 @@ "postinstall": "node scripts/post-install", "prebuild": "rm -rf ./dist ./build ./config", "build": "tsc -p . && rollup -c rollup.config.mjs", - "format": "prettier ./src/**/*.ts --check", - "format:fix": "prettier ./src/**/*.ts --write", - "lint": "eslint \"src/**/*.ts\"", - "lint:fix": "eslint \"src/**/*.ts\" --fix", + "format": "biome format", + "format:fix": "biome format --fix", + "lint": "biome lint", + "lint:fix": "biome lint --fix", "prepare": "husky" }, "devDependencies": { + "@biomejs/biome": "^1.8.3", "@commitlint/cli": "^19.3.0", "@commitlint/config-conventional": "^19.2.2", "@stencil/core": "~4.18.3", diff --git a/rollup.config.mjs b/rollup.config.mjs index b02cd19..ee0e631 100755 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -17,12 +17,5 @@ export default { file: pkg.module, }, ], - external: [ - '@stencil/core/cli', - '@stencil/core/compiler', - 'node:fs', - 'node:fs/promises', - 'node:path', - 'typescript', - ] -}; \ No newline at end of file + external: ['@stencil/core/cli', '@stencil/core/compiler', 'node:fs', 'node:fs/promises', 'node:path', 'typescript'], +}; diff --git a/src/component.target.ts b/src/component.target.ts index cb07a32..fcf655a 100755 --- a/src/component.target.ts +++ b/src/component.target.ts @@ -1,8 +1,8 @@ +import { writeFileSync } from 'node:fs'; +import { join } from 'node:path'; import { parseFlags } from '@stencil/core/cli'; import { loadConfig } from '@stencil/core/compiler'; import { BuildCtx, Config, OutputTargetCustom } from '@stencil/core/internal'; -import { writeFileSync } from 'node:fs'; -import { join } from 'node:path'; import { parseConfig } from './config-parser'; import { hasConfigProp, typeImportData } from './util'; diff --git a/src/config-parser.ts b/src/config-parser.ts index 859f7f5..1da8ee5 100644 --- a/src/config-parser.ts +++ b/src/config-parser.ts @@ -1,13 +1,12 @@ -import { existsSync } from "node:fs"; -import { join } from "node:path"; -import { parseBiomeConfig } from "./parser/biome"; -import { parsePrettierConfig } from "./parser/prettier"; -import { ConfigType, type StyleConfig } from "./types/config"; - +import { existsSync } from 'node:fs'; +import { join } from 'node:path'; +import { parseBiomeConfig } from './parser/biome'; +import { parsePrettierConfig } from './parser/prettier'; +import { ConfigType, type StyleConfig } from './types/config'; export async function parseConfig(): Promise { const configType = getConfigType(); - return getConfig(configType) + return getConfig(configType); } function getConfigType(): ConfigType { @@ -51,4 +50,3 @@ async function getConfig(type: ConfigType): Promise { }; } } - diff --git a/src/util.stencil.ts b/src/util.stencil.ts index adad312..830de3b 100755 --- a/src/util.stencil.ts +++ b/src/util.stencil.ts @@ -1,7 +1,7 @@ // CODE FROM STENCIlJS/CORE -import * as d from '@stencil/core/internal'; import path, { dirname } from 'node:path'; +import * as d from '@stencil/core/internal'; import ts from 'typescript'; /** diff --git a/src/util.ts b/src/util.ts index 1ccc062..128b0b5 100755 --- a/src/util.ts +++ b/src/util.ts @@ -1,6 +1,6 @@ +import { isAbsolute } from 'node:path'; import { BuildCtx, ComponentCompilerProperty, TypesImportData, ValidatedConfig } from '@stencil/core/internal'; import { normalizePath, relative, sortImportNames, updateReferenceTypeImports } from './util.stencil'; -import { isAbsolute } from 'node:path'; export function hasConfigProp(prop: ComponentCompilerProperty): boolean { return prop.docs.tags.some(tag => tag.name === 'config'); diff --git a/template/components.config.ts b/template/components.config.ts index 489014e..1f07cd6 100755 --- a/template/components.config.ts +++ b/template/components.config.ts @@ -1,3 +1,4 @@ +// @ts-ignore import type { Configuration } from 'src/components-config'; type Config = Configuration.ComponentsConfig; @@ -45,3 +46,5 @@ export class ComponentConfig { return config![prop] ?? (fallback as Config[Tag][Prop]); } } + +export const componentConfig = new ComponentConfig(); diff --git a/tsconfig.json b/tsconfig.json index a2262fb..177c611 100755 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,10 +4,7 @@ "alwaysStrict": true, "declaration": true, "forceConsistentCasingInFileNames": true, - "lib": [ - "es2015", - "dom" - ], + "lib": ["es2015", "dom"], "esModuleInterop": true, "module": "es2015", "target": "es2017", @@ -21,9 +18,7 @@ "outDir": "build", "declarationDir": "dist", "pretty": true, - "removeComments": false, + "removeComments": false }, - "files": [ - "src/index.ts" - ] -} \ No newline at end of file + "files": ["src/index.ts"] +}