Skip to content

Commit bece392

Browse files
committed
chore: update tsslint to 2.0.1
1 parent 549b5d7 commit bece392

File tree

2 files changed

+44
-44
lines changed

2 files changed

+44
-44
lines changed

pnpm-lock.yaml

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsslint.config.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export default defineConfig({
88
rules: {
99
'number-equality'({
1010
typescript: ts,
11-
sourceFile,
12-
reportWarning,
13-
languageService,
11+
file,
12+
program,
13+
report,
1414
}) {
15-
const checker = languageService.getProgram()!.getTypeChecker();
16-
ts.forEachChild(sourceFile, function visit(node) {
15+
const checker = program.getTypeChecker();
16+
ts.forEachChild(file, function visit(node) {
1717
if (
1818
ts.isBinaryExpression(node) &&
1919
node.operatorToken.kind === ts.SyntaxKind.EqualsEqualsEqualsToken &&
@@ -22,18 +22,18 @@ export default defineConfig({
2222
) {
2323
const type = checker.getTypeAtLocation(node.left);
2424
if (type.flags & ts.TypeFlags.Number) {
25-
reportWarning(
25+
report(
2626
`Replace "x === 0" with "!x" for numeric variables to clarify boolean usage.`,
27-
node.getStart(sourceFile),
27+
node.getStart(file),
2828
node.getEnd(),
2929
).withFix('Use exclamation instead', () => [
3030
{
31-
fileName: sourceFile.fileName,
31+
fileName: file.fileName,
3232
textChanges: [
3333
{
34-
newText: `!(${node.left.getText(sourceFile)})`,
34+
newText: `!(${node.left.getText(file)})`,
3535
span: {
36-
start: node.getStart(sourceFile),
36+
start: node.getStart(file),
3737
length: node.getWidth(),
3838
},
3939
},
@@ -47,13 +47,13 @@ export default defineConfig({
4747
},
4848
'object-equality'({
4949
typescript: ts,
50-
sourceFile,
51-
reportWarning,
52-
languageService,
50+
file,
51+
program,
52+
report,
5353
}) {
54-
const checker = languageService.getProgram()!.getTypeChecker();
54+
const checker = program.getTypeChecker();
5555
const checkFlags = [ts.TypeFlags.Undefined, ts.TypeFlags.Null];
56-
ts.forEachChild(sourceFile, function visit(node) {
56+
ts.forEachChild(file, function visit(node) {
5757
if (
5858
ts.isPrefixUnaryExpression(node) &&
5959
node.operator === ts.SyntaxKind.ExclamationToken
@@ -67,38 +67,38 @@ export default defineConfig({
6767
ts.isPrefixUnaryExpression(node.parent) &&
6868
node.parent.operator === ts.SyntaxKind.ExclamationToken
6969
) {
70-
reportWarning(
70+
report(
7171
`Do not use "!!" for a variable of type "object | ${flagText}". Replace with "!== ${flagText}" for clarity.`,
72-
node.parent.getStart(sourceFile),
72+
node.parent.getStart(file),
7373
node.getEnd(),
7474
).withFix(`Replace with !== ${flagText}`, () => [
7575
{
76-
fileName: sourceFile.fileName,
76+
fileName: file.fileName,
7777
textChanges: [
7878
{
79-
newText: `${node.operand.getText(sourceFile)} !== ${flagText}`,
79+
newText: `${node.operand.getText(file)} !== ${flagText}`,
8080
span: {
81-
start: node.parent.getStart(sourceFile),
81+
start: node.parent.getStart(file),
8282
length:
83-
node.getEnd() - node.parent.getStart(sourceFile),
83+
node.getEnd() - node.parent.getStart(file),
8484
},
8585
},
8686
],
8787
},
8888
]);
8989
} else {
90-
reportWarning(
90+
report(
9191
`Do not use "!" for a variable of type "object | ${flagText}". Replace with "=== ${flagText}" for clarity.`,
92-
node.getStart(sourceFile),
92+
node.getStart(file),
9393
node.getEnd(),
9494
).withFix(`Replace with === ${flagText}`, () => [
9595
{
96-
fileName: sourceFile.fileName,
96+
fileName: file.fileName,
9797
textChanges: [
9898
{
99-
newText: `${node.operand.getText(sourceFile)} === ${flagText}`,
99+
newText: `${node.operand.getText(file)} === ${flagText}`,
100100
span: {
101-
start: node.getStart(sourceFile),
101+
start: node.getStart(file),
102102
length: node.getWidth(),
103103
},
104104
},

0 commit comments

Comments
 (0)