lint src/, scripts/ folders separately
This commit is contained in:
parent
ee90fdb90b
commit
a37d34a5b6
|
@ -21,14 +21,6 @@
|
|||
"@typescript-eslint/camelcase": ["error", { "properties": "never", "allow": ["^[A-Za-z][a-zA-Za-z]+_[A-Za-z]+$"] }],
|
||||
"@typescript-eslint/class-name-casing": "error",
|
||||
"@typescript-eslint/consistent-type-definitions": ["error", "interface"],
|
||||
"indent": "off",
|
||||
"@typescript-eslint/indent": ["error", 4, {
|
||||
"flatTernaryExpressions": true,
|
||||
"FunctionDeclaration": { "parameters": 1, "body": 1 },
|
||||
"CallExpression": { "arguments": 1 },
|
||||
"ignoredNodes": ["TSTypeAnnotation"],
|
||||
"SwitchCase": 1
|
||||
}],
|
||||
"@typescript-eslint/interface-name-prefix": "error",
|
||||
"@typescript-eslint/no-inferrable-types": "error",
|
||||
"@typescript-eslint/no-misused-new": "error",
|
||||
|
@ -44,7 +36,7 @@
|
|||
"@typescript-eslint/type-annotation-spacing": "error",
|
||||
"@typescript-eslint/unified-signatures": "error",
|
||||
|
||||
/** scripts/eslint/rules */
|
||||
// scripts/eslint/rules
|
||||
"object-literal-surrounding-space": "error",
|
||||
"no-type-assertion-whitespace": "error",
|
||||
"type-operator-spacing": "error",
|
||||
|
@ -55,19 +47,20 @@
|
|||
"no-double-space": "error",
|
||||
"boolean-trivia": "error",
|
||||
"no-in-operator": "error",
|
||||
"simple-indent": "error",
|
||||
"debug-assert": "error",
|
||||
"no-keywords": "error",
|
||||
|
||||
/** eslint-plugin-import */
|
||||
// eslint-plugin-import
|
||||
"import/no-extraneous-dependencies": ["error", { "optionalDependencies": false }],
|
||||
|
||||
/** eslint-plugin-no-null */
|
||||
// eslint-plugin-no-null
|
||||
"no-null/no-null": "error",
|
||||
|
||||
/** eslint-plugin-jsdoc */
|
||||
// eslint-plugin-jsdoc
|
||||
"jsdoc/check-alignment": "error",
|
||||
|
||||
/** eslint */
|
||||
// eslint
|
||||
"brace-style": ["error", "stroustrup", { "allowSingleLine": true }],
|
||||
"constructor-super": "error",
|
||||
"curly": ["error", "multi-line"],
|
||||
|
@ -109,7 +102,7 @@
|
|||
"quotes": ["error", "double", { "avoidEscape": true, "allowTemplateLiterals": true }],
|
||||
"space-in-parens": "error",
|
||||
"unicode-bom": ["error", "never"],
|
||||
"use-isnan": "error",
|
||||
"use-isnan": "error"
|
||||
},
|
||||
"overrides": [{
|
||||
"files": ["src/lib/*.d.ts"],
|
||||
|
@ -118,10 +111,10 @@
|
|||
"@typescript-eslint/prefer-function-type": "off",
|
||||
"@typescript-eslint/unified-signatures": "off",
|
||||
|
||||
/** scripts/eslint/rules */
|
||||
// scripts/eslint/rules
|
||||
"no-keywords": "off",
|
||||
|
||||
/** eslint */
|
||||
// eslint
|
||||
"no-var": "off"
|
||||
}
|
||||
}]
|
16
Gulpfile.js
16
Gulpfile.js
|
@ -333,13 +333,13 @@ task("run-rules-tests").description = "Runs the eslint rule tests";
|
|||
|
||||
const lintFoldStart = async () => { if (fold.isTravis()) console.log(fold.start("lint")); };
|
||||
const lintFoldEnd = async () => { if (fold.isTravis()) console.log(fold.end("lint")); };
|
||||
const eslint = async () => {
|
||||
const eslint = (path) => async () => {
|
||||
const args = [
|
||||
"node_modules/eslint/bin/eslint",
|
||||
"--format", "autolinkable-stylish",
|
||||
"--config", ".eslintrc",
|
||||
"--ext", ".ts", ".",
|
||||
"--rulesdir", "built/eslint/rules/",
|
||||
"--ext", ".ts",
|
||||
`"${ path }"`,
|
||||
];
|
||||
|
||||
if (cmdLineOptions.fix) {
|
||||
|
@ -350,13 +350,15 @@ const eslint = async () => {
|
|||
return exec(process.execPath, args);
|
||||
}
|
||||
|
||||
const lint = series([buildRules, lintFoldStart, eslint, lintFoldEnd]);
|
||||
const lintScripts = series([buildRules, eslint("scripts/**/*.ts")]);
|
||||
lintScripts.displayName = "lint-scripts";
|
||||
task("lint-scripts", lintScripts);
|
||||
task("lint-scripts").description = "Runs eslint on the scripts sources.";
|
||||
|
||||
const lint = series([buildRules, lintFoldStart, eslint("src/**/*.ts"), lintFoldEnd]);
|
||||
lint.displayName = "lint";
|
||||
task("lint", lint);
|
||||
task("lint").description = "Runs eslint on the compiler sources.";
|
||||
task("lint").flags = {
|
||||
" --f[iles]=<regex>": "pattern to match files to lint",
|
||||
};
|
||||
|
||||
const buildCancellationToken = () => buildProject("src/cancellationToken");
|
||||
const cleanCancellationToken = () => cleanProject("src/cancellationToken");
|
||||
|
|
|
@ -104,6 +104,7 @@
|
|||
"scripts": {
|
||||
"pretest": "gulp tests",
|
||||
"test": "gulp runtests-parallel --light=false",
|
||||
"test:eslint-rules": "gulp run-rules-tests",
|
||||
"build": "npm run build:compiler && npm run build:tests",
|
||||
"build:compiler": "gulp local",
|
||||
"build:tests": "gulp tests",
|
||||
|
@ -112,7 +113,7 @@
|
|||
"gulp": "gulp",
|
||||
"jake": "gulp",
|
||||
"lint": "gulp lint",
|
||||
"lint:test": "gulp run-rules-tests",
|
||||
"lint:scripts": "gulp lint-scripts",
|
||||
"setup-hooks": "node scripts/link-hooks.js",
|
||||
"update-costly-tests": "node scripts/costly-tests.js"
|
||||
},
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5917,7 +5917,7 @@ namespace ts {
|
|||
// If fileName is provided, gets all the diagnostics associated with that file name.
|
||||
// Otherwise, returns all the diagnostics (global and file associated) in this collection.
|
||||
getDiagnostics(): Diagnostic[];
|
||||
getDiagnostics(fileName: string): DiagnosticWithLocation[];
|
||||
getDiagnostics(fileName: string): DiagnosticWithLocation[]; // eslint-disable-line @typescript-eslint/unified-signatures
|
||||
|
||||
reattachFileDiagnostics(newFile: SourceFile): void;
|
||||
}
|
||||
|
|
|
@ -422,14 +422,14 @@ function myFunc() { return 100; }`, /*isLocal*/ true);
|
|||
content: `
|
||||
interface SomeObject
|
||||
{
|
||||
message: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export function createSomeObject(): SomeObject
|
||||
{
|
||||
return {
|
||||
message: "new Object"
|
||||
};
|
||||
return {
|
||||
message: "new Object"
|
||||
};
|
||||
}`
|
||||
};
|
||||
const libraryTsconfig: File = {
|
||||
|
|
|
@ -1146,7 +1146,7 @@ foo().hello`
|
|||
const currentDirectory = "/user/username/projects/myproject";
|
||||
const field = "fullscreen";
|
||||
const fieldWithoutReadonly = `interface Document {
|
||||
${field}: boolean;
|
||||
${field}: boolean;
|
||||
}`;
|
||||
|
||||
const libFileWithDocument: File = {
|
||||
|
@ -1227,13 +1227,13 @@ var y: number;
|
|||
const aFile: File = {
|
||||
path: `${currentDirectory}/a.ts`,
|
||||
content: `interface Document {
|
||||
${field}: boolean;
|
||||
${field}: boolean;
|
||||
}`
|
||||
};
|
||||
const bFile: File = {
|
||||
path: `${currentDirectory}/b.d.ts`,
|
||||
content: `interface Document {
|
||||
${field}: boolean;
|
||||
${field}: boolean;
|
||||
}`
|
||||
};
|
||||
const libFileWithDocument: File = {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"extends": "./src/tsconfig-base.json",
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"scripts/**/*.ts",
|
||||
]
|
||||
}
|
||||
{
|
||||
"extends": "./src/tsconfig-base.json",
|
||||
"include": [
|
||||
"src/**/*",
|
||||
"scripts/**/*"
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue