Skip to content

Commit 05ce5ae

Browse files
committed
refactor: use biome instead of eslint
1 parent 3f90ff3 commit 05ce5ae

File tree

6 files changed

+515
-2255
lines changed

6 files changed

+515
-2255
lines changed

.eslintrc

Lines changed: 0 additions & 23 deletions
This file was deleted.

biome.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"linter": {
7+
"enabled": true,
8+
"rules": {
9+
"recommended": true
10+
}
11+
}
12+
}

lib/index.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import postcss from 'postcss'
22
import merge from 'lodash.merge'
33
import isUrl from 'is-url-superb'
4-
import {walk} from 'posthtml/lib/api.js'
5-
import {parseSrcset, stringifySrcset} from 'srcset'
4+
import { walk } from 'posthtml/lib/api.js'
5+
import { parseSrcset, stringifySrcset } from 'srcset'
66
import postcssBaseUrl from './plugins/postcss-baseurl.js'
77

88
const defaultTags = {
@@ -94,30 +94,31 @@ const plugin = (options = {}) => tree => {
9494
}
9595

9696
// Handle style attribute
97-
if (node.attrs && node.attrs.style && options.inlineCss) {
97+
if (node.attrs?.style && options.inlineCss) {
9898
node.attrs.style = prependUrl(node.attrs.style, options.url)
9999
}
100100

101101
// Handle defined HTML attributes
102-
Object.entries(options.attributes).forEach(([attribute, value]) => {
103-
if (node.attrs && node.attrs[attribute]) {
102+
for (const [attribute, value] of Object.entries(options.attributes)) {
103+
if (node.attrs?.[attribute]) {
104104
handleSingleValueAttributes(node, attribute, value)
105105
}
106-
})
106+
}
107107

108108
// Handle defined HTML tags
109109
const tags = Array.isArray(options.tags) ?
110110
Object.entries(defaultTags).filter(([tag]) => options.tags.includes(tag)) :
111111
Object.entries(options.tags)
112112

113+
// biome-ignore lint: fails with for...of
113114
tags.forEach(([tag, attributes]) => {
114115
if (node.tag !== tag) {
115116
return node
116117
}
117118

118119
// Handle tag attributes
119-
Object.entries(attributes).forEach(([attribute, value]) => {
120-
if (node.attrs && node.attrs[attribute]) {
120+
for (const [attribute, value] of Object.entries(attributes)) {
121+
if (node.attrs?.[attribute]) {
121122
// Handle "single-value" attributes
122123
if (['href', 'src', 'poster', 'background'].includes(attribute)) {
123124
handleSingleValueAttributes(node, attribute, value)
@@ -138,7 +139,7 @@ const plugin = (options = {}) => tree => {
138139
node.attrs[attribute] = stringifySrcset(parsed)
139140
}
140141
}
141-
})
142+
}
142143
})
143144

144145
// Return the node

0 commit comments

Comments
 (0)