-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Use ESLint to run TSlint #3887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ESLint to run TSlint #3887
Changes from all commits
6a7911f
e627327
bcec099
2bc3839
046a7c8
4a0c0d6
925700d
66d0e22
dc8f430
dbb983a
2fb1ffe
7718a52
f893795
fd9aa13
b4bfbfa
43d4aee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "extends": [ | ||
| "./packages/eslint-config" | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,10 +34,10 @@ | |
| "dist:css": "css-dist lib/css/*.css", | ||
| "dist:variables": "generate-css-variables common/_colors.scss common/_color-aliases.scss common/_variables.scss", | ||
| "dist:verify": "assert-package-layout", | ||
| "lint": "run-p lint:scss lint:ts", | ||
| "lint": "run-p lint:scss lint:es", | ||
| "lint:scss": "sass-lint", | ||
| "lint:ts": "ts-lint", | ||
| "lint-fix": "ts-lint --fix", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this syntax was intentional since we don't intend to run this command with |
||
| "lint:es": "es-lint", | ||
| "lint-fix": "es-lint --fix", | ||
| "test": "run-s test:typeCheck test:iso test:karma", | ||
| "test:typeCheck": "tsc -p ./test", | ||
| "test:iso": "mocha test/isotest.js", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| /* | ||
| * Copyright 2019 Palantir Technologies, Inc. All rights reserved. | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| module.exports = { | ||
| env: { | ||
| browser: true, | ||
| mocha: true, | ||
| node: true, | ||
| }, | ||
| plugins: [ | ||
| "@typescript-eslint", | ||
| "@typescript-eslint/tslint", | ||
| ], | ||
| parser: "@typescript-eslint/parser", | ||
| parserOptions: { | ||
| sourceType: "module", | ||
| ecmaFeatures: { | ||
| jsx: true, | ||
| }, | ||
| project: "**/tsconfig.json", | ||
| }, | ||
| rules: { | ||
| // run the tslint rules which are not yet converted (run inside eslint) | ||
| "@typescript-eslint/tslint/config": ["error", { | ||
| "lintFile": "../../tslint.json", | ||
| }], | ||
| }, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "name": "@blueprintjs/eslint-config", | ||
| "version": "0.1.0", | ||
| "description": "ESLint configuration for @blueprintjs packages", | ||
| "dependencies": { | ||
| "@typescript-eslint/eslint-plugin": "^2.15.0", | ||
| "@typescript-eslint/eslint-plugin-tslint": "^2.15.0", | ||
| "@typescript-eslint/parser": "^2.15.0", | ||
| "eslint": "^6.7.2" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "[email protected]:palantir/blueprint.git", | ||
| "directory": "packages/eslint-config" | ||
| }, | ||
| "author": "Palantir Technologies", | ||
| "license": "Apache-2.0" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| /** | ||
| * @license Copyright 2019 Palantir Technologies, Inc. All rights reserved. | ||
| * @fileoverview Runs ESLint, with support for generating JUnit report | ||
| */ | ||
|
|
||
| // @ts-check | ||
| "use strict"; | ||
|
|
||
| const path = require("path"); | ||
| const fs = require("fs"); | ||
| const { junitReportPath } = require("./utils"); | ||
| const { spawn, execSync } = require("child_process"); | ||
| const glob = require("glob"); | ||
|
|
||
| let format = "codeframe"; | ||
| let out; | ||
| let outputStream = process.stdout; | ||
| if (process.env.JUNIT_REPORT_PATH != null) { | ||
| format = "junit"; | ||
| out = junitReportPath("eslint"); | ||
| console.info(`TSLint report will appear in ${out}`); | ||
| outputStream = fs.createWriteStream(out, { flags: "w+" }); | ||
| } | ||
|
|
||
| const gitRoot = execSync("git rev-parse --show-toplevel").toString().trim(); | ||
| const commandLineOptions = ["-c", path.join(gitRoot, "./.eslintrc.json"), "--color", "-f", format]; | ||
| if (process.argv.includes("--fix")) { | ||
| commandLineOptions.push("--fix") | ||
| } | ||
|
|
||
| // ESLint will fail if provided with no files, so we expand the glob before running it | ||
| const fileGlob = "{src,test}/**/*.tsx"; | ||
| const absoluteFileGlob = path.resolve(process.cwd(), fileGlob); | ||
| const anyFilesToLint = glob.sync(absoluteFileGlob) | ||
| if (anyFilesToLint.length === 0) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. curious why we need to add this... does eslint complain if there are no files? |
||
| console.log(`Not running ESLint because no files match the glob "${fileGlob}"`) | ||
| process.exit(); | ||
| } | ||
|
|
||
| const eslint = spawn("eslint", [...commandLineOptions, absoluteFileGlob]); | ||
|
|
||
| eslint.stdout.pipe(outputStream); | ||
| eslint.stderr.pipe(process.stderr); | ||
|
|
||
| eslint.on("close", code => { | ||
| process.exitCode = code; | ||
| }); | ||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yarn lint-fixdoesn't match what's in the next file. I would revert the script name change and keep it aslint-fix