diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..07f6b38 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +lib +docs \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index 1d2a182..72c4429 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,3 +1 @@ - -npm run build npm test diff --git a/fixtures/Foo.mist.tsx b/fixtures/Foo.mist.tsx index 3202d29..ccd0f29 100644 --- a/fixtures/Foo.mist.tsx +++ b/fixtures/Foo.mist.tsx @@ -1,7 +1,7 @@ // Generated by MistCSS, do not modify import './Foo.mist.css' -import type { JSX, ReactNode } from 'react'; +import type { JSX, ReactNode } from 'react' type FooProps = { children?: ReactNode diff --git a/package-lock.json b/package-lock.json index 190addb..d0c6998 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,6 +28,7 @@ "prettier": "^3.2.5", "stylelint": "^16.2.1", "stylelint-config-standard": "^36.0.0", + "tsx": "^4.7.1", "typescript": "^5.3.3", "vitepress": "^1.0.0-rc.44" } @@ -2902,6 +2903,18 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/get-tsconfig": { + "version": "4.7.3", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.7.3.tgz", + "integrity": "sha512-ZvkrzoUA0PQZM6fy6+/Hce561s+faD1rsNwhnO5FelNjyy7EMGJ3Rz1AQ8GYDWjhRs/7dBLOEJvhK8MiEJOAFg==", + "dev": true, + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, "node_modules/glob": { "version": "10.3.10", "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.10.tgz", @@ -3802,6 +3815,15 @@ "node": ">=8" } }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, "node_modules/reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", @@ -4405,6 +4427,25 @@ "typescript": ">=4.2.0" } }, + "node_modules/tsx": { + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.7.1.tgz", + "integrity": "sha512-8d6VuibXHtlN5E3zFkgY8u4DX7Y3Z27zvvPKVmLon/D4AjuKzarkUBTLDBgj9iTQ0hg5xM7c/mYiRVM+HETf0g==", + "dev": true, + "dependencies": { + "esbuild": "~0.19.10", + "get-tsconfig": "^4.7.2" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", diff --git a/package.json b/package.json index 120f17b..c3ce8a7 100644 --- a/package.json +++ b/package.json @@ -9,10 +9,10 @@ "scripts": { "build": "rm -rf lib && tsc", "format": "prettier --write .", - "lint": "eslint src", + "lint": "eslint", "fixtures:type-check": " tsc -p ./fixtures/tsconfig.json", "fixtures:lint-css": "stylelint './fixtures/**/*.css'", - "test": "npm run build && node --test && npm run fixtures:type-check && npm run fixtures:lint-css", + "test": "npm run build && node --import tsx/esm --test src/*.test.ts && npm run fixtures:type-check && npm run fixtures:lint-css", "prepublishOnly": "npm run build", "docs:dev": "vitepress dev docs", "docs:build": "vitepress build docs", @@ -43,6 +43,7 @@ "prettier": "^3.2.5", "stylelint": "^16.2.1", "stylelint-config-standard": "^36.0.0", + "tsx": "^4.7.1", "typescript": "^5.3.3", "vitepress": "^1.0.0-rc.44" }, diff --git a/src/renderer.ts b/src/renderer.ts index 159c630..ea5ea52 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -52,7 +52,7 @@ export function render(name: string, components: Components): string { return `// Generated by MistCSS, do not modify import './${name}.mist.css' -import type { JSX, ReactNode } from 'react'; +import type { JSX, ReactNode } from 'react' ${Object.keys(components) .map((key) => renderComponent(components, key))