Skip to content

Commit

Permalink
add eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Jun 13, 2019
1 parent 74c6bc1 commit 55b8a38
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 734 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
@@ -0,0 +1,3 @@
/built/local/**
/tests/**
/lib/**
121 changes: 121 additions & 0 deletions .eslintrc
@@ -0,0 +1,121 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"warnOnUnsupportedTypeScriptVersion": false,
"ecmaVersion": 6,
"sourceType": "module",
"project": "./src/tsconfig-base.json"
},
"env": {
"browser": false,
"node": true,
"es6": true
},
"plugins": [
"@typescript-eslint", "microsoft-typescript"
],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "off",
"@typescript-eslint/array-type": "off",
"@typescript-eslint/ban-types": "off",
"camelcase": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/class-name-casing": "off",
"@typescript-eslint/explicit-member-accessibility": "off",
"@typescript-eslint/import/order": "off",
"indent": "off",
"@typescript-eslint/indent": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/member-ordering": "off",
"@typescript-eslint/no-angle-bracket-type-assertion": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-object-literal-type-assertion": "off",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-triple-slash-reference": "off",
"@typescript-eslint/no-unnecessary-qualifier": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/prefer-for-of": "error",
"@typescript-eslint/prefer-function-type": "off",
"@typescript-eslint/prefer-interface": "off",
"@typescript-eslint/prefer-namespace-keyword": "off",
"semi": "off",
"@typescript-eslint/semi": "off",
"@typescript-eslint/type-annotation-spacing": "off",
"@typescript-eslint/unified-signatures": "off",

"microsoft-typescript/object-literal-surrounding-space": "off",
"microsoft-typescript/no-type-assertion-whitespace": "error",
"microsoft-typescript/type-operator-spacing": "off",
"microsoft-typescript/only-arrow-functions": "off",
"microsoft-typescript/no-double-space": "off",
"microsoft-typescript/boolean-trivia": "off",
"microsoft-typescript/no-in-operator": "off",
"microsoft-typescript/debug-assert": "off",
"microsoft-typescript/no-keywords": "off",

"arrow-body-style": "off",
"arrow-parens": "off",
"brace-style": "off",
"comma-dangle": "off",
"complexity": "off",
"constructor-super": "error",
"curly": ["error", "multi-line"],
"dot-notation": "off",
"eol-last": "off",
"eqeqeq": "error",
"guard-for-in": "off",
"linebreak-style": "off",
"max-classes-per-file": "off",
"max-len": "off",
"new-parens": "error",
"no-bitwise": "off",
"no-caller": "error",
"no-cond-assign": "off",
"no-console": "off",
"no-debugger": "off",
"no-duplicate-case": "error",
"no-duplicate-imports": "error",
"no-empty": "off",
"no-eval": "off",
"no-extra-bind": "error",
"no-fallthrough": "off",
"no-invalid-this": "off",
"no-multiple-empty-lines": "off",
"no-new-func": "off",
"no-new-wrappers": "error",
"no-redeclare": "off",
"no-return-await": "error",
"no-restricted-globals": "off",
"no-sequences": "off",
"no-shadow": "off",
"no-sparse-arrays": "error",
"no-template-curly-in-string": "off",
"no-throw-literal": "off",
"no-trailing-spaces": "off",
"no-undef-init": "error",
"no-unsafe-finally": "error",
"no-unused-expressions": "off",
"no-unused-labels": "error",
"no-var": "off",
"object-shorthand": "off",
"one-var": "off",
"prefer-const": "off",
"prefer-object-spread": "error",
"quote-props": ["error", "consistent-as-needed"],
"quotes": "off",
"radix": "off",
"sort-keys": "off",
"space-before-function-paren": "off",
"space-in-parens": "off",
"unicode-bom": ["error", "never"],
"use-isnan": "error",
"valid-typeof": "off"
}
}
41 changes: 15 additions & 26 deletions Gulpfile.js
Expand Up @@ -318,34 +318,23 @@ task("clean-tests").description = "Cleans the outputs for the test infrastructur

const watchTests = () => watchProject("src/testRunner", cmdLineOptions);

const buildRules = () => buildProject("scripts/tslint");
task("build-rules", buildRules);
task("build-rules").description = "Compiles tslint rules to js";

const cleanRules = () => cleanProject("scripts/tslint");
cleanTasks.push(cleanRules);
task("clean-rules", cleanRules);
task("clean-rules").description = "Cleans the outputs for the lint rules";

const lintFoldStart = async () => { if (fold.isTravis()) console.log(fold.start("lint")); };
const lintFoldEnd = async () => { if (fold.isTravis()) console.log(fold.end("lint")); };
const lint = series([
lintFoldStart,
...["scripts/tslint/tsconfig.json", "src/tsconfig-base.json"].map(project => {
const lintOne = () => {
const args = ["node_modules/tslint/bin/tslint", "--project", project, "--formatters-dir", "./built/local/tslint/formatters", "--format", "autolinkableStylish"];
if (cmdLineOptions.fix) args.push("--fix");
log(`Linting: node ${args.join(" ")}`);
return exec(process.execPath, args);
};
lintOne.dispayName = `lint(${project})`;
return lintOne;
}),
lintFoldEnd
]);
const eslint = async () => {
const args = [
"node_modules/eslint/bin/eslint", "-f", "autolinkable-stylish", "-c", ".eslintrc", "--ext", ".ts", "."
];

if (cmdLineOptions.fix) {
args.push("--fix");
}
log(`Linting: ${args.join(" ")}`);
return exec(process.execPath, args);
}
const lint = series([lintFoldStart, eslint, lintFoldEnd]);
lint.displayName = "lint";
task("lint", series(buildRules, lint));
task("lint").description = "Runs tslint on the compiler sources.";
task("lint", lint);
task("lint").description = "Runs eslint on the compiler sources.";
task("lint").flags = {
" --f[iles]=<regex>": "pattern to match files to lint",
};
Expand Down Expand Up @@ -393,7 +382,7 @@ const generateCodeCoverage = () => exec("istanbul", ["cover", "node_modules/moch
task("generate-code-coverage", series(preBuild, buildTests, generateCodeCoverage));
task("generate-code-coverage").description = "Generates code coverage data via istanbul";

const preTest = parallel(buildRules, buildTests, buildServices, buildLssl);
const preTest = parallel(buildTests, buildServices, buildLssl);
preTest.displayName = "preTest";

const postTest = (done) => cmdLineOptions.lint ? lint(done) : done();
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -82,7 +82,7 @@ gulp runtests # Run tests using the built compiler and test infrastructu
# You can override the host or specify a test for this command.
# Use --host=<hostName> or --tests=<testPath>.
gulp baseline-accept # This replaces the baseline test results with the results obtained from gulp runtests.
gulp lint # Runs tslint on the TypeScript source.
gulp lint # Runs eslint on the TypeScript source.
gulp help # List the above commands.
```

Expand Down
6 changes: 5 additions & 1 deletion package.json
Expand Up @@ -54,13 +54,18 @@
"@types/through2": "latest",
"@types/travis-fold": "latest",
"@types/xml2js": "^0.4.0",
"@typescript-eslint/eslint-plugin": "latest",
"@typescript-eslint/parser": "latest",
"azure-devops-node-api": "^8.0.0",
"browser-resolve": "^1.11.2",
"browserify": "latest",
"chai": "latest",
"chalk": "latest",
"convert-source-map": "latest",
"del": "latest",
"eslint": "latest",
"eslint-formatter-autolinkable-stylish": "latest",
"eslint-plugin-microsoft-typescript": "0.1.11",
"fancy-log": "latest",
"fs-extra": "^6.0.1",
"gulp": "^4.0.0",
Expand All @@ -85,7 +90,6 @@
"source-map-support": "latest",
"through2": "latest",
"travis-fold": "latest",
"tslint": "latest",
"typescript": "next",
"vinyl": "latest",
"vinyl-sourcemaps-apply": "latest",
Expand Down
97 changes: 0 additions & 97 deletions scripts/tslint/formatters/autolinkableStylishFormatter.ts

This file was deleted.

0 comments on commit 55b8a38

Please sign in to comment.