Skip to content

Commit

Permalink
feat: remove standard from package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys authored and wraithgar committed Feb 17, 2022
1 parent c393e77 commit 72520ff
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/postinstall/update-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ const patchPackage = async (path, root, config) => {
if (pkg.content.templateVersion) {
update.templateVersion = undefined
}
if (pkg.content.scripts && pkg.content.scripts['lint:fix']) {
// some old packages using standard had a lint:fix script
delete update.scripts['lint:fix']
}
if (pkg.content.standard) {
// remove standard configuration if it exists
update.standard = undefined
}
}

pkg.update(update)
Expand Down
1 change: 1 addition & 0 deletions lib/postlint/check-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const unwantedPackages = [
'eslint-plugin-promise',
'eslint-plugin-standard',
'eslint-plugin-import',
'standard',
]

const hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)
Expand Down
3 changes: 2 additions & 1 deletion tap-snapshots/test/postlint/check-package.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ Array [
eslint-plugin-promise
eslint-plugin-standard
eslint-plugin-import
standard
),
"solution": "npm rm @npmcli/lint eslint-plugin-promise eslint-plugin-standard eslint-plugin-import",
"solution": "npm rm @npmcli/lint eslint-plugin-promise eslint-plugin-standard eslint-plugin-import standard",
},
]
`
Expand Down
26 changes: 26 additions & 0 deletions test/postinstall/update-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,29 @@ t.test('converts template Version', async (t) => {
t.equal(contents.templateVersion, undefined, 'did not get template version')
t.equal(contents.templateOSS.version, TEMPLATE_VERSION, 'did not get template version')
})

t.test('removes standard', async (t) => {
const pkg = {
name: 'testpkg',
scripts: {
test: 'test',
'lint:fix': 'something',
},
standard: {
ignore: [],
},
}

const project = t.testdir({
'package.json': JSON.stringify(pkg, null, 2),
})

const needsAction = await patchPackage(project)
t.equal(needsAction, true, 'needs action')

const contents = JSON.parse(await fs.readFile(join(project, 'package.json'), {
encoding: 'utf8',
}))
t.equal(contents.standard, undefined, 'removed standard')
t.equal(contents.scripts['lint:fix'], undefined, 'removes lint:fix script')
})

0 comments on commit 72520ff

Please # to comment.