Skip to content

Upgrade tslist to eslint #261

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
202 changes: 202 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
/*
👋 Hi! This file was autogenerated by tslint-to-eslint-config.
https://github.com/typescript-eslint/tslint-to-eslint-config

It represents the closest reasonable ESLint configuration to this
project's original TSLint configuration.

We recommend eventually switching this configuration to extend from
the recommended rulesets in typescript-eslint.
https://github.com/typescript-eslint/tslint-to-eslint-config/blob/master/docs/FAQs.md

Happy linting! 💖
*/
module.exports = {
"env": {
"node": true
},
"extends": [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
"prettier",
"prettier/@typescript-eslint"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"import",
"jsdoc",
"prefer-arrow"
],
"rules": {
"@typescript-eslint/adjacent-overload-signatures": "error",
"@typescript-eslint/array-type": [
"warn",
{
"default": "array"
}
],
"@typescript-eslint/ban-types": [
"error",
{
"types": {
"Object": {
"message": "Avoid using the `Object` type. Did you mean `object`?"
},
"Function": {
"message": "Avoid using the `Function` type. Prefer a specific function type, like `() => void`."
},
"Boolean": {
"message": "Avoid using the `Boolean` type. Did you mean `boolean`?"
},
"Number": {
"message": "Avoid using the `Number` type. Did you mean `number`?"
},
"String": {
"message": "Avoid using the `String` type. Did you mean `string`?"
},
"Symbol": {
"message": "Avoid using the `Symbol` type. Did you mean `symbol`?"
}
}
}
],
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/member-delimiter-style": [
"off",
{
"multiline": {
"delimiter": "none",
"requireLast": true
},
"singleline": {
"delimiter": "semi",
"requireLast": false
}
}
],
"@typescript-eslint/naming-convention": "off",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-parameter-properties": "off",
"@typescript-eslint/no-unnecessary-type-assertion": "warn",
"@typescript-eslint/no-unused-expressions": "error",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unsafe-return": "warn",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-var-requires": "warn",
"@typescript-eslint/prefer-for-of": "off",
"@typescript-eslint/prefer-function-type": "error",
"@typescript-eslint/prefer-namespace-keyword": "error",
"@typescript-eslint/prefer-regexp-exec": "warn",
"@typescript-eslint/restrict-plus-operands": "warn",
"@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/semi": [
"off",
null
],
"@typescript-eslint/triple-slash-reference": [
"error",
{
"path": "always",
"types": "prefer-import",
"lib": "always"
}
],
"@typescript-eslint/unbound-method": "warn",
"@typescript-eslint/unified-signatures": "error",
"arrow-parens": [
"off",
"always"
],
"brace-style": [
"off",
"off"
],
"comma-dangle": "off",
"complexity": "off",
"constructor-super": "error",
"eqeqeq": [
"error",
"smart"
],
"guard-for-in": "error",
"id-blacklist": [
"error",
"any",
"Number",
"number",
"String",
// "string",
"Boolean",
// "boolean",
"Undefined",
// "undefined"
],
"id-match": "error",
"import/no-default-export": "error",
"import/order": "off",
"jsdoc/check-alignment": "error",
"jsdoc/check-indentation": "warn",
"jsdoc/newline-after-description": "error",
"max-classes-per-file": [
"error",
1
],
"max-len": "off",
"new-parens": "error",
"no-bitwise": "error",
"no-caller": "error",
"no-cond-assign": "error",
"no-console": "off",
"no-debugger": "error",
"no-empty": "error",
"no-eval": "error",
"no-fallthrough": "off",
"no-invalid-this": "off",
"no-new-wrappers": "error",
"no-shadow": [
"warn",
{
"hoist": "all"
}
],
"no-throw-literal": "error",
"no-trailing-spaces": "off",
"no-undef-init": "error",
"no-underscore-dangle": "error",
"no-unsafe-finally": "error",
"no-unused-labels": "error",
"no-var": "error",
"object-shorthand": "error",
"one-var": [
"error",
"never"
],
"prefer-arrow/prefer-arrow-functions": "warn",
"prefer-const": "error",
"quote-props": "off",
"radix": "error",
"spaced-comment": [
"error",
"always",
{
"markers": [
"/"
]
}
],
"use-isnan": "error",
"valid-typeof": "off"
}
};
23 changes: 18 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -12,20 +12,26 @@
"bin": {
"patch-package": "./index.js"
},
"config": {
"allsrc": "src{/**,}/*.ts integration-tests{/**,}/*.ts property-based-tests{/**,}/*.ts",
"prettier_options": "--no-semi --trailing-comma=all --arrow-parens avoid"
},
"scripts": {
"precommit": "tsc --noEmit && lint-staged",
"prepublishOnly": "yarn run clean && yarn run build",
"build": "tsc --project tsconfig.build.json",
"new-integration-test": "ts-node integration-tests/newIntegrationTest.ts",
"clean": "rimraf dist patch-package.test*.tgz",
"format": "prettier --no-semi --write --trailing-comma=all src{/**,}/*.ts integration-tests{/**,}/*.ts property-based-tests{/**,}/*.ts",
"format": "prettier $npm_package_config_prettier_options --write $npm_package_config_allsrc",
"format:verify": "prettier $npm_package_config_prettier_options --list-different",
"lint": "eslint $npm_package_config_allsrc",
"prepack": "rimraf dist/**/*.test.js",
"test": "./run-tests.sh --runInBand"
},
"lint-staged": {
"*.ts": [
"tslint -c tslint.json -p tsconfig.json",
"prettier --no-semi --trailing-comma=all --list-different"
"eslint",
"yarn format:verify"
]
},
"jest": {
@@ -55,15 +61,22 @@
"@types/rimraf": "^2.0.2",
"@types/semver": "^5.5.0",
"@types/tmp": "^0.0.34",
"@typescript-eslint/eslint-plugin": "^4.1.0",
"@typescript-eslint/parser": "^4.1.0",
"eslint": "^7.8.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsdoc": "^30.4.0",
"eslint-plugin-prefer-arrow": "^1.2.2",
"husky": "^1.3.1",
"jest": "^24.5.0",
"lint-staged": "^8.1.5",
"np": "^6.2.0",
"prettier": "^1.18.2",
"prettier": "^2.1.1",
"randomstring": "^1.1.5",
"ts-jest": "^24.0.0",
"ts-node": "8.0.3",
"tslint": "^5.14.0",
"tslint": "^6.1.3",
"typescript": "^3.6.3"
},
"dependencies": {
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ const packageNames = argv._

console.log(
chalk.bold("patch-package"),
// tslint:disable-next-line:no-var-requires
// eslint-disable-next-line @typescript-eslint/no-var-requires
require(join(__dirname, "../package.json")).version,
)

2 changes: 1 addition & 1 deletion src/makePatch.ts
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ export function makePatch({
)).version as string

// copy .npmrc/.yarnrc in case packages are hosted in private registry
[".npmrc", ".yarnrc"].forEach(rcFile => {
;[".npmrc", ".yarnrc"].forEach(rcFile => {
const rcPath = join(appPath, rcFile)
if (existsSync(rcPath)) {
copySync(rcPath, join(tmpRepo.name, rcFile))
4 changes: 3 additions & 1 deletion src/packageIsDevDependency.ts
Original file line number Diff line number Diff line change
@@ -14,5 +14,7 @@ export function packageIsDevDependency({
return false
}
const { devDependencies } = require(packageJsonPath)
return Boolean(devDependencies && devDependencies[packageDetails.packageNames[0]])
return Boolean(
devDependencies && devDependencies[packageDetails.packageNames[0]],
)
}
2 changes: 1 addition & 1 deletion src/patch/apply.ts
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ export const executeEffects = (
}

function isExecutable(fileMode: number) {
// tslint:disable-next-line:no-bitwise
// eslint-disable-next-line no-bitwise
return (fileMode & 0b001_000_000) > 0
}

2 changes: 1 addition & 1 deletion src/patch/parse.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable
/* eslint-disable */

import { parsePatchFile } from "../patch/parse"

2 changes: 1 addition & 1 deletion src/patch/parse.ts
Original file line number Diff line number Diff line change
@@ -394,7 +394,7 @@ export function interpretParsedPatchFile(files: FileDeets[]): ParsedPatchFile {
}

function parseFileMode(mode: string): FileMode {
// tslint:disable-next-line:no-bitwise
// eslint-disable-next-line no-bitwise
const parsedMode = parseInt(mode, 8) & 0o777
if (
parsedMode !== NON_EXECUTABLE_FILE_MODE &&
68 changes: 34 additions & 34 deletions src/spawnSafe.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import { sync as spawnSync } from "cross-spawn"
import { SpawnOptions } from "child_process"
export interface SpawnSafeOptions extends SpawnOptions {
throwOnError?: boolean
logStdErrOnError?: boolean
}
const defaultOptions: SpawnSafeOptions = {
logStdErrOnError: true,
throwOnError: true,
}
export const spawnSafeSync = (
command: string,
args?: string[],
options?: SpawnSafeOptions,
) => {
const mergedOptions = Object.assign({}, defaultOptions, options)
const result = spawnSync(command, args, options)
if (result.error || result.status !== 0) {
if (mergedOptions.logStdErrOnError) {
if (result.stderr) {
console.error(result.stderr.toString())
} else if (result.error) {
console.error(result.error)
}
}
if (mergedOptions.throwOnError) {
throw result
}
}
return result
}
import { sync as spawnSync } from "cross-spawn"
import { SpawnOptions } from "child_process"

export interface SpawnSafeOptions extends SpawnOptions {
throwOnError?: boolean
logStdErrOnError?: boolean
}

const defaultOptions: SpawnSafeOptions = {
logStdErrOnError: true,
throwOnError: true,
}

export const spawnSafeSync = (
command: string,
args?: string[],
options?: SpawnSafeOptions,
) => {
const mergedOptions = Object.assign({}, defaultOptions, options)
const result = spawnSync(command, args, options)
if (result.error || result.status !== 0) {
if (mergedOptions.logStdErrOnError) {
if (result.stderr) {
console.error(result.stderr.toString())
} else if (result.error) {
console.error(result.error)
}
}
if (mergedOptions.throwOnError) {
throw result
}
}
return result
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why prettier rewrote all of this file. Probably a line-break replacement.

984 changes: 938 additions & 46 deletions yarn.lock

Large diffs are not rendered by default.