Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Oct 31, 2024
1 parent fc4133f commit 54d9331
Show file tree
Hide file tree
Showing 8 changed files with 518 additions and 449 deletions.
904 changes: 498 additions & 406 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"build": "rm -rf lib && tsc",
"format": "prettier --write .",
"lint": "eslint",
"test": "vitest",
"test:postcss": "postcss test/mist.css",
"test": "postcss test/mist.css",
"prepublishOnly": "npm run build",
"prepare": "husky"
},
Expand All @@ -31,6 +30,7 @@
"postcss-cli": "^11.0.0",
"postcss-import": "^16.1.0",
"prettier": "^3.2.5",
"tsx": "^4.19.2",
"typescript": "^5.3.3",
"vitest": "^1.5.0"
},
Expand Down
11 changes: 5 additions & 6 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import atImport from 'postcss-import'

import plugin from './lib/plugin.js'

export default {
plugins: [atImport, plugin],
module.exports = {
plugins: [
require('postcss-import'),
require('./lib/index.js')({})
]
}
2 changes: 1 addition & 1 deletion src/html.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Ref: lib.dom.d.ts
export const tagToHTMLElement = {
module.exports = {
a: 'HTMLAnchorElement',
abbr: 'HTMLElement',
address: 'HTMLElement',
Expand Down
17 changes: 0 additions & 17 deletions src/index.test.ts

This file was deleted.

16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'node:fs'
import { PluginCreator } from 'postcss'
import selectorParser from 'postcss-selector-parser'
import path from 'node:path'
import { tagToHTMLElement } from './html.js'
import fs = require('node:fs')
import { type PluginCreator } from 'postcss'
import selectorParser = require('postcss-selector-parser');
import path = require('node:path');
const html = require('./html')

declare module 'postcss-selector-parser' {
// For some reasons these aren't avaiblable in this module types
Expand Down Expand Up @@ -34,8 +34,8 @@ function render(parsed: Parsed): string {
const attributeEntries = Object.entries(attributes)

let htmlElement = 'HTMLElement'
if (tag in tagToHTMLElement) {
htmlElement = tagToHTMLElement[tag as keyof typeof tagToHTMLElement]
if (tag in html) {
htmlElement = html[tag as keyof typeof html]
}

let interfaceDefinition = `interface ${interfaceName} extends React.DetailedHTMLProps<React.HTMLAttributes<${htmlElement}>, ${htmlElement}> {\n`
Expand Down Expand Up @@ -104,7 +104,7 @@ function initialParsedValue(): Parsed[keyof Parsed] {
}
}

const mistcss: PluginCreator<{}> = (_opts = {}) => {
export const mistcss: PluginCreator<{}> = (_opts = {}) => {
return {
postcssPlugin: 'mistcss',
Once(root, helper) {
Expand Down
9 changes: 2 additions & 7 deletions test/mist.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
interface Mist_button
extends React.DetailedHTMLProps<
React.HTMLAttributes<HTMLButtonElement>,
HTMLButtonElement
> {
'data-variant': 'primary' | 'secondary'
interface Mist_button extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
'data-variant'?: 'primary' | 'secondary'
}

declare namespace JSX {
interface IntrinsicElements {
button: Mist_button
}
}

4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "@tsconfig/node18/tsconfig.json",
"compilerOptions": {
"outDir": "./lib"
}
"outDir": "./lib",
},
}

0 comments on commit 54d9331

Please sign in to comment.