Skip to content

Commit 9b0023a

Browse files
authored
feat(eslint-plugin-internal): add plugin-test-formatting rule (typescript-eslint#1821)
The strings that are used for eslint plugins will not be checked for formatting. This can lead to diff noise as one contributor adjusts formatting, uses different quotes, etc. This rule just enforces the following: - all code samples are formatted with prettier - all single line tests do not use backticks - all multiline tests have: - no code on the first line - no code on the last line - the closing backtick indentation === property indentation - one of the following indentations: - no indentation at all - indentation of 1 + object indent examples of enforced style: ```ts ruleTester.run('foo', rule, { valid: [ 'const a = 1;', ` const a = 1; `, ` const a = 1; `, { code: 'const a = 1;', }, { code: ` const a = 1; `, }, { code: ` const a = 1; `, }, ], invalid: [ { code: 'const a = 1;', }, { code: ` const a = 1; `, }, { code: ` const a = 1; `, }, ], }); ```
1 parent 151f89b commit 9b0023a

File tree

7 files changed

+1045
-3
lines changed

7 files changed

+1045
-3
lines changed

.prettierrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"singleQuote": true,
23
"trailingComma": "all"
34
}

packages/eslint-plugin-internal/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"typecheck": "tsc -p tsconfig.json --noEmit"
1313
},
1414
"dependencies": {
15-
"@typescript-eslint/experimental-utils": "2.26.0"
15+
"@typescript-eslint/experimental-utils": "2.26.0",
16+
"prettier": "*"
1617
}
1718
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import noTypescriptDefaultImport from './no-typescript-default-import';
22
import noTypescriptEstreeImport from './no-typescript-estree-import';
3+
import pluginTestFormatting from './plugin-test-formatting';
34
import preferASTTypesEnum from './prefer-ast-types-enum';
45

56
export default {
67
'no-typescript-default-import': noTypescriptDefaultImport,
78
'no-typescript-estree-import': noTypescriptEstreeImport,
9+
'plugin-test-formatting': pluginTestFormatting,
810
'prefer-ast-types-enum': preferASTTypesEnum,
911
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy