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

Use JSCS preset system instead of generating custom build config. #70

Merged
merged 1 commit into from
Oct 15, 2015

Conversation

rwjblue
Copy link
Collaborator

@rwjblue rwjblue commented Oct 14, 2015

This PR removes the custom config file generation and replaces it with JSCS's built in preset system (thanks to @hzoo for helping push that forward so much!). This removes the need for a custom binary/command (because now jscs command will work properly).

I believe this is backwards compatible (if folks had created a .jscsrc file with our rules in them, they should continue to work just the same). Definitely open to thoughts of how that might be an issue (worst case scenario we can just bump majors, but I'd prefer not to)...

Fixes #64.
Fixes #34.

@@ -0,0 +1 @@
{ "preset": "../../lib/jscsrc.json"}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This lets JSCS find lib/jscsrc.json (which is exactly what a user would get if they did preset: 'ember-suave').

@rwjblue
Copy link
Collaborator Author

rwjblue commented Oct 14, 2015

Note: that I used ember-cli-blueprint-test-helpers to make testing the generated file simple. Thanks to @trabus for his hard work on extracting those helpers.

@elidupuis
Copy link

Just tested this out quickly for my integration with pre-commit and it seems to work great! 👍

@rwjblue
Copy link
Collaborator Author

rwjblue commented Oct 14, 2015

aptible/ember-json-schema-document#1 updates a little addon that was previously using a custom .jscsrc (for editor integrations) and all seems to work well.

@hzoo
Copy link

hzoo commented Oct 14, 2015

maybe add preset or jscs-preset to keywords of package.json?

Btw we're working on 3.0 soon (going to release a bugfix release today) mainly for https://github.com/cst/cst but also other stuff like "verbose": true by default

@rwjblue
Copy link
Collaborator Author

rwjblue commented Oct 14, 2015

@hzoo - Great idea, updated!

@hzoo
Copy link

hzoo commented Oct 14, 2015

How different is ember-suave and the ember .jscsrc anyway? You could potentially use ember-suave as a preset although you would have to manage the versions (well I guess that its true already)

@rwjblue
Copy link
Collaborator Author

rwjblue commented Oct 14, 2015

ember-suave is quite a bit more aggressive than Ember's default JSCS setup (forbidding var, requiring destructuring, etc).

@brzpegasus
Copy link
Contributor

@rwjblue This looks great!! Much cleaner with a preset! Just a few things:

  • Would you mind squashing the commits?
  • I'm happy to merge this. However, I will want to update the README to reflect the changes before releasing.
  • Does this classify as backwards-compatible if the user has to do more than simply upgrade ember-suave in order for it to work? Mainly:
    • They will need to run ember g ember-suave at the very least, after bumping the version (or after automatically getting the updated version when they run npm install if they specified ember-suave with ~ or ^).
    • If the project previously had a custom .jscsrc (which ember-suave was using to merge with the default rules), it would need to be moved out of the way in favor of the .jscsrc file from the blueprint, and then the contents from the old file would need to be merged back in. Otherwise, things will not run out of the box.

@brzpegasus
Copy link
Contributor

If the project previously had a custom .jscsrc, [...] things will not run out of the box.

Here's an example of a custom .jscsrc file that a project may have created, without including all the rules from ember-suave. In other words, the file could have been created only to override some of the rules from ember-suave, but does not otherwise list out all of the rules:

{
  "excludeFiles": ["fixtures/**"],
  "requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
  "requireCommentsToIncludeAccess": null
}

This would stop working after upgrading, without some (minimal) changes.

@rwjblue
Copy link
Collaborator Author

rwjblue commented Oct 15, 2015

Would you mind squashing the commits?

No problem. Done.

I will want to update the README to reflect the changes before releasing.

Agreed. Will get that updated shortly.

They will need to run ember g ember-suave at the very least, after bumping the version (or after automatically getting the updated version when they run npm install if they specified ember-suave with ~ or ^).

It really depends on what we want. It is possible for us to detect that no .jscsrc file is present and print a console warning and provide a custom one for them (essentially bring back the jscsrcBuilder in the case that no .jscsrc file is found).

If the project previously had a custom .jscsrc (which ember-suave was using to merge with the default rules), it would need to be moved out of the way in favor of the .jscsrc file from the blueprint, and then the contents from the old file would need to be merged back in. Otherwise, things will not run out of the box.

Same as above, we could bring back the jscsrcBuilder and have it detect if "preset": "ember-suave" is present in .jscsrc. If it is not present, we would do the current merging behavior with a console warning. If it is present, we do nothing and use their .jscsrc.


It all comes down to what we want. Do we want to have this addon have a nice upgrade path (following Ember's concept of "no major version breakage without prior deprecation") or do we want to make this addon as simple as possible and revv the major version?

@rwjblue rwjblue force-pushed the jscs-presets branch 3 times, most recently from 9128ed2 to bcb22ca Compare October 15, 2015 13:55
}
```

`ember-sauve` integrates well with ember-cli, but can also be used as a standalone JSCS preset. This allows custom
Copy link
Contributor

Choose a reason for hiding this comment

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

s/sauve/suave/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Fixed...

@rwjblue
Copy link
Collaborator Author

rwjblue commented Oct 15, 2015

It all comes down to what we want. Do we want to have this addon have a nice upgrade path (following Ember's concept of "no major version breakage without prior deprecation") or do we want to make this addon as simple as possible and revv the major version?

Damn that stupid Ember project setting good examples.

I updated this to provide deprecation warnings when used in the following scenarios:

  • without a project .jscsrc file
  • with a project .jscsrc file that does not contain "preset": "ember-suave"

All existing scenarios should fall into one of those two deprecations and the current setup is still supported. I think this is not fully backwards compatible. When we decide to bump major versions (likely for JSCS 3.0) we can remove lib/jscsrc-builder.js and tests/jscsrc-builder-test.js.

@brzpegasus
Copy link
Contributor

Damn that stupid Ember project setting good examples.

😛 Was hard arguing against not being a good citizen and providing an upgrade path.

I think this is not fully backwards compatible.

You mean "now fully backwards compatible", right?

}
}

function getSuaveConfig() {
// avoiding `require` (which would have worked fine)
// to prevent mutating the cached result
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@rwjblue
Copy link
Collaborator Author

rwjblue commented Oct 15, 2015

You mean "now fully backwards compatible", right?

LOL, yes

@rwjblue rwjblue force-pushed the jscs-presets branch 2 times, most recently from 448f844 to 87cb441 Compare October 15, 2015 14:30
@rwjblue
Copy link
Collaborator Author

rwjblue commented Oct 15, 2015

Updated to prevent printing deprecation message twice (once for app tree and once for tests tree). The deprecation messages are now only logged once.

Also, add blueprint and blueprint test.

Now:

```
ember install ember-suave
```

Will auto-generate a `.jscsrc` with `{ "preset": "ember-suave" }`.
@brzpegasus
Copy link
Contributor

Excellent, thanks!! 💯

brzpegasus added a commit that referenced this pull request Oct 15, 2015
Use JSCS preset system instead of generating custom build config.
@brzpegasus brzpegasus merged commit 6a48c95 into DavyJonesLocker:master Oct 15, 2015
@rwjblue rwjblue deleted the jscs-presets branch October 15, 2015 14:44
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.

4 participants