-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
fix: make xo happy #145
fix: make xo happy #145
Changes from 4 commits
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 |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import {WriteStream} from 'node:tty'; | ||
import type {WriteStream} from 'node:tty'; | ||
|
||
export interface Options { | ||
export type Options = { | ||
/** | ||
Whether `process.argv` should be sniffed for `--color` and `--no-color` flags. | ||
|
||
@default true | ||
*/ | ||
readonly sniffFlags?: boolean; | ||
} | ||
}; | ||
|
||
/** | ||
Levels: | ||
|
@@ -21,7 +21,7 @@ export type ColorSupportLevel = 0 | 1 | 2 | 3; | |
/** | ||
Detect whether the terminal supports color. | ||
*/ | ||
export interface ColorSupport { | ||
export type ColorSupport = { | ||
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. This is not the same. What was the XO error message about? 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.
|
||
/** | ||
The color level. | ||
*/ | ||
|
@@ -41,7 +41,7 @@ export interface ColorSupport { | |
Whether Truecolor 16 million colors are supported. | ||
*/ | ||
has16m: boolean; | ||
} | ||
}; | ||
|
||
export type ColorInfo = ColorSupport | false; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import os from 'node:os'; | |
import tty from 'node:tty'; | ||
|
||
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js | ||
function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) { | ||
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) { | ||
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 don't see this as an improvement. What was the XO error? 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.
|
||
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); | ||
const position = argv.indexOf(prefix + flag); | ||
const terminatorPosition = argv.indexOf('--'); | ||
|
@@ -138,10 +138,13 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) { | |
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); | ||
|
||
switch (env.TERM_PROGRAM) { | ||
case 'iTerm.app': | ||
case 'iTerm.app': { | ||
return version >= 3 ? 3 : 2; | ||
case 'Apple_Terminal': | ||
} | ||
|
||
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. Was this an error? 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.
|
||
case 'Apple_Terminal': { | ||
return 2; | ||
} | ||
// No default | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import {stdout, stderr} from 'node:process'; | ||
import {expectType} from 'tsd'; | ||
import supportsColor, {createSupportsColor, Options, ColorInfo} from './index.js'; | ||
import type {Options, ColorInfo} from './index.d'; | ||
import supportsColor, {createSupportsColor} from './index.js'; | ||
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. This should be a single import |
||
|
||
const options: Options = {}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,6 @@ | |
"import-fresh": "^3.3.0", | ||
"tsd": "^0.18.0", | ||
"typescript": "^4.4.3", | ||
"xo": "^0.44.0" | ||
"xo": "^0.53.1" | ||
} | ||
} |
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.
I don't see how this fixes or improves anything, what was the XO error?
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.
Error - Optional chainings are not supported until Node.js 14.0.0. The configured version range is '^12.17.0 || ^14.13 || >=16.0.0'. (n/no-unsupported-features/es-syntax)