Skip to content

Commit b185f4d

Browse files
committed
chore: use eslint plugin for preventing externals/builtins
1 parent d0a105e commit b185f4d

File tree

5 files changed

+44
-34
lines changed

5 files changed

+44
-34
lines changed

.eslintrc.local.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
'use strict'
2+
3+
module.exports = {
4+
plugins: ['import'],
5+
rules: {
6+
'import/no-extraneous-dependencies': [
7+
'error',
8+
{
9+
devDependencies: false,
10+
optionalDependencies: false,
11+
peerDependencies: false,
12+
bundledDependencies: false,
13+
includeInternal: true,
14+
},
15+
],
16+
'import/no-nodejs-modules': ['error'],
17+
},
18+
overrides: [
19+
{
20+
files: ['**/test/**', '.eslintrc.js', '.eslintrc.local.js'],
21+
rules: {
22+
'import/no-extraneous-dependencies': 0,
23+
'import/no-nodejs-modules': 0,
24+
},
25+
},
26+
],
27+
}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@
3333
!/SECURITY.md
3434
!/tap-snapshots/
3535
!/test/
36-
!/rollup.config.js

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"description": "The semantic version parser used by npm.",
55
"main": "index.js",
66
"scripts": {
7-
"test": "tap && npm run check-self-contained",
7+
"test": "tap",
88
"snap": "tap",
9-
"check-self-contained": "rollup -c --silent > /dev/null",
109
"lint": "eslint \"**/*.js\"",
1110
"postlint": "template-oss-check",
1211
"lintfix": "npm run lint -- --fix",
@@ -16,8 +15,7 @@
1615
"devDependencies": {
1716
"@npmcli/eslint-config": "^4.0.0",
1817
"@npmcli/template-oss": "4.14.1",
19-
"@rollup/plugin-commonjs": "^24.1.0",
20-
"rollup": "^3.21.5",
18+
"eslint-plugin-import": "^2.27.5",
2119
"tap": "^16.0.0"
2220
},
2321
"license": "ISC",

rollup.config.js

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

test/map.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,28 @@ const ignore = [
1111
'tap-snapshots',
1212
'test',
1313
'fixtures',
14-
'rollup.config.js',
1514
]
1615

1716
const { statSync, readdirSync } = require('fs')
1817
const find = (folder, set = [], root = true) => {
1918
const ent = readdirSync(folder)
20-
set.push(...ent.filter(f => !ignore.includes(f) && /\.m?js$/.test(f)).map(f => folder + '/' + f))
21-
for (const e of ent.filter(f => !ignore.includes(f) && !/\.m?js$/.test(f))) {
19+
set.push(
20+
...ent
21+
.filter((f) => !ignore.includes(f) && /\.m?js$/.test(f))
22+
.map((f) => folder + '/' + f)
23+
)
24+
for (const e of ent.filter(
25+
(f) => !ignore.includes(f) && !/\.m?js$/.test(f)
26+
)) {
2227
if (statSync(folder + '/' + e).isDirectory()) {
2328
find(folder + '/' + e, set, false)
2429
}
2530
}
2631
if (!root) {
2732
return
2833
}
29-
return set.map(f => f.slice(folder.length + 1)
30-
.replace(/\\/g, '/'))
34+
return set
35+
.map((f) => f.slice(folder.length + 1).replace(/\\/g, '/'))
3136
.sort((a, b) => a.localeCompare(b))
3237
}
3338

@@ -40,10 +45,13 @@ t.strictSame(sut, tests, 'test files should match system files')
4045
const map = require('../map.js')
4146

4247
for (const testFile of tests) {
43-
t.test(testFile, t => {
48+
t.test(testFile, (t) => {
4449
t.plan(1)
4550
// cast to an array, since map() can return a string or array
4651
const systemFiles = [].concat(map(testFile))
47-
t.ok(systemFiles.some(sys => sut.includes(sys)), 'test covers a file')
52+
t.ok(
53+
systemFiles.some((sys) => sut.includes(sys)),
54+
'test covers a file'
55+
)
4856
})
4957
}

0 commit comments

Comments
 (0)