diff --git a/test/ruleDisableEnableTests.ts b/test/ruleDisableEnableTests.ts deleted file mode 100644 index 8c78fc447a0..00000000000 --- a/test/ruleDisableEnableTests.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2013 Palantir Technologies, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import {ILinterOptions, Linter, RuleFailure, TestUtils} from "./lint"; - -describe("Enable and Disable Rules", () => { - const {readFileSync} = require("fs"); - const {join} = require("path"); - - it("is enabled and disabled in all the right places", () => { - const validConfiguration = {rules: { - "variable-name": true, - "quotemark": [true, "double"], - }}; - - const relativePath = join("test", "files", "enabledisable.test.ts"); - const source = readFileSync(relativePath, "utf8"); - - const options: ILinterOptions = { - configuration: validConfiguration, - formatter: "json", - formattersDirectory: null, - rulesDirectory: null, - }; - - const QuotemarkRule = TestUtils.getRule("quotemark"); - const VariableNameRule = TestUtils.getRule("variable-name"); - - const quotemarkFailure = TestUtils.createFailuresOnFile("enabledisable.test.ts", QuotemarkRule.DOUBLE_QUOTE_FAILURE); - const variableNameFailure = TestUtils.createFailuresOnFile("enabledisable.test.ts", VariableNameRule.FORMAT_FAILURE); - - const expectedFailure1 = variableNameFailure([2, 5], [2, 10]); - const expectedFailure2 = variableNameFailure([10, 5], [10, 10]); - - const expectedFailure3 = quotemarkFailure([2, 13], [2, 19]); - const expectedFailure4 = quotemarkFailure([8, 13], [8, 19]); - const expectedFailure5 = quotemarkFailure([10, 13], [10, 19]); - const expectedFailure6 = quotemarkFailure([16, 13], [16, 19]); - - const expectedFailure7 = quotemarkFailure([39, 13], [39, 19]); - const expectedFailure8 = variableNameFailure([41, 5], [41, 10]); - - const ll = new Linter(relativePath, source, options); - const result = ll.lint(); - const parsedResult = JSON.parse(result.output); - const actualFailures: RuleFailure[] = []; - for (let failure of parsedResult) { - const startArray = [failure.startPosition.line + 1, failure.startPosition.character + 1]; - const endArray = [failure.endPosition.line + 1, failure.endPosition.character + 1]; - actualFailures.push(TestUtils.createFailure("enabledisable.test.ts", startArray, endArray, failure.failure)); - } - - TestUtils.assertContainsFailure(actualFailures, expectedFailure1); - TestUtils.assertContainsFailure(actualFailures, expectedFailure2); - TestUtils.assertContainsFailure(actualFailures, expectedFailure3); - TestUtils.assertContainsFailure(actualFailures, expectedFailure4); - TestUtils.assertContainsFailure(actualFailures, expectedFailure5); - TestUtils.assertContainsFailure(actualFailures, expectedFailure6); - TestUtils.assertContainsFailure(actualFailures, expectedFailure7); - TestUtils.assertContainsFailure(actualFailures, expectedFailure8); - assert.lengthOf(actualFailures, 8); - }); -}); diff --git a/test/files/enabledisable.test.ts b/test/rules/_integration/enable-disable/test.ts.lint similarity index 70% rename from test/files/enabledisable.test.ts rename to test/rules/_integration/enable-disable/test.ts.lint index ef82e12240e..ba78e3b5740 100644 --- a/test/files/enabledisable.test.ts +++ b/test/rules/_integration/enable-disable/test.ts.lint @@ -1,19 +1,25 @@ /* tslint:enable */ var AAAaA = 'test' + ~~~~~ [variable name must be in camelcase or uppercase] + ~~~~~~ [' should be "] /* tslint:disable */ var AAAaA = 'test' /* tslint:disable */ var AAAaA = 'test' /* tslint:enable:quotemark */ var AAAaA = 'test' + ~~~~~~ [' should be "] /* tslint:enable */ var AAAaA = 'test' + ~~~~~ [variable name must be in camelcase or uppercase] + ~~~~~~ [' should be "] /* tslint:disable:quotemark variable-name */ var AAAaA = 'test' /* tslint:disable:quotemark */ var AAAaA = 'test' /* tslint:enable:quotemark */ var AAAaA = 'test' + ~~~~~~ [' should be "] /* tslint:disable */ var AAAaA = 'test' /* tslint:enable:zasdadsa */ @@ -37,8 +43,10 @@ var AAAaA = 'test' // tslint:disable var AAAaA = 'test' // tslint:enable-line:quotemark + ~~~~~~ [' should be "] // tslint:enable-next-line:variable-name var AAAaA = 'test' + ~~~~~ [variable name must be in camelcase or uppercase] // tslint:enable /* tslint:disable:quotemark */ diff --git a/test/rules/_integration/enable-disable/tslint.json b/test/rules/_integration/enable-disable/tslint.json new file mode 100644 index 00000000000..a8de85ad1d7 --- /dev/null +++ b/test/rules/_integration/enable-disable/tslint.json @@ -0,0 +1,6 @@ +{ + "rules": { + "quotemark": [true, "double"], + "variable-name": true + } +} diff --git a/test/tsconfig.json b/test/tsconfig.json index 16d1ee67b7d..bc75b6c36ec 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -130,7 +130,6 @@ "configurationTests.ts", "eofLineRuleTests.ts", "lint.ts", - "ruleDisableEnableTests.ts", "ruleLoaderTests.ts", "ruleTestRunner.ts", "utils.ts",