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

fix: Now correctly uses $schema file #4

Merged
merged 1 commit into from
Sep 8, 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
5 changes: 5 additions & 0 deletions .changeset/soft-melons-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ts-blocks": minor
---

Move schema to root of the package and initialize the `blocks.json` file with new `$schema` url.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ const blocks: Record<string, Block> = {
result: {
category: "types",
},
// ++++++
// ++++++
"to-map": {
category: "utilities",
},
// ++++++
// ++++++
};
```
2 changes: 1 addition & 1 deletion bin.mjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
import("./dist/index.mjs");
import('./dist/index.mjs');
103 changes: 99 additions & 4 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,110 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": true
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "tab",
"indentWidth": 4,
"lineEnding": "lf",
"lineWidth": 100,
"attributePosition": "auto"
},
"files": {
"ignore": ["dist", "node_modules"]
},
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": true
"recommended": true,
"complexity": {
"noExtraBooleanCast": "error",
"noMultipleSpacesInRegularExpressionLiterals": "error",
"noUselessCatch": "error",
"noUselessTypeConstraint": "error",
"noWith": "error"
},
"correctness": {
"noConstAssign": "error",
"noConstantCondition": "error",
"noEmptyCharacterClassInRegex": "error",
"noEmptyPattern": "error",
"noGlobalObjectCalls": "error",
"noInvalidConstructorSuper": "error",
"noInvalidNewBuiltin": "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"
},
"style": { "noNamespace": "error", "useAsConstAssertion": "error" },
"suspicious": {
"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",
"useNamespaceKeyword": "error",
"useValidTypeof": "error"
}
},
"ignore": ["**/dist/*", "**/node_modules/*"]
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "es5",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSpacing": true,
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto"
},
"globals": []
},
"overrides": [
{
"include": ["*.md"],
"formatter": {
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100
}
}
}
]
}
2 changes: 1 addition & 1 deletion blocks/utilities/array-to-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/
const arrayToMap = <T, K, V>(
arr: T[],
fn: (item: T, index: number) => [key: K, value: V],
fn: (item: T, index: number) => [key: K, value: V]
): Map<K, V> => {
const map = new Map<K, V>();

Expand Down
7 changes: 3 additions & 4 deletions blocks/utilities/map-to-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
* @param fn A mapping function to transform each pair into an item
* @returns
*/
const mapToArray = <K, V, T>(
map: Map<K, V>,
fn: (key: K, value: V) => T,
): T[] => {
const mapToArray = <K, V, T>(map: Map<K, V>, fn: (key: K, value: V) => T): T[] => {
const items: T[] = [];

for (const [key, value] of map) {
Expand All @@ -16,3 +13,5 @@ const mapToArray = <K, V, T>(

return items;
};

export { mapToArray };
2 changes: 1 addition & 1 deletion blocks/utilities/truncate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Options = {
const truncate = (
str: string,
maxLength: number,
{ reverse = false, ending = "" }: Partial<Options>,
{ reverse = false, ending = '' }: Partial<Options>
) => {
if (str.length <= maxLength) return str;

Expand Down
14 changes: 7 additions & 7 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { defineBuildConfig } from "unbuild";
import { defineBuildConfig } from 'unbuild';

export default defineBuildConfig({
entries: [
"src/index",
"src/blocks",
"src/commands/add",
"src/commands/init",
"src/commands/index",
"src/config/index",
'src/index',
'src/blocks',
'src/commands/add',
'src/commands/init',
'src/commands/index',
'src/config/index',
],
failOnWarn: false,
declaration: true,
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"type": "git",
"url": "git+https://github.com/ieedan/ts-blocks"
},
"keywords": [
"changelog",
"date"
],
"keywords": ["changelog", "date"],
"author": "Aidan Bleser",
"license": "MIT",
"bugs": {
Expand All @@ -24,7 +21,9 @@
"package.json",
"pnpm-lock.yaml",
"README.md",
"schema.json",
"dist/**/*",
"src/**/*",
"blocks/**/*"
],
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions src/config/schema.json → schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
},
"addByCategory": {
"description": "When true will create category directories within the provided path to organize the files.",
"type": "boolean"
"type": "boolean",
"default": "false"
},
"includeIndexFile": {
"description": "When true creates an `index.ts` at the root of the folder and exports each function from it when added.",
"type": "boolean"
"type": "boolean",
"default": "true"
}
},
"required": ["path", "addByCategory", "includeIndexFile"]
Expand Down
32 changes: 16 additions & 16 deletions src/blocks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type Category = "types" | "utilities";
export type Category = 'types' | 'utilities';

export type Block = {
dependencies?: Record<string, string>;
Expand All @@ -8,28 +8,28 @@ export type Block = {

const blocks: Record<string, Block> = {
result: {
category: "types",
exports: ["Result", "Ok", "Err"],
category: 'types',
exports: ['Result', 'Ok', 'Err'],
},
"array-to-map": {
category: "utilities",
exports: ["arrayToMap"],
'array-to-map': {
category: 'utilities',
exports: ['arrayToMap'],
},
"map-to-array": {
category: "utilities",
exports: ["mapToArray"],
'map-to-array': {
category: 'utilities',
exports: ['mapToArray'],
},
truncate: {
category: "utilities",
exports: ["truncate"],
category: 'utilities',
exports: ['truncate'],
},
"array-sum": {
category: "utilities",
exports: ["arraySum"],
'array-sum': {
category: 'utilities',
exports: ['arraySum'],
},
sleep: {
category: "utilities",
exports: ["sleep"],
category: 'utilities',
exports: ['sleep'],
},
};

Expand Down
Loading