Skip to content

Commit ea49cac

Browse files
authored
feat: bump all upgradable deps, fix related usage (#321)
1 parent 0ecdefa commit ea49cac

27 files changed

+2855
-2853
lines changed

.codesandbox/ci.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"node": "14",
23
"packages": [
34
"packages/*"
45
],

.eslintrc.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,17 @@ module.exports = {
55
// `strictNullChecks` is required
66
'@typescript-eslint/no-unnecessary-condition': 0,
77
},
8-
settings: {
9-
node: {
10-
allowModules: ['@babel/types', 'estree', 'unist'],
11-
},
12-
},
138
overrides: [
149
{
1510
files: '*.ts',
1611
rules: {
1712
'@typescript-eslint/consistent-type-imports': 2,
1813
},
1914
},
20-
{
21-
files: '**/*.{md,mdx}/**',
22-
rules: {
23-
'unicorn/filename-case': 0,
24-
},
25-
},
2615
{
2716
files: '*.{md,mdx}',
2817
rules: {
2918
'react/no-unescaped-entities': 1,
30-
// related to https://github.com/eslint/eslint/issues/14207
31-
'unicorn/filename-case': 0,
3219
},
3320
settings: {
3421
'mdx/code-blocks': true,

package.json

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,29 @@
2525
"typecov": "type-coverage"
2626
},
2727
"devDependencies": {
28-
"@1stg/lib-config": "^1.2.10",
29-
"@1stg/tslint-config": "^1.2.0",
30-
"@types/eslint": "^7.2.10",
28+
"@1stg/lib-config": "^3.0.0",
29+
"@1stg/tslint-config": "^2.0.0",
30+
"@types/eslint": "^7.2.14",
3131
"@types/eslint-plugin-markdown": "^2.0.0",
32-
"@types/jest": "^26.0.23",
33-
"@types/node": "^14.14.41",
34-
"@types/react": "^17.0.4",
35-
"@types/unist": "^2.0.3",
32+
"@types/jest": "^26.0.24",
33+
"@types/node": "^16.3.0",
34+
"@types/react": "^17.0.14",
35+
"@types/unist": "^2.0.5",
3636
"lerna": "^4.0.0",
3737
"npm-run-all": "^4.1.5",
3838
"react": "^17.0.2",
3939
"remark-validate-links": "^10.0.4",
40-
"ts-jest": "^26.5.5",
41-
"ts-node": "^9.1.1",
40+
"ts-jest": "^27.0.3",
41+
"ts-node": "^10.0.0",
4242
"tslint": "^6.1.3",
43-
"type-coverage": "^2.17.3",
44-
"typescript": "^4.2.4",
43+
"type-coverage": "^2.18.0",
44+
"typescript": "^4.3.5",
4545
"yarn-deduplicate": "^3.1.0"
4646
},
4747
"resolutions": {
48-
"@babel/core": "^7.13.16",
49-
"prettier": "^2.2.1",
50-
"tslib": "^2.2.0"
48+
"@babel/core": "^7.14.6",
49+
"prettier": "^2.3.2",
50+
"tslib": "^2.3.0"
5151
},
5252
"commitlint": {
5353
"extends": [
@@ -89,6 +89,10 @@
8989
[
9090
2
9191
]
92+
],
93+
[
94+
"validate-links",
95+
true
9296
]
9397
]
9498
},

packages/eslint-mdx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"dependencies": {
3636
"remark-mdx": "^1.6.22",
3737
"remark-parse": "^8.0.3",
38-
"tslib": "^2.2.0",
38+
"tslib": "^2.3.0",
3939
"unified": "^9.2.1"
4040
}
4141
}

packages/eslint-mdx/src/helpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export const arrayify = <T, R = T extends Array<infer S> ? S : T>(
161161
return arr
162162
}, [])
163163

164+
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- test coverage
164165
export const first = <T>(items: T[] | readonly T[]) => items && items[0]
165166

166167
export const last = <T>(items: T[] | readonly T[]) =>

packages/eslint-mdx/src/parser.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { AST, Linter } from 'eslint'
55
import remarkMdx from 'remark-mdx'
66
import remarkParse from 'remark-parse'
77
import unified from 'unified'
8-
import type { Node, Parent } from 'unist'
98

