-
Notifications
You must be signed in to change notification settings - Fork 885
Conversation
Allows tests for rules to be written in a more visual manner. Works in this commit! However, major code cleanup needed.
…TSLint does stuff
Fix bug where messages couldn't have punctuation Fix bug where errors wouldn't be sorted with a total ordering (sort by message)
…, no-constructor-vars
Convert tests for no-consecutive-blank-lines, no-duplicate-key no-duplicate-variable, no-empty, and no-eval rules
…eyword, and no-require-imports. Allow '-' and '_' in message shortcuts
…case-fall-through, and no-trailing-whitespace rules Tweak no-switch-case-fall-through rule to have saner error start and end locations
…res, and object-literal-sort-keys rules
Switch to one directory per rule with subdirectories for different options
…typedef rules Fix trailing-comma rule to have more sensible error locations
Adjust Gruntfile so tests for rules run on Windows Convert tsx test to new format
This lets us add a --test command that people can use to test custom rules if they wish
a762ba6
to
03eeef6
Compare
(Translate tests added to new style tests as well)
@@ -0,0 +1,95 @@ | |||
import * as colors from "colors"; |
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.
copyright block
@@ -152,6 +162,12 @@ tslint accepts the following commandline options: | |||
and verbose. prose is the default if this option is not used. Additonal | |||
formatters can be added and used if the --formatters-dir option is set. | |||
|
|||
--test: | |||
Runs tslint on the specified directory and checks if tslint's output matches | |||
the expected output. Automatically loads the tslint.json file in the |
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.
how about "... the expected output in .linttest files" (or whatever we end up naming the extension)
looks pretty great overall. I'm wondering if we can make the structure of the linttests simpler. All the for example, //// tslint.json
{
"rules": {
"no-require-imports": true
}
}
//// linttest
var lib = require('lib'); // failure
~~~~~~~~~~~~~~ [no-require]
let lib2 = require('lib2'); // failure
~~~~~~~~~~~~~~~ [no-require]
import {l} from 'lib';
var lib3 = load('not_an_import');
var lib4 = lib2.subImport;
var lib5 = require('lib5'), // failure
~~~~~~~~~~~~~~~ [no-require]
lib6 = require('lib6'), // failure
~~~~~~~~~~~~~~~ [no-require]
lib7 = 700;
import lib8 = require('lib8'); // failure
~~~~~~~~~~~~~~~ [no-require]
import lib9 = lib2.anotherSubImport;
[no-require]: require() style import is forbidden this would flatten the directories. you could still have multiple files for a rule, e.g. |
Interesting idea. There are a few cases where this isn't true ( |
yeah, I don't see it as a huge benefit either; the tradeoffs are minor. the current structure does support cases like somewhat relatedly, any ideas for a better directory name than |
@@ -22,13 +22,16 @@ module.exports = function (grunt) { | |||
options: { | |||
reporter: "spec" | |||
}, | |||
src: ["build/test/**/*.js"] | |||
src: ["build/test/**/*Tests.js", "build/test/assert.js", "build/test/lint.js"] |
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.
why do you need to include build/test/lint.js
here?
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.
it seems to still work if I remove it.
filed a separate issue for updating documentation, which should be handled next: #941 |
👍 |
New testing system for rules
Implements #620 and provides a solution to #532.
Documentation for this feature will come in a separate PR. The code is still a little bit messy, but I'd like to get a second set of eyes on it for ideas to make it nicer.
In brief,
src/test.ts
andsrc/test/*
contain the logic/code for parsing the markup of the new testing system.test/rule-tester
contains the tests for this code.test/rules
contains one directory for every rule which contains the rule's tests written in the new markup style.