Skip to content

Commit 72520ff

Browse files
lukekarryswraithgar
authored andcommitted
feat: remove standard from package.json
1 parent c393e77 commit 72520ff

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

lib/postinstall/update-package.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ const patchPackage = async (path, root, config) => {
7979
if (pkg.content.templateVersion) {
8080
update.templateVersion = undefined
8181
}
82+
if (pkg.content.scripts && pkg.content.scripts['lint:fix']) {
83+
// some old packages using standard had a lint:fix script
84+
delete update.scripts['lint:fix']
85+
}
86+
if (pkg.content.standard) {
87+
// remove standard configuration if it exists
88+
update.standard = undefined
89+
}
8290
}
8391

8492
pkg.update(update)

lib/postlint/check-package.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const unwantedPackages = [
66
'eslint-plugin-promise',
77
'eslint-plugin-standard',
88
'eslint-plugin-import',
9+
'standard',
910
]
1011

1112
const hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)

tap-snapshots/test/postlint/check-package.js.test.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ Array [
7878
eslint-plugin-promise
7979
eslint-plugin-standard
8080
eslint-plugin-import
81+
standard
8182
),
82-
"solution": "npm rm @npmcli/lint eslint-plugin-promise eslint-plugin-standard eslint-plugin-import",
83+
"solution": "npm rm @npmcli/lint eslint-plugin-promise eslint-plugin-standard eslint-plugin-import standard",
8384
},
8485
]
8586
`

test/postinstall/update-package.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,29 @@ t.test('converts template Version', async (t) => {
161161
t.equal(contents.templateVersion, undefined, 'did not get template version')
162162
t.equal(contents.templateOSS.version, TEMPLATE_VERSION, 'did not get template version')
163163
})
164+
165+
t.test('removes standard', async (t) => {
166+
const pkg = {
167+
name: 'testpkg',
168+
scripts: {
169+
test: 'test',
170+
'lint:fix': 'something',
171+
},
172+
standard: {
173+
ignore: [],
174+
},
175+
}
176+
177+
const project = t.testdir({
178+
'package.json': JSON.stringify(pkg, null, 2),
179+
})
180+
181+
const needsAction = await patchPackage(project)
182+
t.equal(needsAction, true, 'needs action')
183+
184+
const contents = JSON.parse(await fs.readFile(join(project, 'package.json'), {
185+
encoding: 'utf8',
186+
}))
187+
t.equal(contents.standard, undefined, 'removed standard')
188+
t.equal(contents.scripts['lint:fix'], undefined, 'removes lint:fix script')
189+
})

0 commit comments

Comments
 (0)