Skip to content

Commit

Permalink
chore: turn on plugin-test-formatting rule (#1822)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradzacher committed Mar 31, 2020
1 parent 9642d9d commit 188b689
Show file tree
Hide file tree
Showing 93 changed files with 8,819 additions and 6,610 deletions.
13 changes: 12 additions & 1 deletion .eslintrc.js
Expand Up @@ -174,7 +174,7 @@ module.exports = {
'@typescript-eslint/internal/no-typescript-estree-import': 'error',
},
},
// rule source files
// plugin rule source files
{
files: [
'packages/eslint-plugin-internal/src/rules/**/*.ts',
Expand All @@ -187,6 +187,17 @@ module.exports = {
'import/no-default-export': 'off',
},
},
// plugin rule tests
{
files: [
'packages/eslint-plugin-internal/tests/rules/**/*.test.ts',
'packages/eslint-plugin-tslint/tests/rules/**/*.test.ts',
'packages/eslint-plugin/tests/rules/**/*.test.ts',
],
rules: {
'@typescript-eslint/internal/plugin-test-formatting': 'error',
},
},
// tools and tests
{
files: ['**/tools/**/*.ts', '**/tests/**/*.ts'],
Expand Down
Expand Up @@ -10,20 +10,20 @@ const ruleTester = new RuleTester({

ruleTester.run('no-typescript-estree-import', rule, {
valid: [
'import { foo } from "@typescript-eslint/experimental-utils";',
'import foo from "@typescript-eslint/experimental-utils";',
'import * as foo from "@typescript-eslint/experimental-utils";',
"import { foo } from '@typescript-eslint/experimental-utils';",
"import foo from '@typescript-eslint/experimental-utils';",
"import * as foo from '@typescript-eslint/experimental-utils';",
],
invalid: batchedSingleLineTests({
code: `
import { foo } from "@typescript-eslint/typescript-estree";
import foo from "@typescript-eslint/typescript-estree";
import * as foo from "@typescript-eslint/typescript-estree";
import { foo } from '@typescript-eslint/typescript-estree';
import foo from '@typescript-eslint/typescript-estree';
import * as foo from '@typescript-eslint/typescript-estree';
`,
output: `
import { foo } from "@typescript-eslint/experimental-utils";
import foo from "@typescript-eslint/experimental-utils";
import * as foo from "@typescript-eslint/experimental-utils";
import { foo } from '@typescript-eslint/experimental-utils';
import foo from '@typescript-eslint/experimental-utils';
import * as foo from '@typescript-eslint/experimental-utils';
`,
errors: [
{
Expand Down
Expand Up @@ -71,6 +71,7 @@ const a = 1;
${PARENT_INDENT}\``,
wrap`noFormat\`const a = 1;\``,
// sanity check suggestion validation
// eslint-disable-next-line @typescript-eslint/internal/plugin-test-formatting
`
ruleTester.run({
invalid: [
Expand Down
Expand Up @@ -14,29 +14,29 @@ const ruleTester = new RuleTester({

ruleTester.run('prefer-ast-types-enum', rule, {
valid: [
'node.type === "constructor"',
'node.type === AST_NODE_TYPES.Literal',
'node.type === AST_TOKEN_TYPES.Keyword',
'node.type === 1',
"node.type === 'constructor';",
'node.type === AST_NODE_TYPES.Literal;',
'node.type === AST_TOKEN_TYPES.Keyword;',
'node.type === 1;',
`
enum MY_ENUM {
Literal = 1
}
enum MY_ENUM {
Literal = 1,
}
`,
`
enum AST_NODE_TYPES {
Literal = 'Literal'
}
enum AST_NODE_TYPES {
Literal = 'Literal',
}
`,
],
invalid: batchedSingleLineTests({
code: `
node.type === 'Literal'
node.type === 'Keyword'
node.type === 'Literal';
node.type === 'Keyword';
`,
output: `
node.type === AST_NODE_TYPES.Literal
node.type === AST_TOKEN_TYPES.Keyword
node.type === AST_NODE_TYPES.Literal;
node.type === AST_TOKEN_TYPES.Keyword;
`,
errors: [
{
Expand Down

0 comments on commit 188b689

Please sign in to comment.