-
Notifications
You must be signed in to change notification settings - Fork 23
Enable type-checking for rules that needs it #109
Comments
This would also be nice. It shouldn't take much work to do it, considering that TSLint has a few helper functions to make this very simple. |
@isiahmeadows I'd be happy to review a PR 😉. |
I've been majorly backed up lately, or I probably would've already. |
Hi guys, tried to fix this with the helper mentioned above but I don't think it produces proper valid Program instance. I've already implemented type-checking in my https://github.com/zaggino/brackets-typescript repository but it's much more complex there because I also re-implemented whole TypeScript's Language Service. My attempt diff makes );
},
+ getProgram(Linter, configurationPath) {
+ let program;
+ try {
+ const tsconfigPath = path.resolve(path.dirname(configurationPath), 'tsconfig.json');
+ const isFile = fs.statSync(tsconfigPath).isFile();
+ if (isFile) {
+ program = Linter.createProgram('tsconfig.json', path.dirname(configurationPath));
+ }
+ } catch (err) {
+ // no-op
+ }
+ return program;
+ },
+
provideLinter() {
// eslint-disable-next-line import/no-dynamic-require
tslintDef = require('loophole').allowUnsafeNewFunction(() => require(TSLINT_MODULE_NAME).Linter);
@@ -144,7 +158,7 @@ export default {
const linter = new Linter({
formatter: 'json',
rulesDirectory,
- });
+ }, this.getProgram(Linter, configurationPath));
linter.lint(filePath, text, configuration);
const lintResult = linter.getResult(); |
@zaggino your solution works perfectly for me! I am hesitant to issue a pull request since the fix was your idea, and apparently it doesn't work for everyone, but I can confirm that it does work in principle. Have you been able to find a solution that works for you? |
Ah, and as mentioned in #93 @beckend has also solved this issue in his own plugin at https://github.com/beckend/linter-tslint2 |
feel free to use the code however you wish @newtrat , it didn't work for me so I've switched back to Brackets for my TypeScript projects |
Getting a lot(or same) error repeatedly when using latest tslint.
It says on tslint gh:
palantir/tslint#1445
The text was updated successfully, but these errors were encountered: