mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-03-15 14:05:47 -05:00
lint src/, scripts/ folders separately
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { TSESTree } from "@typescript-eslint/typescript-estree";
|
||||
import { TSESTree } from "@typescript-eslint/experimental-utils";
|
||||
import { createRule } from "./utils";
|
||||
|
||||
type MessageId = "simpleIndentError";
|
||||
@@ -15,7 +15,7 @@ export = createRule<Options, MessageId>({
|
||||
messages: {
|
||||
simpleIndentError: "4 space indentation expected",
|
||||
},
|
||||
fixable: 'whitespace',
|
||||
fixable: "whitespace",
|
||||
schema: [],
|
||||
type: "layout",
|
||||
},
|
||||
@@ -29,8 +29,8 @@ export = createRule<Options, MessageId>({
|
||||
const checkIndent = (node: TSESTree.Program) => {
|
||||
const lines = sourceCode.getLines();
|
||||
const linesLen = lines.length;
|
||||
let totalLen = 0;
|
||||
|
||||
let totalLen = 0;
|
||||
for (let i = 0; i < linesLen; i++) {
|
||||
const lineNumber = i + 1;
|
||||
const line = lines[i];
|
||||
@@ -48,7 +48,7 @@ export = createRule<Options, MessageId>({
|
||||
}
|
||||
|
||||
context.report({
|
||||
messageId: 'simpleIndentError',
|
||||
messageId: "simpleIndentError",
|
||||
node,
|
||||
loc: { column: indentEnd, line: lineNumber },
|
||||
fix(fixer) {
|
||||
@@ -63,10 +63,10 @@ export = createRule<Options, MessageId>({
|
||||
|
||||
totalLen += lineLen;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
Program: checkIndent,
|
||||
}
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -104,7 +104,7 @@ module TestModule {
|
||||
}
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: 'simpleIndentError', line: 3, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 3, column: 2 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -112,14 +112,14 @@ module TestModule {
|
||||
function a() {
|
||||
\t\tvar test = 123;
|
||||
}
|
||||
`,
|
||||
`,
|
||||
output: `
|
||||
function a() {
|
||||
var test = 123;
|
||||
}
|
||||
`,
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: 'simpleIndentError', line: 3, column: 3 },
|
||||
{ messageId: "simpleIndentError", line: 3, column: 3 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -142,10 +142,10 @@ class TestClass {
|
||||
}
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: 'simpleIndentError', line: 3, column: 2 },
|
||||
{ messageId: 'simpleIndentError', line: 5, column: 2 },
|
||||
{ messageId: 'simpleIndentError', line: 6, column: 3 },
|
||||
{ messageId: 'simpleIndentError', line: 7, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 3, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 5, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 6, column: 3 },
|
||||
{ messageId: "simpleIndentError", line: 7, column: 2 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -164,9 +164,9 @@ var obj = {
|
||||
};
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: 'simpleIndentError', line: 3, column: 2 },
|
||||
{ messageId: 'simpleIndentError', line: 4, column: 2 },
|
||||
{ messageId: 'simpleIndentError', line: 5, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 3, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 4, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 5, column: 2 },
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -183,7 +183,7 @@ enum TestEnum {
|
||||
}
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: 'simpleIndentError', line: 3, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 3, column: 2 },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -214,12 +214,12 @@ switch (integerValue) {
|
||||
}
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: 'simpleIndentError', line: 3, column: 2 },
|
||||
{ messageId: 'simpleIndentError', line: 4, column: 3 },
|
||||
{ messageId: 'simpleIndentError', line: 5, column: 3 },
|
||||
{ messageId: 'simpleIndentError', line: 9, column: 2 },
|
||||
{ messageId: 'simpleIndentError', line: 10, column: 3 },
|
||||
{ messageId: 'simpleIndentError', line: 11, column: 3 },
|
||||
{ messageId: "simpleIndentError", line: 3, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 4, column: 3 },
|
||||
{ messageId: "simpleIndentError", line: 5, column: 3 },
|
||||
{ messageId: "simpleIndentError", line: 9, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 10, column: 3 },
|
||||
{ messageId: "simpleIndentError", line: 11, column: 3 },
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -234,8 +234,8 @@ for (var i = 0; i < 1; ++i) {
|
||||
}
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: 'simpleIndentError', line: 3, column: 2 },
|
||||
]
|
||||
{ messageId: "simpleIndentError", line: 3, column: 2 },
|
||||
],
|
||||
},
|
||||
{
|
||||
code: `
|
||||
@@ -249,7 +249,7 @@ while (i < 1) {
|
||||
}
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: 'simpleIndentError', line: 3, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 3, column: 2 },
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -264,7 +264,7 @@ do {
|
||||
} while (i < 1);
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: 'simpleIndentError', line: 3, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 3, column: 2 },
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -279,7 +279,7 @@ if (i < 1) {
|
||||
}
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: 'simpleIndentError', line: 3, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 3, column: 2 },
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -296,7 +296,7 @@ var arr = [
|
||||
];
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: 'simpleIndentError', line: 3, column: 2 },
|
||||
{ messageId: "simpleIndentError", line: 3, column: 2 },
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -325,8 +325,8 @@ var arr2 = [
|
||||
];
|
||||
`,
|
||||
errors: [
|
||||
{ messageId: 'simpleIndentError', line: 4, column: 3 },
|
||||
{ messageId: 'simpleIndentError', line: 9, column: 3 },
|
||||
{ messageId: "simpleIndentError", line: 4, column: 3 },
|
||||
{ messageId: "simpleIndentError", line: 9, column: 3 },
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as path from "path";
|
||||
import { TSESLint } from "@typescript-eslint/experimental-utils";
|
||||
|
||||
export const ROOT_DIR = path.join(process.cwd(), 'scripts', 'eslint', 'tests', 'fixtures');
|
||||
export const FILENAME = path.join(ROOT_DIR, 'file.ts');
|
||||
export const ROOT_DIR = path.join(process.cwd(), "scripts", "eslint", "tests", "fixtures");
|
||||
export const FILENAME = path.join(ROOT_DIR, "file.ts");
|
||||
export const RuleTester = TSESLint.RuleTester;
|
||||
|
||||
@@ -21,4 +21,4 @@
|
||||
"configurePrerelease.ts",
|
||||
"word2md.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user