-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
silence some incorrect unsafe-member-access errors (#88)
- Loading branch information
1 parent
e8d997d
commit 5f2e749
Showing
8 changed files
with
206 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.exports = { | ||
parser: "@typescript-eslint/parser", | ||
plugins: [ | ||
"@typescript-eslint", | ||
], | ||
parserOptions: { | ||
project: ["./tsconfig.json"], | ||
tsconfigRootDir: __dirname, | ||
extraFileExtensions: [".svelte"], | ||
}, | ||
settings: { | ||
"svelte3/typescript": require("typescript"), | ||
}, | ||
rules: { | ||
"@typescript-eslint/no-unsafe-member-access": "error", | ||
}, | ||
}; |
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,40 @@ | ||
<script lang="ts" context="module"> | ||
const context_safe = []; | ||
const context_unsafe: any = null; | ||
console.log(context_safe.length); | ||
console.log(context_unsafe.length); | ||
</script> | ||
|
||
<script lang="ts"> | ||
import { writable } from 'svelte/store'; | ||
import { external_safe, external_unsafe } from './external-file'; | ||
const instance_safe = []; | ||
const instance_unsafe: any = null; | ||
$: reactive_safe = instance_safe; | ||
$: reactive_unsafe = instance_unsafe; | ||
const writable_safe = writable([]); | ||
const writable_unsafe = writable(null as any); | ||
console.log(context_safe.length); | ||
console.log(context_unsafe.length); | ||
console.log(external_safe.length); | ||
console.log(external_unsafe.length); | ||
console.log(instance_safe.length); | ||
console.log(instance_unsafe.length); | ||
// console.log(reactive_safe.length); TODO, current limitation | ||
console.log(reactive_unsafe.length); | ||
// console.log($writable_safe.length); TODO, current limitation | ||
console.log($writable_unsafe.length); | ||
</script> | ||
|
||
{context_safe.length} | ||
{context_unsafe.length} | ||
{external_safe.length} | ||
{external_unsafe.length} | ||
{instance_safe.length} | ||
{instance_unsafe.length} | ||
<!-- {reactive_safe.length} TODO, current limitation --> | ||
{reactive_unsafe.length} | ||
<!-- {$writable_safe.length} TODO, current limitation --> | ||
{$writable_unsafe.length} |
90 changes: 90 additions & 0 deletions
90
test/samples/typescript-unsafe-member-access/expected.json
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,90 @@ | ||
[ | ||
{ | ||
"ruleId": "@typescript-eslint/no-unsafe-member-access", | ||
"severity": 2, | ||
"line": 6, | ||
"column": 14, | ||
"endLine": 6, | ||
"endColumn": 35 | ||
}, | ||
{ | ||
"ruleId": "@typescript-eslint/no-unsafe-member-access", | ||
"severity": 2, | ||
"line": 20, | ||
"column": 14, | ||
"endLine": 20, | ||
"endColumn": 35 | ||
}, | ||
{ | ||
"ruleId": "@typescript-eslint/no-unsafe-member-access", | ||
"severity": 2, | ||
"line": 22, | ||
"column": 14, | ||
"endLine": 22, | ||
"endColumn": 36 | ||
}, | ||
{ | ||
"ruleId": "@typescript-eslint/no-unsafe-member-access", | ||
"severity": 2, | ||
"line": 24, | ||
"column": 14, | ||
"endLine": 24, | ||
"endColumn": 36 | ||
}, | ||
{ | ||
"ruleId": "@typescript-eslint/no-unsafe-member-access", | ||
"severity": 2, | ||
"line": 26, | ||
"column": 14, | ||
"endLine": 26, | ||
"endColumn": 36 | ||
}, | ||
{ | ||
"ruleId": "@typescript-eslint/no-unsafe-member-access", | ||
"severity": 2, | ||
"line": 28, | ||
"column": 14, | ||
"endLine": 28, | ||
"endColumn": 37 | ||
}, | ||
{ | ||
"ruleId": "@typescript-eslint/no-unsafe-member-access", | ||
"severity": 2, | ||
"line": 32, | ||
"column": 2, | ||
"endLine": 32, | ||
"endColumn": 23 | ||
}, | ||
{ | ||
"ruleId": "@typescript-eslint/no-unsafe-member-access", | ||
"severity": 2, | ||
"line": 34, | ||
"column": 2, | ||
"endLine": 34, | ||
"endColumn": 24 | ||
}, | ||
{ | ||
"ruleId": "@typescript-eslint/no-unsafe-member-access", | ||
"severity": 2, | ||
"line": 36, | ||
"column": 2, | ||
"endLine": 36, | ||
"endColumn": 24 | ||
}, | ||
{ | ||
"ruleId": "@typescript-eslint/no-unsafe-member-access", | ||
"severity": 2, | ||
"line": 38, | ||
"column": 2, | ||
"endLine": 38, | ||
"endColumn": 24 | ||
}, | ||
{ | ||
"ruleId": "@typescript-eslint/no-unsafe-member-access", | ||
"severity": 2, | ||
"line": 40, | ||
"column": 2, | ||
"endLine": 40, | ||
"endColumn": 25 | ||
} | ||
] |
2 changes: 2 additions & 0 deletions
2
test/samples/typescript-unsafe-member-access/external-file.ts
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,2 @@ | ||
export const external_safe = ['hi']; | ||
export const external_unsafe: any = null; |
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 @@ | ||
{ | ||
"include": ["**/*"] | ||
} |
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