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

Create a speccy.yml Config File for common options #93

Closed
wants to merge 4 commits into from

Conversation

dangoosby
Copy link
Contributor

No description provided.

@philsturgeon
Copy link
Contributor

This PR only seems to cover the rules config option, but ignores all the options we have in the sample file. What about enabling the--json-schema switch through setting jsonSchema: true, etc?

I know there are a lot of options, but we talked about how each of them should be able to be set in the config file... and this PR doesn't do any of that.

lint.js Outdated
@@ -80,10 +85,14 @@ More information: https://speccy.io/rules/#${rule.name}

const command = async (file, cmd) => {
const verbose = cmd.quiet ? 1 : cmd.verbose;
let rules = [].concat(cmd.rules);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to concat a single array with itself. This is just making a copy as there is only one array there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

lint.js Outdated

linter.initialize();

await loader.loadRuleFiles(cmd.rules, { verbose });
if(fs.existsSync(process.env["NODE_CONFIG_DIR"] + "/default.yml")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is what you were doing before, and we moved away from it. You dont need to check for the existance of a config file, just let rules = [].concat(cmd.rules, config.get('lint.rules')); and if there is no config file there will be no rules!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I overlooked the config.has() method and incorrectly compensated for the resulting errors. That has been corrected.

const rules = config.get('lint.rules');

it('gets rules', () => {
if(rules);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is not doing anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@coveralls
Copy link

Coverage Status

Coverage remained the same at 72.835% when pulling ecf3ad1 on feature/speccy-config into 52f812e on master.

@coveralls
Copy link

coveralls commented Jun 23, 2018

Coverage Status

Coverage remained the same at 72.835% when pulling 8316a5e on feature/speccy-config into 52f812e on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 72.835% when pulling ecf3ad1 on feature/speccy-config into 52f812e on master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 72.835% when pulling ecf3ad1 on feature/speccy-config into 52f812e on master.

@@ -40,6 +46,12 @@ const command = async (specFile, cmd) => {
verbose
});

let port = cmd.port;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cli interface should probably override given config file values, not the other way around.

This does make things a bit tricky trying to do it in the command files, because cmd.port has a default value, set in speccy.js

This means that instead of just doing something simple like this:

const port = config.get('serve.port') || cmd.port;

... we'd need to use config.get() in speccy.js and use it to define the default values.

That might look like this in speccy.js:

.option('-p, --port [value]', 'port on which the server will listen', config.get('serve.port') || 5000)

This means the CLI option is used if provided, then serve.port is inspected. If no value is set, it'll use 5000 as the default port!

Similar stuff will have to be done for the other options too.

@philsturgeon philsturgeon changed the title added loading lint rules from config file via node-config package and… Create a speccy.yml Config File for common options Jul 5, 2018
@philsturgeon
Copy link
Contributor

Closing in favour of #102. Thanks for the prototype and hard work on this!

@philsturgeon philsturgeon mentioned this pull request Jul 6, 2018
@philsturgeon philsturgeon deleted the feature/speccy-config branch November 15, 2018 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants