-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eslint-config-universe] Add more lint rules for TypeScript (#6847)
* [eslint-config-universe] Add more lint rules for TypeScript * expotools check-packages --no-build --no-test --fix-lint * expotools check-packages
- Loading branch information
Showing
101 changed files
with
679 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
packages/eslint-config-universe/__tests__/__snapshots__/typescript-analysis-test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`lints: fixtures/typescript-analysis-00.ts 1`] = ` | ||
Object { | ||
"errorCount": 0, | ||
"fixableErrorCount": 0, | ||
"fixableWarningCount": 0, | ||
"messages": Array [], | ||
"output": "type T = { | ||
a?: { | ||
b?: { | ||
c: string; | ||
method?: () => void; | ||
}; | ||
}; | ||
}; | ||
export function myFunc(foo: T | null) { | ||
return foo?.a?.b?.c; | ||
}", | ||
"warningCount": 0, | ||
} | ||
`; | ||
exports[`lints: fixtures/typescript-analysis-01.ts 1`] = ` | ||
Object { | ||
"errorCount": 1, | ||
"fixableErrorCount": 0, | ||
"fixableWarningCount": 0, | ||
"messages": Array [ | ||
Object { | ||
"column": 1, | ||
"endColumn": 2, | ||
"endLine": 6, | ||
"line": 4, | ||
"message": "For-in loops over arrays are forbidden. Use for-of or array.forEach instead.", | ||
"messageId": "forInViolation", | ||
"nodeType": "ForInStatement", | ||
"ruleId": "@typescript-eslint/no-for-in-array", | ||
"severity": 2, | ||
}, | ||
], | ||
"source": "export const arr = [1, 2, 3]; | ||
let sum = ''; | ||
for (const b in arr) { | ||
sum += b; | ||
} | ||
export { sum };", | ||
"warningCount": 0, | ||
} | ||
`; | ||
exports[`lints: fixtures/typescript-analysis-02.ts 1`] = ` | ||
Object { | ||
"errorCount": 0, | ||
"fixableErrorCount": 0, | ||
"fixableWarningCount": 0, | ||
"messages": Array [], | ||
"output": "export function getBlah(): string | null { | ||
const a: string | null = Math.random() ? '' : null; | ||
const b: string | null = Math.random() ? '' : null; | ||
return a ?? b; | ||
}", | ||
"warningCount": 0, | ||
} | ||
`; | ||
exports[`lints: fixtures/typescript-analysis-03.ts 1`] = ` | ||
Object { | ||
"errorCount": 0, | ||
"fixableErrorCount": 0, | ||
"fixableWarningCount": 0, | ||
"messages": Array [ | ||
Object { | ||
"column": 9, | ||
"endColumn": 10, | ||
"endLine": 2, | ||
"line": 2, | ||
"message": "Expected an error object to be thrown.", | ||
"messageId": "object", | ||
"nodeType": "Literal", | ||
"ruleId": "@typescript-eslint/no-throw-literal", | ||
"severity": 1, | ||
}, | ||
], | ||
"source": "export function wat() { | ||
throw 3; | ||
}", | ||
"warningCount": 1, | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const blah = (): Array<string> => { | ||
return ['1']; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const blah = 3!!; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const numberTest: Number | null = null; | ||
export const booleanTest: Boolean | null = null; | ||
export const symbolTest: Symbol | null = null; | ||
export const objectTest: Object | null = null; | ||
export const stringTest: String | null = null; | ||
export const objectShorthandTest: {} | null = null; |
Oops, something went wrong.