Skip to content

Commit ccec83a

Browse files
authored
feat: usage of ESLint v8 (#274)
BREAKING CHANGE: Similarly to https://github.com/standard/standard/releases/tag/v17.0.0
1 parent a11665f commit ccec83a

File tree

4 files changed

+47
-38
lines changed

4 files changed

+47
-38
lines changed

index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
/*! semistandard. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
2-
// programmatic usage
3-
import engine from 'standard-engine'
4-
import opts from './options.js'
1+
/*! standard. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
2+
import { StandardEngine } from 'standard-engine'
3+
import options from './options.js'
54

6-
const Linter = engine.linter
7-
8-
export default new Linter(opts)
5+
export default new StandardEngine(options)

options.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
import { fileURLToPath } from 'node:url'
21
import { readFileSync } from 'node:fs'
2+
import { fileURLToPath } from 'node:url'
33
import eslint from 'eslint'
44

5-
const pkgUrl = new URL('./package.json', import.meta.url)
6-
const pkg = JSON.parse(readFileSync(pkgUrl, 'utf-8'))
5+
// eslintConfig.overrideConfigFile have problem reading URLs and file:///
6+
const overrideConfigFile = fileURLToPath(new URL('./eslintrc.json', import.meta.url))
7+
const pkgURL = new URL('./package.json', import.meta.url)
8+
const pkgJSON = readFileSync(pkgURL, { encoding: 'utf-8' })
9+
const pkg = JSON.parse(pkgJSON)
710

811
export default {
9-
// cmd, homepage, bugs all pulled from package.json
10-
cmd: 'semistandard',
11-
version: pkg.version,
12-
homepage: pkg.homepage,
1312
bugs: pkg.bugs.url,
14-
tagline: 'Semicolons For All!',
13+
cmd: 'semistandard',
1514
eslint,
1615
eslintConfig: {
17-
configFile: fileURLToPath(new URL('eslintrc.json', import.meta.url))
18-
}
16+
overrideConfigFile
17+
},
18+
homepage: pkg.homepage,
19+
tagline: 'Semicolons For All!',
20+
version: pkg.version
1921
}

package.json

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@
1414
"url": "https://github.com/standard/semistandard/issues"
1515
},
1616
"dependencies": {
17-
"eslint": "^7.32.0",
18-
"eslint-config-semistandard": "16.0.0",
19-
"eslint-config-standard": "16.0.3",
20-
"eslint-config-standard-jsx": "10.0.0",
21-
"eslint-plugin-import": "^2.24.2",
22-
"eslint-plugin-node": "^11.1.0",
23-
"eslint-plugin-promise": "^5.1.0",
24-
"eslint-plugin-react": "~7.25.1",
25-
"standard-engine": "^14.0.1"
17+
"eslint": "^8.20.0",
18+
"eslint-config-semistandard": "^17.0.0",
19+
"eslint-config-standard": "17.0.0",
20+
"eslint-config-standard-jsx": "^11.0.0",
21+
"eslint-plugin-import": "^2.26.0",
22+
"eslint-plugin-n": "^15.2.4",
23+
"eslint-plugin-promise": "^6.0.0",
24+
"eslint-plugin-react": "^7.30.1",
25+
"standard-engine": "^15.0.0"
2626
},
2727
"devDependencies": {
28+
"installed-check": "^6.0.3",
2829
"merge": "^2.1.1",
2930
"mkdirp": "^1.0.4",
3031
"rimraf": "^3.0.2",
@@ -33,7 +34,7 @@
3334
"tape": "^5.3.1"
3435
},
3536
"engines": {
36-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
37+
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
3738
},
3839
"homepage": "https://github.com/standard/semistandard",
3940
"keywords": [
@@ -71,7 +72,7 @@
7172
"url": "https://github.com/standard/semistandard.git"
7273
},
7374
"scripts": {
74-
"test": "standard && tape test/*.js"
75+
"test": "standard && installed-check --engine-check --engine-no-dev && tape test/*.js"
7576
},
7677
"standard": {
7778
"ignore": "tmp/**"

test/api.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,24 @@ import semistandard from '../index.js'
44

55
const filePath = resolve('./bin/cmd.js')
66

7-
test('api usage', function (t) {
8-
t.plan(6)
9-
semistandard.lintFiles(['bin/cmd.js'], {}, function (err, result) {
10-
t.error(err, 'no error while linting')
11-
t.equal(typeof result, 'object', 'result is an object')
12-
t.equal(result.errorCount, 7, 'error count 7')
7+
test('api: lintFiles', async (t) => {
8+
t.plan(5)
9+
const [result] = await semistandard.lintFiles([filePath])
10+
t.equal(typeof result, 'object', 'result is an object')
1311

14-
t.equal(resolve(result.results[0].filePath), filePath, 'error filepath correct')
15-
t.equal(result.results[0].messages[0].message, 'Missing semicolon.', 'first missing semicolon message')
16-
t.equal(result.results[0].messages[0].message, 'Missing semicolon.', 'second missing semicolon message')
17-
})
12+
t.equal(result.errorCount, 7, 'error count 7')
13+
14+
t.equal(resolve(result.filePath), filePath, 'error filepath correct')
15+
t.equal(result.messages[0].message, 'Missing semicolon.', 'first missing semicolon message')
16+
t.equal(result.messages[1].message, 'Missing semicolon.', 'second missing semicolon message')
17+
})
18+
19+
test('api: lintText', async (t) => {
20+
t.plan(4)
21+
const [result] = await semistandard.lintText('console.log("hi there")\n')
22+
23+
t.equal(typeof result, 'object', 'result is an object')
24+
t.equal(result.errorCount, 2, 'error count 2')
25+
t.equal(result.messages[0].message, 'Strings must use singlequote.', 'singlequote message')
26+
t.equal(result.messages[1].message, 'Missing semicolon.', 'missing semicolon message')
1827
})

0 commit comments

Comments
 (0)