-
-
Notifications
You must be signed in to change notification settings - Fork 9
Update rcs core #44
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
Update rcs core #44
Conversation
Don't allow non JSX file to run with JSX arguments
I need help here, I don't know how to solve travis's report here. How to do this ? |
True, that's why I am not releasing a stable version of {
"dependencies": {
// locking the version
"rcs-core": "^3.0.0-alpha.0",
// locking the tag
"rcs-core": "next",
// locking the branch of github
"rcs-core": "github:JPeer264/node-rcs-core#master",
// locking any commit
"rcs-core": "github:JPeer264/node-rcs-core#2815d48e6caa619a7cb38a5d014af7b762e6de6f"
}
} But I would suggest to lock down the version in this case. I will release an alpha version of |
lib/process/replaceData.js
Outdated
if ( | ||
options.type === 'js' || | ||
( | ||
options.type === 'auto' && | ||
fileExt.js.includes(path.extname(filePath)) | ||
) | ||
) { | ||
data = rcs.replace.js(fileData, options.parserOptions); | ||
// eslint-disable-next-line no-param-reassign |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it still works without this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will try. I don't know since I can't run test on my side.
c809454
to
e17bf3a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes, plus I think my linting is not included into travis, I will update that. There might be some problems of the linter as well.
lib/config/config.js
Outdated
} | ||
return false; | ||
} | ||
}; // /include |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you remove ; // /include
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/config/config.js
Outdated
} | ||
}; // /include | ||
|
||
module.exports = new Config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't know how that works, also I've never seen it. Could you add the parentheses to the class new Config();
You know if there are any differences between new Config
and new Config()
, just curious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's valid JS if there is not parameter to the constructor. The linter usually refuse it because it can lead to code like this: new Date.toString()
which tries to invoke toString as the constructor of some object Date
. It's usually not the developer intention. I'm changing it to be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah well, thanks for the answer. That makes sense :)
package.json
Outdated
"universalify": "^0.1.2" | ||
"rcs-core": "^3.0.0-alpha.0", | ||
"universalify": "^0.1.2", | ||
"yarn": "^1.17.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not add yarn
as dependency :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either install yarn
with homebrew
(if you are on a mac) or install it globally via npm. I might switch fully to plain npm anyways soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I used to use npm
and when I've tried install yarn, it shouted that we shouldn't mix package manager, so I've removed the lock file and forgot to check the package.json
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, all good.
Should be OK now. I've fixed all original code that choked with the linter too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just saw two things - last changes then it's ready to merge :)
lib/config/config.js
Outdated
@@ -32,13 +32,13 @@ class Config { | |||
} | |||
|
|||
isIgnored(filePath) { | |||
for (let i = 0; i < this.ignorePatterns.length; i++) { | |||
for (let i = 0; i < this.ignorePatterns.length; i += 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just saw this now. Could you change this method to following:
isIgnored(filePath) {
return this.ignorePatterns.some(pattern => minimatch(filePath, pattern);
}
lib/mapping/loadMapping.js
Outdated
@@ -2,38 +2,47 @@ const merge = require('lodash.merge'); | |||
const rcs = require('rcs-core'); | |||
const json = require('json-extra'); | |||
|
|||
const loadMapping = (pathString, options) => { | |||
function loadReversed(selectors) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here please change to following:
const loadReversed = selectors => (
Object.entries(selectors).reduce((prev, [key, value]) => ({
...prev,
[key.charAt(0) + value]: key.slice(1, key.length),
}), {})
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. ava or nyc does not accept object destructuring IIRC (I had to use _.merge
instead).
Not sure it's more understandable this way anyway.
I'm going to do something in between without reduce
Edit: Yep, it does not work:
SyntaxError: /Users/cyril/esp/node-rename-css-selectors/lib/mapping/loadMapping.js: Unexpected token (7:4)
5 | const loadReversed = selectors => (
6 | Object.entries(selectors).reduce((prev, [key, value]) => ({
> 7 | ...prev,
| ^
8 | [key.charAt(0) + value]: key.slice(1, key.length),
9 | }), {}));
10 |
at Parser.pp$5.raise (/Users/cyril/esp/node-rename-css-selectors/node_modules/babylon/lib/index.js:4454:13)
at Parser.pp.unexpected (/Users/cyril/esp/node-rename-css-selectors/node_modules/babylon/lib/index.js:1761:8)
at Parser.pp$3.parseIdentifier (/Users/cyril/esp/node-rename-css-selectors/node_modules/babylon/lib/index.js:4332:10)
at Parser.pp$3.parsePropertyName (/Users/cyril/esp/node-rename-css-selectors/node_modules/babylon/lib/index.js:4156:96)
at Parser.pp$3.parseObj (/Users/cyril/esp/node-rename-css-selectors/node_modules/babylon/lib/index.js:4045:12)
Let me know if it's ok for you this way. It's seem easier to read IMHO. |
I released |
* Update code to support changes in RCS core * Add support for true options from config file. Don't allow non JSX file to run with JSX arguments * Chore: install rcs-core@next * Fix all tests to run with the changes * Improve code coverage * Make linter happy! * Fix requested changes Co-authored-by: Jan Peer Stöcklmair <jan.oster94@gmail.com>
Hi! Not sure why it's in a patch update of the rename-css-selectors |
Uff thats really bad. So "just" JS files are breaking? It's in a patch as it shouldn't break the usage of rcs. I'm gonna invest in this asap! |
Btw which kinda errors are you getting? JS files are being replaced wrongly or you JS files where you use rcs are breaking? E.g. some methods are not found? |
FYI. I unpublished 3.2.6 and released 3.2.7 which is the same as 3.2.5, so nobody should experience any issues for now, until we solved the problem with the new rcs-core. |
Thanks! |
Can you give the example code that breaks (before and after transform) ? Thanks. |
@klimashkin It'll be hard to fix if you don't give us more details. Can you give (part of) the source JS code and the compiled JS code that has broken? Thanks. |
@klimashkin could you try v |
This update the code to work with version 3 of rcs-core.
It adds ignore feature to config file, so it's possible to ignore minified files (like those coming from external libraries)
It also adds source line tracking so generated warning are meaningful (to be used with rcs-core#94)