-
Notifications
You must be signed in to change notification settings - Fork 889
Conversation
Will update the PR. It should merge the whole config. Not just the Do you want it to be done directly in |
Move extends logic into Test is skipped right now because I don't know how to get the config copied and referenced. |
Currently it should support relative path. Once this is okey from you then I will code for array and package support. |
Updated to support package and array. Definitely need testing |
Thanks for the PR @unional! I haven't reviewed the code, but I like the |
Please take a look at the PR when you have time. While the test passed, when I try to use it using Haven't test directly with |
} | ||
let parentRules = parentConfig.rules; | ||
if (parentRules) { | ||
for (let name in parentRules) { |
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.
We prefer for (const name of Object.keys(parentRules)) {
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.
Yes
@jkillian , what would you suggest in adding test? You can see in https://github.com/palantir/tslint/pull/1016/files#diff-7adcebcb9ab1532bda827cc5be7bc94bR6, I'm routing back to the test source for the config file. Any suggestion? |
Well, the cwd for the tests should be the root of the project, so instead of doing As far as testing with a package, I think the easiest solution will be to make a super-simple npm package and list it as a devDependency instead of trying to make a fake npm package somewhere. |
That doesn't work because the |
I have one ready. |
But |
The Update: You are correct. it does start at root. 👍 |
What's your opinion on |
Don't have to review code at the moment. Found bugs. Since I can now run tests, I'll get them all work and do a rebase. Will ping you soon. 🌹 |
Probably better to not do this I'd say |
Alrighty. |
Tests in, passed. Code rebased. Ready to go! @jkillian |
let packageJson = JSON.parse(fileData); | ||
return path.resolve(`node_modules/${relativeFilePath}/${packageJson.main}`); | ||
} else { | ||
return path.resolve(relativeTo, relativeFilePath); |
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.
Do you want to change this to:
return getRelativePath(relativeFilePath, relativeTo);
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.
Sure, let's use that instead
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.
ok
With this in, custom rules could be published as // tslint-eslint-rules -> tslint-config-eslint
// main: tslint.json
{
"rulesDirectory": "./<local rule relative path>",
"rules": {
// Can add default rules value here, and
// disable conflicting core rules if needed.
}
} |
Build failing because |
Feel free to just add that as a dependency and use it. I'm not sure how the legal technicalities work of copying code form an MIT-licensed project into an Apache licensed one |
Also, I like how simple & clean this code is ending up for such a powerful feature! This will be a great PR once it gets merged in |
Ok What you think on the exception message for resolve? |
Also, for the typings for |
Maybe something like this: Error: Invalid "extends" configuration value - could not require "some-invalid-path". Review the Node lookup algorithm (https://nodejs.org/api/modules.html#modules_all_together) for the approximate method TSLint uses to find the referenced configuration file.
Seems like a good solution to me, just drop it in |
Ok. I drop the file under Should be good to go V2! |
@@ -78,7 +79,7 @@ export function findConfiguration(configFile: string, inputFilePath: string): IC | |||
/** | |||
* Searches for a TSLint configuration and returns the path to it. | |||
* Could return undefined if not configuration is found. | |||
* @param suppliedConfigFilePath A path to an known config file supplied by a user. Pass null here if | |||
* @param suppliedConfigFilePath A path to an know``n config file supplied by a user. Pass null here if |
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.
stray ``
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.
Ouch
UPDATE: DONE!
Sweet! Comments I left are just minor style things, I'll make the tweaks in a follow-up PR if you don't have a chance to do it yourself. Also, can you squash this into one commit now? |
Sure |
Regarding the I don't know if you aware of microsoft/TypeScript#7398. There may be problem in the future. Just want to bring it up to your attention. |
🎈 🎉 |
I wrote a little post about this: http://palantir.github.io/tslint/2016/03/31/sharable-configurations-rules.html Does it all seem correct to you @unional? |
Seems like you go all the way to the complex scenario. 😄 The simplest case would be: // package.json
{
"main": "tslint.json" // or any json file
} // tslint.json
{
"rulesDirectory": "./rules",
"rules": {
// default values
}
} Then if you want to extend from someone else, just change your // tslint.json
{
"extends": "some-other-package",
"rulesDirectory": "./rules",
"rules": {
// my rules default
// overriding `some-other-package` defaults
}
} |
In your example you are suggesting the package authors to share multiple configs. It is powerful, but it is also more advanced. 🌹 |
So you may organize the post into three sections:
My two cents. |
I want to add some test in but don't know how. I have added a config.json file. Can you give me some pointers?
Also, please comment on the name and location of the functions.
I can adjust accordingly.
edit from @adidahiya: closes #997