Skip to content

Commit

Permalink
refactor: to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
cossssmin committed Feb 26, 2024
1 parent b33a93f commit e84744b
Show file tree
Hide file tree
Showing 11 changed files with 6,998 additions and 12,929 deletions.
23 changes: 23 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2023
},
"plugins": ["@typescript-eslint"],
"rules": {
"indent": [2, 2, {"SwitchCase": 1}],
"quotes": [2, "single"],
"linebreak-style": [2, "unix"],
"camelcase": [2, {"properties": "always"}],
"brace-style": [2, "1tbs", {"allowSingleLine": true}]
},
"env": {
"es6": true,
"node": true,
"browser": false
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
]
}
9 changes: 4 additions & 5 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@ on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14, 16, 18]
node-version: [18, 20]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm ci
- run: npm test
env:
CI: true
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export type PluginOptions = {
/**
The name of the tag for the plugin to use.
@default 'outlook'
@example
```js
import posthtml from 'posthtml'
import posthtmlMso from 'posthtml-mso'
const html = `
<mso only="2013">Show in Outlook 2013</mso>
<not-mso>Hide from Outlook</not-mso>
`
posthtml([
posthtmlMso({tag: 'mso'})
])
.process(html)
.then(result => console.log(result.html))
// Result:
// <!--[if mso 15]>Show in Outlook 2013<![endif]-->
// <!--[if !mso]><!-->Hide from Outlook<!--<![endif]-->
```
*/
tag?: string;
};
8 changes: 4 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
'use strict'

module.exports = (options = {}) => tree => {
const plugin = (options = {}) => tree => {
options.tag = options.tag || 'outlook'

const attributes = ['only', 'not', 'lt', 'lte', 'gt', 'gte']
Expand All @@ -24,7 +22,7 @@ module.exports = (options = {}) => tree => {
return node
}

// Uknown tag, skip and return content
// Unknown tag, skip and return content
if (node.tag !== options.tag) {
return node
}
Expand Down Expand Up @@ -149,3 +147,5 @@ const arraysMatch = (first, second) => {

return true
}

export default plugin
Loading

0 comments on commit e84744b

Please sign in to comment.