Skip to content

Commit

Permalink
chore(eslint-plugin): use getFixturesRootDir in tests (#1506)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed Jan 24, 2020
1 parent 9ca65dc commit 802e347
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 56 deletions.
11 changes: 5 additions & 6 deletions packages/eslint-plugin/tests/rules/no-dynamic-delete.test.ts
@@ -1,15 +1,14 @@
import path from 'path';
import rule from '../../src/rules/no-dynamic-delete';
import { RuleTester } from '../RuleTester';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const rootPath = getFixturesRootDir();

const rootDir = path.join(process.cwd(), 'tests/fixtures');
const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2015,
tsconfigRootDir: rootDir,
tsconfigRootDir: rootPath,
project: './tsconfig.json',
},
parser: '@typescript-eslint/parser',
});

ruleTester.run('no-dynamic-delete', rule, {
Expand Down
@@ -1,15 +1,14 @@
import path from 'path';
import rule, {
Options,
MessageId,
} from '../../src/rules/no-unnecessary-condition';
import { RuleTester } from '../RuleTester';
import {
TestCaseError,
InvalidTestCase,
} from '@typescript-eslint/experimental-utils/dist/ts-eslint';
import rule, {
Options,
MessageId,
} from '../../src/rules/no-unnecessary-condition';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const rootPath = path.join(process.cwd(), 'tests/fixtures/');
const rootPath = getFixturesRootDir();

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
Expand Down
@@ -1,21 +1,20 @@
import path from 'path';
import rule from '../../src/rules/no-unnecessary-qualifier';
import { RuleTester } from '../RuleTester';
import { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils';
import rule from '../../src/rules/no-unnecessary-qualifier';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const messageId = 'unnecessaryQualifier';
const rootPath = path.join(process.cwd(), 'tests/fixtures/');
const rootPath = getFixturesRootDir();

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
tsconfigRootDir: rootPath,
project: './tsconfig.json',
sourceType: 'module',
ecmaVersion: 6,
},
});

const messageId = 'unnecessaryQualifier';

ruleTester.run('no-unnecessary-qualifier', rule, {
valid: [
`
Expand Down
@@ -1,16 +1,15 @@
import path from 'path';
import rule from '../../src/rules/no-unnecessary-type-arguments';
import { RuleTester } from '../RuleTester';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const rootPath = getFixturesRootDir();

const rootDir = path.join(process.cwd(), 'tests/fixtures');
const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2015,
sourceType: 'module',
tsconfigRootDir: rootDir,
tsconfigRootDir: rootPath,
project: './tsconfig.json',
},
parser: '@typescript-eslint/parser',
});

ruleTester.run('no-unnecessary-type-arguments', rule, {
Expand Down
Expand Up @@ -5,7 +5,7 @@ import { RuleTester } from '../RuleTester';
const rootDir = path.resolve(__dirname, '../fixtures/');
const ruleTester = new RuleTester({
parserOptions: {
ecmaVersion: 2015,
sourceType: 'module',
tsconfigRootDir: rootDir,
project: './tsconfig.json',
},
Expand Down
9 changes: 4 additions & 5 deletions packages/eslint-plugin/tests/rules/prefer-includes.test.ts
@@ -1,12 +1,9 @@
import { TSESLint } from '@typescript-eslint/experimental-utils';
import path from 'path';
import rule from '../../src/rules/prefer-includes';
import * as util from '../../src/util';
import { RuleTester } from '../RuleTester';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const rootPath = path.join(process.cwd(), 'tests/fixtures/');

type MessageIds = util.InferMessageIdsTypeFromRule<typeof rule>;
const rootPath = getFixturesRootDir();

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
Expand All @@ -16,6 +13,8 @@ const ruleTester = new RuleTester({
},
});

type MessageIds = util.InferMessageIdsTypeFromRule<typeof rule>;

type InvalidTestCase = TSESLint.InvalidTestCase<MessageIds, never>;
type ValidTestCase = TSESLint.ValidTestCase<never> | string;
function addOptional(cases: ValidTestCase[]): ValidTestCase[];
Expand Down
@@ -1,12 +1,11 @@
import { TSESLint } from '@typescript-eslint/experimental-utils';
import path from 'path';
import rule, {
MessageIds,
Options,
} from '../../src/rules/prefer-nullish-coalescing';
import { RuleTester } from '../RuleTester';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const rootPath = path.join(process.cwd(), 'tests/fixtures/');
const rootPath = getFixturesRootDir();

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
Expand Down
5 changes: 2 additions & 3 deletions packages/eslint-plugin/tests/rules/prefer-regexp-exec.test.ts
@@ -1,8 +1,7 @@
import path from 'path';
import rule from '../../src/rules/prefer-regexp-exec';
import { RuleTester } from '../RuleTester';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const rootPath = path.join(process.cwd(), 'tests/fixtures/');
const rootPath = getFixturesRootDir();

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
Expand Down
@@ -1,9 +1,8 @@
import { TSESLint } from '@typescript-eslint/experimental-utils';
import path from 'path';
import rule from '../../src/rules/prefer-string-starts-ends-with';
import { RuleTester } from '../RuleTester';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const rootPath = path.join(process.cwd(), 'tests/fixtures/');
const rootPath = getFixturesRootDir();

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
Expand Down
@@ -1,8 +1,7 @@
import path from 'path';
import rule from '../../src/rules/require-array-sort-compare';
import { RuleTester } from '../RuleTester';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const rootPath = path.join(process.cwd(), 'tests/fixtures/');
const rootPath = getFixturesRootDir();

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
Expand Down
@@ -1,8 +1,7 @@
import path from 'path';
import rule from '../../src/rules/restrict-plus-operands';
import { RuleTester } from '../RuleTester';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const rootPath = path.join(process.cwd(), 'tests/fixtures/');
const rootPath = getFixturesRootDir();

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
Expand Down
@@ -1,8 +1,7 @@
import path from 'path';
import rule from '../../src/rules/restrict-template-expressions';
import { RuleTester } from '../RuleTester';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const rootPath = path.join(process.cwd(), 'tests/fixtures/');
const rootPath = getFixturesRootDir();

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
Expand Down
@@ -1,8 +1,7 @@
import path from 'path';
import rule from '../../src/rules/strict-boolean-expressions';
import { RuleTester } from '../RuleTester';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const rootPath = path.join(process.cwd(), 'tests/fixtures/');
const rootPath = getFixturesRootDir();

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
Expand Down
5 changes: 2 additions & 3 deletions packages/eslint-plugin/tests/rules/unbound-method.test.ts
@@ -1,9 +1,8 @@
import { TSESLint } from '@typescript-eslint/experimental-utils';
import path from 'path';
import rule, { MessageIds, Options } from '../../src/rules/unbound-method';
import { RuleTester } from '../RuleTester';
import { RuleTester, getFixturesRootDir } from '../RuleTester';

const rootPath = path.join(process.cwd(), 'tests/fixtures/');
const rootPath = getFixturesRootDir();

const ruleTester = new RuleTester({
parser: '@typescript-eslint/parser',
Expand Down

0 comments on commit 802e347

Please sign in to comment.