Skip to content

Commit 34dad80

Browse files
committed
Replace standard with prettier, xo
1 parent 667e11a commit 34dad80

File tree

6 files changed

+55
-32
lines changed

6 files changed

+55
-32
lines changed

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage/
2+
*.md

example.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
var remark = require('remark')
2-
var find = require('./index.js')
1+
const remark = require('remark')
2+
const find = require('./index.js')
33

44
remark()
55
.use(function () {
66
return function (tree) {
7-
// string condition
7+
// String condition
88
console.log(find(tree, 'value'))
99

10-
// object condition
11-
console.log(find(tree, { value: 'emphasis' }))
10+
// Object condition
11+
console.log(find(tree, {value: 'emphasis'}))
1212

13-
// function condition
14-
console.log(find(tree, function (node) {
15-
return node.type === 'inlineCode'
16-
}))
13+
// Function condition
14+
console.log(
15+
find(tree, function (node) {
16+
return node.type === 'inlineCode'
17+
})
18+
)
1719
}
1820
})
1921
.processSync('Some _emphasis_, **strongness**, and `code`.')

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
* Finds first node for which function returns true when passed node as argument.
1616
*/
1717

18-
var visit = require('unist-util-visit')
19-
var iteratee = require('lodash.iteratee')
18+
const visit = require('unist-util-visit')
19+
const iteratee = require('lodash.iteratee')
20+
21+
module.exports = find
2022

2123
/**
2224
* Unist node finder utility.
@@ -29,7 +31,7 @@ var iteratee = require('lodash.iteratee')
2931
* The first node that matches condition, or undefined if no node matches.
3032
* @type {<V extends Node>(tree: Node, condition: TestStr | TestObj | TestFn) => V | undefined}
3133
*/
32-
module.exports = function find (tree, condition) {
34+
function find(tree, condition) {
3335
if (!tree) throw new Error('unist-util-find requires a tree to search')
3436
if (!condition) throw new Error('unist-util-find requires a condition')
3537

package.json

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"sideEffects": false,
1313
"scripts": {
1414
"prepack": "npm run build",
15-
"test": "standard && node test.js",
15+
"format": "prettier . -w --loglevel warn && xo --fix",
16+
"test-api": "node --conditions development test.js",
17+
"test": "npm run format && npm run test-api",
1618
"build": "tsc"
1719
},
1820
"type": "commonjs",
@@ -32,13 +34,28 @@
3234
"devDependencies": {
3335
"@types/lodash.iteratee": "^4.7.7",
3436
"@types/unist": "^2.0.6",
37+
"prettier": "^2.0.0",
3538
"remark": "^13.0.0",
36-
"standard": "^8.0.0",
3739
"tape": "^5.3.1",
38-
"typescript": "^4.6.4"
40+
"typescript": "^4.6.4",
41+
"xo": "^0.54.0"
3942
},
4043
"dependencies": {
4144
"lodash.iteratee": "^4.7.0",
4245
"unist-util-visit": "^2.0.0"
46+
},
47+
"prettier": {
48+
"bracketSpacing": false,
49+
"semi": false,
50+
"singleQuote": true,
51+
"tabWidth": 2,
52+
"trailingComma": "none",
53+
"useTabs": false
54+
},
55+
"xo": {
56+
"rules": {
57+
"unicorn/prefer-module": "off"
58+
},
59+
"prettier": true
4360
}
4461
}

test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var test = require('tape')
2-
var remark = require('remark')
3-
var find = require('./index.js')
1+
const test = require('tape')
2+
const remark = require('remark')
3+
const find = require('./index.js')
44

55
test('unist-find', function (t) {
66
const tree = remark().parse('Some _emphasis_, **strongness**, and `code`.')
@@ -22,7 +22,7 @@ test('unist-find', function (t) {
2222
})
2323

2424
t.test('should find with object condition', function (st) {
25-
const result = find(tree, { type: 'emphasis' })
25+
const result = find(tree, {type: 'emphasis'})
2626

2727
st.equal(result, tree.children[0].children[1])
2828

tsconfig.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"compilerOptions": {
3-
"target": "ES2020",
4-
"module": "ES2020",
5-
"moduleResolution": "node",
6-
"strict": true,
7-
"allowJs": true,
8-
"checkJs": true,
9-
"allowSyntheticDefaultImports": true,
10-
"declaration": true,
11-
"emitDeclarationOnly": true,
12-
"skipLibCheck": true
13-
},
14-
"include": ["index.js"]
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"module": "ES2020",
5+
"moduleResolution": "node",
6+
"strict": true,
7+
"allowJs": true,
8+
"checkJs": true,
9+
"allowSyntheticDefaultImports": true,
10+
"declaration": true,
11+
"emitDeclarationOnly": true,
12+
"skipLibCheck": true
13+
},
14+
"include": ["index.js"]
1515
}

0 commit comments

Comments
 (0)