109
import {
1110
arrayify,
@@ -26,6 +25,8 @@ import { traverse } from './traverse'
2625
import type {
2726
Comment,
2827
LocationError,
28+
Node,
29+
Parent,
2930
ParserFn,
3031
ParserOptions,
3132
ParserServices,
@@ -47,7 +48,8 @@ export const DEFAULT_PARSER_OPTIONS: ParserOptions = {
4748
ecmaFeatures: {
4849
jsx: true,
4950
},
50-
ecmaVersion: new Date().getUTCFullYear() as Linter.ParserOptions['ecmaVersion'],
51+
ecmaVersion:
52+
new Date().getUTCFullYear() as Linter.ParserOptions['ecmaVersion'],
5153
sourceType: 'module',
5254
tokens: true,
5355
filePath: '__placeholder__.mdx',
@@ -80,7 +82,7 @@ export class Parser {
8082
}
8183

8284
normalizeJsxNode(node: Node, parent?: Parent, options = this._options) {
83-
const value = node.value as string
85+
const value = node.value
8486

8587
if (node.type !== 'jsx' || isComment(value)) {
8688
return node
@@ -235,9 +237,9 @@ export class Parser {
235237
}
236238

237239
/* istanbul ignore next */
238-
return ('ast' in program && program.ast
239-
? program
240-
: { ast: program }) as Linter.ESLintParseResult
240+
return (
241+
'ast' in program && program.ast ? program : { ast: program }
242+
) as Linter.ESLintParseResult
241243
}
242244

243245
// fix adjacent JSX nodes
@@ -247,7 +249,7 @@ export class Parser {
247249
node: Node,
248250
options: ParserOptions,
249251
): Node | Node[] {
250-
const value = node.value as string
252+
const value = node.value
251253

252254
let program: AST.Program
253255

@@ -281,7 +283,7 @@ export class Parser {
281283
return node
282284
}
283285

284-
const { expression } = (program.body[0] as unknown) as ExpressionStatement
286+
const { expression } = program.body[0] as unknown as ExpressionStatement
285287

286288
if (!isJsxNode(expression) || expression.children.length <= 1) {
287289
return node
@@ -339,7 +341,7 @@ export class Parser {
339341
this._services.JSXElementsWithHTMLComments.push(node)
340342
}
341343

342-
const value = node.value as string
344+
const value = node.value
343345

344346
const { loc, start, end } = normalizePosition(node.position)
345347

packages/eslint-mdx/src/traverse.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { Node, Parent } from 'unist'
2-
31
import { arrayify, last } from './helpers'
42
import { parser } from './parser'
53
import {
@@ -9,7 +7,7 @@ import {
97
isOpenTag,
108
isSelfClosingTag,
119
} from './regexp'
12-
import type { TraverseOptions, Traverser } from './types'
10+
import type { Node, Parent, TraverseOptions, Traverser } from './types'
1311

1412
export class Traverse {
1513
code: string
@@ -52,7 +50,7 @@ export class Traverse {
5250
// eslint-disable-next-line sonarjs/cognitive-complexity
5351
return nodes.reduce<Node[]>((acc, node, index) => {
5452
if (node.type === 'jsx') {
55-
const value = node.value as string
53+
const value = node.value
5654
if (isOpenTag(value)) {
5755
offset++
5856
hasOpenTag = true
@@ -138,12 +136,10 @@ export class Traverse {
138136
return
139137
}
140138

141-
let children = node.children as Node[]
142-
143-
if (children) {
139+
if ('children' in node) {
144140
const parent = node as Parent
145-
children = node.children = this.combineJsxNodes(children, parent)
146-
for (const child of children) {
141+
parent.children = this.combineJsxNodes(parent.children, parent)
142+
for (const child of parent.children) {
147143
this.traverse(child, parent)
148144
}
149145
}

packages/eslint-mdx/src/types.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import type { JSXElement, JSXFragment } from '@babel/types'
22
import type { AST, Linter } from 'eslint'
3-
import type { Node, Parent, Point } from 'unist'
3+
import type { Node as _Node, Parent as _Parent, Point } from 'unist'
4+
5+
export interface Node<T = string> extends _Node {
6+
value?: T
7+
}
8+
9+
export interface Parent<T = string> extends _Parent {
10+
children: Array<Node<T>>
11+
}
412

513
export type Arrayable<T> = T[] | readonly T[]
614

@@ -14,7 +22,7 @@ export declare type ValueOf<T> = T extends {
1422
? N
1523
: never
1624

17-
export type JsxNode = (JSXElement | JSXFragment) & { range: [number, number] }
25+
export type JsxNode = { range: [number, number] } & (JSXElement | JSXFragment)
1826

1927
export type ParserFn = (
2028
code: string,
@@ -23,10 +31,10 @@ export type ParserFn = (
2331

2432
export type ParserConfig =
2533
| {
26-
parseForESLint: ParserFn
34+
parse: ParserFn
2735
}
2836
| {
29-
parse: ParserFn
37+
parseForESLint: ParserFn
3038
}
3139

3240
export interface LocationError {
@@ -37,10 +45,10 @@ export interface LocationError {
3745
}
3846

3947
export interface ParserOptions extends Linter.ParserOptions {
40-
extensions?: string | string[]
41-
markdownExtensions?: string | string[]
48+
extensions?: string[] | string
49+
markdownExtensions?: string[] | string
4250
filePath?: string
43-
parser?: string | ParserConfig | ParserFn
51+
parser?: ParserConfig | ParserFn | string
4452
}
4553

4654
export type Traverser = (node: Node, parent?: Parent) => void

packages/eslint-mdx/typings.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
declare module 'remark-mdx' {
22
import type * as unified from 'unified'
3+
34
const mdx: unified.Attacher
45
export = mdx
56
}

packages/eslint-plugin-mdx/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
"dependencies": {
3636
"cosmiconfig": "^7.0.0",
3737
"eslint-mdx": "^1.13.0",
38-
"eslint-plugin-markdown": "^2.1.0",
38+
"eslint-plugin-markdown": "^2.2.0",
3939
"remark-mdx": "^1.6.22",
4040
"remark-parse": "^8.0.3",
4141
"remark-stringify": "^8.1.1",
42-
"synckit": "^0.1.5",
43-
"tslib": "^2.2.0",
42+
"synckit": "^0.2.0",
43+
"tslib": "^2.3.0",
4444
"unified": "^9.2.1",
4545
"vfile": "^4.2.1"
4646
}

0 commit comments

Comments
 (0)