question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Require "standard" field in package.json

See original GitHub issue

Bringing this proposal over from a twitter thread: https://twitter.com/anandthakker/status/776252795972362241

I quite like standard (the rules). My only problem with standard (the tool) is that it makes it difficult to get automatic, in-editor linter errors when switching between OSS projects (most of which I don’t control) that do/don’t use standard. There are, for the most part, three main cases:

  1. Project uses standard
  2. Project uses eslint, and contains an .eslintrc (or maybe an eslintConfig property in package.json)
  3. Project uses neither

I’d be okay setting up vim to inspect the current project and pick, eslint or standard accordingly. However, my (main) issue is that there isn’t a great way to distinguish between cases 1 and 3: if I just default to standard when there’s no .eslintrc, then I get stuck with a bunch of spurious lint errors in projects that use some other linter (or don’t use one at all).

@feross What do you think about the idea of having standard require the standard property in package.json? My reasoning is that this (a) enforces a reliable way to programmatically determine whether a project uses standard and (b) is a very low burden to comply with (standard could even add the field on install?)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
LinusUcommented, Sep 15, 2016

It’s already in there:

readJsonFile('package.json').then(res => {
  return (res.devDependencies && res.devDependencies.standard)
})

I don’t think forcing everyone to add a standard property to the package.json would be a good idea at all. Will you not be able to use standard to lint standalone files anymore then? Or a subdirectory?

It takes away the beauty of standard, which is that I don’t have configure anything at all. I only need to do the very bare minimum (installing a package, adding to scripts.test), I don’t want to be forced to do anything more.

2reactions
ferosscommented, Sep 15, 2016

@anandthakker I sympathize. Turning on and off the standard linter in your text editor can get tedious.

I need a reliable way to programmatically determine whether a project uses standard

I would check for standard in devDependencies. That is going to be super reliable, and doesn’t require any changes to the way we handle the package.json configuration.

Honestly, the "standard" property in package.json is just a hack to make things a bit easier for larger projects transitioning to standard by offering things like ignoring folders, using an env, or defining some globals. Ideally, these aren’t needed at all.

IMO, the presence of the "standard" field in package.json is a sign that something isn’t ideal about your standard usage. The ideal is no configuration. Right now, the number one reason people configure standard is to set babel-eslint as their parser, but eslint is getting ES7 support very soon, so this reason will soon go away!

Read more comments on GitHub >

github_iconTop Results From Across the Web

package.json - npm Docs
json are the name and version fields as they will be required. The name and version together form an identifier that is assumed...
Read more >
The Basics of Package.json - NodeSource
In this chapter, we'll give you a kickstart introduction to effectively using package.json with Node.js and npm . The package.json file is ...
Read more >
Add custom metadata or config to package.json, is it valid?
Yes, you're allowed to add custom entries to package.json . Choose a key name: not already defined (details below); not reserved for future...
Read more >
Not using "main" and other common package.json fields by ...
The main / module / browser fields in package.json should be ignored by default. Using them could be behind a cli flag, or...
Read more >
package.xml -- standard fields aren't supported, including ...
When one of our 30 day trials ends, I want to be able to run something like "force export" and get everything I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found