This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
resolve
instead of Node.JS require for resolving configuration …
…files (#1172) * Add `resolve` dependency (and custom typings) * Use resolve instead of require in resolveConfigurationPaths Fixes #1171 * Simplify resolveConfigurationPath `resolve` can handle relative and absolute links. * path-is-absolute is no longer needed. * Install test packages in subdirectory, so they aren't in the scope of the main tslint binary * Run `npm install` in test config directory to install test packages. * Fix code style issue * Add dev dependency on npm for grunt run:installTestDeps task * Revert "Add dev dependency on npm for grunt run:installTestDeps task" This reverts commit fa0b947. * Replace run:installTestDeps task with npm-command:test * Fix lint errors in Gruntfile * Resolve config file relative to the cwd if it can't be found relative to the parent config * Make rules in tslint-test-custom-rules package valid rules (copied from noFailRule) * Add CLI test with a relative extend config * Add test config package And install it as a dev dependency * Add CLI test for extending a package which is installed in tslint. * Make test packages private * Fix entry point of test packages * Simplify non-relative test package * Add unit test for loadConfigurationFromPath with configs outside of the tslint require path.
- Loading branch information
Showing
18 changed files
with
199 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
declare module "resolve" { | ||
interface ResolveOptions { | ||
basedir?: string; | ||
extensions?: string[]; | ||
paths?: string[]; | ||
moduleDirectory?: string | string[]; | ||
} | ||
interface AsyncResolveOptions extends ResolveOptions { | ||
package?: any; | ||
readFile?: Function; | ||
isFile?: (file: string, cb: Function) => void; | ||
packageFilter?: Function; | ||
pathFilter?: Function; | ||
} | ||
interface SyncResolveOptions extends ResolveOptions { | ||
readFile?: Function; | ||
isFile?: (file: string) => boolean; | ||
packageFilter?: Function; | ||
} | ||
interface ResolveFunction { | ||
(id: string, cb: (err: any, res: string, pkg: any) => void): void; | ||
(id: string, opts: AsyncResolveOptions, cb: (err: any, res: string, pkg: any) => void): void; | ||
sync(id: string, opts?: SyncResolveOptions): string; | ||
isCore(pkg: any): any; | ||
} | ||
|
||
const resolve: ResolveFunction; | ||
export = resolve; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "tslint-test-configs", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"tslint-test-config": "../external/tslint-test-config", | ||
"tslint-test-custom-rules": "../external/tslint-test-custom-rules" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "tslint-test-config-non-relative", | ||
"description": "A test package with a tslint config which is installed in the tslint.", | ||
"version": "0.0.1", | ||
"private": true, | ||
"main": "tslint.json", | ||
"scripts": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rules": { | ||
"class-name": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"name": "tslint-test-config", | ||
"version": "0.0.1", | ||
"main": "index.js", | ||
"private": true, | ||
"main": "tslint.json", | ||
"scripts": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"name": "tslint-test-custom-rules", | ||
"version": "0.0.1", | ||
"private": true, | ||
"main": "tslint.json", | ||
"scripts": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var Lint = require("tslint/lib/lint"); | ||
var Rule = (function (_super) { | ||
__extends(Rule, _super); | ||
function Rule() { | ||
_super.apply(this, arguments); | ||
} | ||
Rule.prototype.apply = function (sourceFile) { | ||
return this.applyWithWalker(new NoFailWalker(sourceFile, this.getOptions())); | ||
}; | ||
return Rule; | ||
})(Lint.Rules.AbstractRule); | ||
exports.Rule = Rule; | ||
var NoFailWalker = (function (_super) { | ||
__extends(NoFailWalker, _super); | ||
function NoFailWalker() { | ||
_super.apply(this, arguments); | ||
} | ||
NoFailWalker.prototype.visitSourceFile = function (node) { | ||
// yay, no failures! | ||
}; | ||
return NoFailWalker; | ||
})(Lint.RuleWalker); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var Lint = require("tslint/lib/lint"); | ||
var Rule = (function (_super) { | ||
__extends(Rule, _super); | ||
function Rule() { | ||
_super.apply(this, arguments); | ||
} | ||
Rule.prototype.apply = function (sourceFile) { | ||
return this.applyWithWalker(new NoFailWalker(sourceFile, this.getOptions())); | ||
}; | ||
return Rule; | ||
})(Lint.Rules.AbstractRule); | ||
exports.Rule = Rule; | ||
var NoFailWalker = (function (_super) { | ||
__extends(NoFailWalker, _super); | ||
function NoFailWalker() { | ||
_super.apply(this, arguments); | ||
} | ||
NoFailWalker.prototype.visitSourceFile = function (node) { | ||
// yay, no failures! | ||
}; | ||
return NoFailWalker; | ||
})(Lint.RuleWalker); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var __extends = (this && this.__extends) || function (d, b) { | ||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
var Lint = require("tslint/lib/lint"); | ||
var Rule = (function (_super) { | ||
__extends(Rule, _super); | ||
function Rule() { | ||
_super.apply(this, arguments); | ||
} | ||
Rule.prototype.apply = function (sourceFile) { | ||
return this.applyWithWalker(new NoFailWalker(sourceFile, this.getOptions())); | ||
}; | ||
return Rule; | ||
})(Lint.Rules.AbstractRule); | ||
exports.Rule = Rule; | ||
var NoFailWalker = (function (_super) { | ||
__extends(NoFailWalker, _super); | ||
function NoFailWalker() { | ||
_super.apply(this, arguments); | ||
} | ||
NoFailWalker.prototype.visitSourceFile = function (node) { | ||
// yay, no failures! | ||
}; | ||
return NoFailWalker; | ||
})(Lint.RuleWalker); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters