Skip to content

Commit ae59913

Browse files
committed
chore: improve type coverage
1 parent 43e448b commit ae59913

File tree

11 files changed

+732
-613
lines changed

11 files changed

+732
-613
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ deploy:
5050
branch: develop
5151

5252
after_script:
53-
- yarn add -D @codechecks/client @codechecks/build-size-watcher @codechecks/type-coverage-watcher -W
53+
- yarn add -D @codechecks/client @codechecks/build-size-watcher typecov -W
5454
- yarn codechecks

codechecks.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ checks:
99
name: 'eslint-plugin-mdx pkg size'
1010
files:
1111
- path: 'packages/eslint-plugin-mdx/lib/**/*.*'
12-
- name: type-coverage-watcher
12+
- name: typecov
1313
options:
1414
atLeast: 99
15+
ignoreAsAssertion: true
1516
ignoreCatch: true
1617
ignoreFiles:
1718
- '*.d.ts'

package.json

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,27 @@
2424
"pretest": "yarn clean",
2525
"release": "lerna publish --conventional-commits --create-release github --yes",
2626
"test": "ts-node --skip-ignore node_modules/.bin/jest",
27-
"type-coverage": "type-coverage --cache --detail --ignore-catch --ignore-files '**/*.d.ts' --strict --update"
27+
"typecov": "type-coverage"
2828
},
2929
"devDependencies": {
30-
"@1stg/lib-config": "^1.0.5",
31-
"@1stg/tslint-config": "^1.0.0",
30+
"@1stg/lib-config": "^1.1.8",
31+
"@1stg/tslint-config": "^1.0.1",
3232
"@types/eslint": "^7.2.6",
3333
"@types/jest": "^26.0.20",
3434
"@types/node": "^14.14.31",
3535
"@types/react": "^17.0.2",
36-
"@types/rebass": "^4.0.7",
36+
"@types/rebass": "^4.0.8",
3737
"@types/unist": "^2.0.3",
3838
"eslint-mdx": "link:packages/eslint-mdx/src",
3939
"eslint-plugin-mdx": "link:packages/eslint-plugin-mdx/src",
4040
"lerna": "^3.22.1",
4141
"npm-run-all": "^4.1.5",
4242
"react": "^17.0.1",
43-
"ts-jest": "^26.5.1",
43+
"ts-jest": "^26.5.2",
4444
"ts-node": "^9.1.1",
4545
"tslint": "^6.1.3",
46-
"type-coverage": "^2.15.1",
47-
"typescript": "^4.3.0-dev.20210220",
46+
"type-coverage": "^2.16.3",
47+
"typescript": "^4.2.2",
4848
"yarn-deduplicate": "^3.1.0"
4949
},
5050
"resolutions": {
@@ -87,6 +87,15 @@
8787
]
8888
},
8989
"typeCoverage": {
90-
"atLeast": 97.96
90+
"atLeast": 99.37,
91+
"cache": true,
92+
"detail": true,
93+
"ignoreAsAssertion": true,
94+
"ignoreCatch": true,
95+
"ignoreFiles": [
96+
"**/*.d.ts"
97+
],
98+
"strict": true,
99+
"update": true
91100
}
92101
}

packages/eslint-mdx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
"remark-mdx": "^1.6.22",
3838
"remark-parse": "^8.0.3",
3939
"tslib": "^2.1.0",
40-
"unified": "^9.1.0"
40+
"unified": "^9.2.1"
4141
}
4242
}

packages/eslint-mdx/src/parser.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import {
2626
Parent,
2727
ParserFn,
2828
ParserOptions,
29+
ParserServices,
2930
} from './types'
3031

3132
export const mdProcessor = unified().use(remarkParse).freeze()
@@ -66,9 +67,7 @@ export class Parser {
6667
private _ast: AST.Program
6768

6869
// @internal
69-
private _services: {
70-
JSXElementsWithHTMLComments: Node[]
71-
}
70+
private _services: ParserServices
7271

7372
// @internal
7473
private readonly _options = DEFAULT_PARSER_OPTIONS

packages/eslint-mdx/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ export interface Comment {
5757
}
5858
origin: string
5959
}
60+
61+
export interface ParserServices {
62+
JSXElementsWithHTMLComments: Node[]
63+
}

packages/eslint-plugin-mdx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"remark-parse": "^8.0.3",
4141
"remark-stringify": "^8.1.1",
4242
"tslib": "^2.1.0",
43-
"unified": "^9.1.0",
43+
"unified": "^9.2.1",
4444
"vfile": "^4.2.1"
4545
},
4646
"optionalDependencies": {

packages/eslint-plugin-mdx/src/rules/no-jsx-html-comments.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Rule } from 'eslint'
2-
import { Comment, JSX_TYPES, JsxType } from 'eslint-mdx'
2+
import { Comment, JSX_TYPES, JsxType, ParserServices } from 'eslint-mdx'
33

44
import { ExpressionStatementWithParent } from './types'
55

@@ -19,9 +19,8 @@ export const noJsxHtmlComments: Rule.RuleModule = {
1919
create(context) {
2020
return {
2121
ExpressionStatement(node: ExpressionStatementWithParent) {
22-
const invalidNodes: Array<import('unist').Node> =
23-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
24-
context.parserServices.JSXElementsWithHTMLComments
22+
const invalidNodes = (context.parserServices as ParserServices)
23+
.JSXElementsWithHTMLComments
2524

2625
if (
2726
!JSX_TYPES.includes(node.expression.type as JsxType) ||

packages/eslint-plugin-mdx/src/rules/no-unescaped-entities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ const EXPRESSION = 'Literal, JSXText'
3838
export const noUnescapedEntities: Rule.RuleModule = {
3939
...reactNoUnescapedEntities,
4040
create(context) {
41-
const configuration: {
41+
const configuration = (context.options[0] || {}) as {
4242
forbid?: EscapeEntity[]
43-
} = context.options[0] || {}
43+
}
4444
const entities = configuration.forbid || DEFAULTS
4545
return {
4646
// eslint-disable-next-line sonarjs/cognitive-complexity

packages/eslint-plugin-mdx/src/rules/remark.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ export const remark: Rule.RuleModule = {
2323
const filename = context.getFilename()
2424
const extname = path.extname(filename)
2525
const sourceCode = context.getSourceCode()
26-
const options = context.parserOptions
26+
const options = context.parserOptions as {
27+
extensions: string[]
28+
markdownExtensions: string[]
29+
}
2730
const isMdx = DEFAULT_EXTENSIONS.concat(options.extensions || []).includes(
2831
extname,
2932
)

0 commit comments

Comments
 (0)