Skip to content
This repository has been archived by the owner on Jun 21, 2021. It is now read-only.

Improved config loading allowing more options. #95

Merged
merged 2 commits into from
Apr 25, 2017
Merged

Conversation

Swiftwork
Copy link
Contributor

  • Added configBasedir and config options.
  • Configs can now be loaded from a specified file path or from ".stylelintrc" and "stylelint.config.js".
  • Config can also be specified as objects either in vscode settings or in the package.json.
  • Removed useStylelintConfigOverrides because it became obsolete.

+ Added configBasedir and config options.
+ Configs can now be loaded from a specified file path or from ".stylelintrc" and "stylelint.config.js".
+ Config can also be specified as objects either in vscode settings or in the package.json.
- Removed useStylelintConfigOverrides because it became obsolete.
@Swiftwork
Copy link
Contributor Author

I followed your postcss-sorting plugin and vscode-config-resolver pattern ;)

@mrmlnc mrmlnc self-assigned this Apr 18, 2017
@mrmlnc
Copy link
Owner

mrmlnc commented Apr 18, 2017

Thanks for your work! 💪 I'll review this PR very soon.

Copy link
Owner

@mrmlnc mrmlnc left a comment

Choose a reason for hiding this comment

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

Very good work, but please, correct specified comments. Thanks 👍 🥇

package.json Outdated
@@ -41,10 +41,18 @@
"type": "object",
"title": "stylefmt configuration",
"properties": {
"stylefmt.useStylelintConfigOverrides": {
Copy link
Owner

Choose a reason for hiding this comment

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

I think we should revert this changes, because this feature is related to issue #8.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed

@@ -75,4 +84,4 @@
"build": "npm run clean && npm run lint && npm run compile",
"watch": "npm run clean && npm run lint && npm run compile -- --sourceMap --watch"
}
}
}
Copy link
Owner

@mrmlnc mrmlnc Apr 23, 2017

Choose a reason for hiding this comment

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

Please, add FinalNewLine here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do

src/extension.ts Outdated
editorSettings: settings.config
};

return configResolver.scan(document.uri.fsPath, options).then((resolved) => {
Copy link
Owner

Choose a reason for hiding this comment

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

Here we should merge resolved config and config from stylelint.configOverrides option if stylefmt.useStylelintConfigOverrides option is enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will look into that but sounds reasonable

src/extension.ts Outdated
config: resolved.json
});
}).catch(() => {
return stylefmtProcess(document, range);
Copy link
Owner

@mrmlnc mrmlnc Apr 23, 2017

Choose a reason for hiding this comment

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

I think that we shouldn't work without config. This is abnormal situation and we need to inform the user. You can replace this line on showOutput(err.toString());?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But stylefmt supports usage without config which indicates to me that that is the appropriate behaviour. However it is up to you, else I believe devs should disable the plugin for workspaces where it is not needed.

Copy link
Owner

Choose a reason for hiding this comment

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

Yeap, you win 👍

@mrmlnc
Copy link
Owner

mrmlnc commented Apr 23, 2017

Hello, @Swiftwork, I added a few comments, if you agree with me, then please correct them, if not, then I am ready to discuss them.

@Swiftwork
Copy link
Contributor Author

I made a new commit with the discussed changes :)

Copy link
Owner

@mrmlnc mrmlnc left a comment

Choose a reason for hiding this comment

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

Sorry, but we need to remove extend module 🌵

src/extension.ts Outdated
configBasedir: settings.configBasedir || vscode.workspace.rootPath,
config: resolved.json
configBasedir: settingsFmt.configBasedir || vscode.workspace.rootPath,
config: extend(true, {}, resolved.json, { rules: configOverrides || {} })
Copy link
Owner

Choose a reason for hiding this comment

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

Please, use Object.assign instead of extend module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Issue with Object.assign is that it doesn't deep copy, so nested properties will be lost rather than overwritten. We could write our own extender, but I didn't see the benefit in that.

Copy link
Owner

Choose a reason for hiding this comment

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

Yeap, sorry, i forgot that stylelint has nested config.

@mrmlnc
Copy link
Owner

mrmlnc commented Apr 24, 2017

I'll merge your PR today, but letter 👍 Thanks for your work!

@Swiftwork
Copy link
Contributor Author

You are welcome, now we just need to exact mimic this behaviour on your postcss-sorting plugin and solve formatOnSave :)

@mrmlnc
Copy link
Owner

mrmlnc commented Apr 24, 2017

If you want add more features, please create issues or PRs 💃

@Swiftwork
Copy link
Contributor Author

If I was unclear, I was referring to another of your vscode plugins. No more additions are planned for this PR and it is ready to merge from my side.

@mrmlnc mrmlnc merged commit d772ada into mrmlnc:master Apr 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants