Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inherit standard configuration from parent package.json #580

Open
timoxley opened this issue Jul 28, 2016 · 2 comments

Comments

@timoxley
Copy link
Contributor

commented Jul 28, 2016

Problem

standard currently does not check directories above cwd for package.json files containing standard configuration.

Example

Say I have A & A/B directories, both with their own package.json files:

A
├── package.json
├── index.js
└── B
    ├── package.json
    └── index.js

Let's suppose B/index.js contains some syntax that requires the babel-eslint parser:

class A {
  // class properties are not supported by vanilla eslint
  static classProperty = 'ok'
}

console.log(A.classProperty)

standard will behave differently depending on what the current directory is:

> cd A
> standard B/index.js && echo 'ok'
ok
> cd B
> standard index.js && echo 'ok'
standard: Use JavaScript Standard Style (http://standardjs.com)
  /Users/timoxley/Projects/tests/standard-config/A/B/index.js:3:24: Parsing error: Unexpected token =

At first, not reading parent directories for configuration does seem like reasonable behaviour, though it differs from that of babel, which finds all the configs in all parents, then merges the results:

https://github.com/babel/babel/blob/210c3f7da92a7bd9b6da8fb57dac38996222fecd/packages/babel-core/src/transformation/file/options/build-config-chain.js#L26

While standard appears to just find the nearest package.json whether it has a "standard" config or not: https://github.com/Flet/standard-engine/blob/9ddbe6cce2dd43f3d888b64aede48ef3190d2e34/index.js#L136

Proposal

I suggest standard should follow the lead of babel here and inherit parent configs. I'd be happy if it just searched up until it found the first "standard" config, but I think perhaps a "standard" for config behaviour across all tools that read config from package.json/.rc files is better than minimalism. Ideally a reusable package could be used for keeping this consistent.

@feross

This comment has been minimized.

Copy link
Member

commented Jul 30, 2016

This sounds reasonable to me.

We currently use find-root to find the nearest package.json. What does babel use?

@timoxley

This comment has been minimized.

@feross feross modified the milestone: standard v9 Aug 19, 2016

@feross feross modified the milestones: standard v10, standard v9 Feb 9, 2017

@feross feross modified the milestones: standard v11, standard v10 Mar 2, 2017

@feross feross modified the milestones: standard v12, standard v13 Aug 28, 2018

@feross feross modified the milestones: standard v13, standard v14 Jul 5, 2019

@feross feross modified the milestones: standard 14, standard 15 Aug 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.