Skip to content

Commit 96fc83a

Browse files
committed
refactor: use union @1stg/lib-config to simplify devDependencies
1 parent 86a73a8 commit 96fc83a

19 files changed

+399
-558
lines changed

.eslintcache

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ tsNode.register({
1111
module.exports = {
1212
root: true,
1313
extends: ['@1stg/eslint-config/recommended'],
14-
settings: {
15-
node: {
16-
allowModules: ['@babel/types', 'estree', 'unist'],
17-
},
18-
},
1914
rules: {
2015
'@typescript-eslint/no-unnecessary-condition': 0,
2116
'@typescript-eslint/unbound-method': 0, // See https://github.com/typescript-eslint/typescript-eslint/issues/636

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*.log
22
*.tsbuildinfo
3+
.*cache
34
.changelog
45
.type-coverage
56
coverage

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ before_deploy:
3434
- cp -f README.md packages/eslint-mdx
3535
- cp -f README.md packages/eslint-plugin-mdx
3636
- 'git add --all && git commit -m "docs: update README" || echo "nothing changed to commit"'
37-
- yarn lerna-changelog
37+
- yarn global add lerna-changelog
38+
- lerna-changelog
3839

3940
deploy:
4041
- provider: script

package.json

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,44 +24,28 @@
2424
"type-coverage": "type-coverage --cache --detail --ignore-catch --ignore-files *.d.ts --strict"
2525
},
2626
"devDependencies": {
27-
"@1stg/babel-preset": "^0.7.10",
28-
"@1stg/commitlint-config": "^0.1.2",
29-
"@1stg/eslint-config": "^0.13.2",
30-
"@1stg/husky-config": "^0.3.2",
31-
"@1stg/lint-staged": "^0.8.11",
32-
"@1stg/prettier-config": "^0.4.3",
33-
"@1stg/remark-config": "^0.2.2",
34-
"@1stg/tsconfig": "^0.6.1",
35-
"@1stg/tslint-config": "^0.4.4",
36-
"@babel/core": "^7.6.4",
37-
"@commitlint/cli": "^8.2.0",
38-
"@pkgr/rollup": "^0.3.0",
27+
"@1stg/lib-config": "^0.1.6",
28+
"@1stg/tslint-config": "^0.5.5",
3929
"@types/cosmiconfig": "^5.0.3",
40-
"@types/eslint": "^6.1.2",
41-
"@types/jest": "^24.0.19",
42-
"@types/node": "^12.11.5",
43-
"@types/react": "^16.9.9",
30+
"@types/eslint": "^6.1.3",
31+
"@types/jest": "^24.0.21",
32+
"@types/node": "^12.12.5",
33+
"@types/react": "^16.9.11",
4434
"@types/rebass": "^4.0.3",
4535
"@types/unist": "^2.0.3",
46-
"eslint": "^6.5.1",
4736
"eslint-mdx": "link:packages/eslint-mdx/src",
4837
"eslint-plugin-mdx": "link:packages/eslint-plugin-mdx/src",
49-
"husky": "^3.0.9",
50-
"jest": "^24.9.0",
5138
"lerna": "^3.18.3",
52-
"lerna-changelog": "^0.8.2",
53-
"lint-staged": "^9.4.2",
5439
"npm-run-all": "^4.1.5",
55-
"prettier": "1.18.2",
5640
"react": "^16.11.0",
57-
"rollup": "^1.25.1",
5841
"ts-jest": "^24.1.0",
5942
"ts-node": "^8.4.1",
6043
"tslint": "^5.20.0",
6144
"type-coverage": "^2.3.0",
6245
"typescript": "^3.6.4"
6346
},
6447
"resolutions": {
48+
"@babel/core": "^7.6.4",
6549
"typescript": "^3.6.4"
6650
},
6751
"commitlint": {

packages/eslint-mdx/src/helper.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import { AST, Linter } from 'eslint'
44
import { parse as esParse } from 'espree'
5-
import { SourceLocation } from 'estree'
6-
import { Position } from 'unist'
75

86
import {
97
Arrayable,
@@ -24,6 +22,7 @@ export const JSX_TYPES: JsxTypes = ['JSXElement', 'JSXFragment']
2422
export const isJsxNode = (node: { type: string }): node is JsxNode =>
2523
JSX_TYPES.includes(node.type as JsxType)
2624

25+
// eslint-disable-next-line sonarjs/cognitive-complexity
2726
export const normalizeParser = (parser?: ParserOptions['parser']) => {
2827
if (parser) {
2928
if (typeof parser === 'string') {
@@ -68,7 +67,7 @@ export const normalizeParser = (parser?: ParserOptions['parser']) => {
6867
}
6968

7069
export const normalizePosition = (
71-
position: Position,
70+
position: import('unist').Position,
7271
): Pick<AST.Program, 'loc' | 'range'> & {
7372
start: number
7473
end: number
@@ -87,7 +86,7 @@ export const normalizePosition = (
8786

8887
export interface BaseNode {
8988
type: string
90-
loc?: SourceLocation
89+
loc?: import('estree').SourceLocation
9190
range?: [number, number]
9291
}
9392

packages/eslint-mdx/src/parser.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { AST, Linter } from 'eslint'
2-
import { ExpressionStatement } from 'estree'
31
import path from 'path'
2+
3+
import { AST, Linter } from 'eslint'
44
import remarkMdx from 'remark-mdx'
55
import remarkParse from 'remark-parse'
66
import unified from 'unified'
7-
import { Node, Parent } from 'unist'
87

98
import {
109
hasProperties,
@@ -16,7 +15,14 @@ import {
1615
} from './helper'
1716
import { COMMENT_CONTENT_REGEX, isComment } from './regexp'
1817
import { traverse } from './traverse'
19-
import { Comment, LocationError, ParserFn, ParserOptions } from './types'
18+
import {
19+
Comment,
20+
LocationError,
21+
Node,
22+
Parent,
23+
ParserFn,
24+
ParserOptions,
25+
} from './types'
2026

2127
export const mdxProcessor = unified()
2228
.use(remarkParse)
@@ -225,6 +231,7 @@ export class Parser {
225231

226232
// fix adjacent JSX nodes
227233
// @internal
234+
// eslint-disable-next-line sonarjs/cognitive-complexity
228235
private _normalizeJsxNodes(
229236
node: Node,
230237
options: ParserOptions,
@@ -257,7 +264,8 @@ export class Parser {
257264
return node
258265
}
259266

260-
const { expression } = program.body[0] as ExpressionStatement
267+
const { expression } = program
268+
.body[0] as import('estree').ExpressionStatement
261269

262270
if (!isJsxNode(expression) || expression.children.length <= 1) {
263271
return node

packages/eslint-mdx/src/traverse.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Node, Parent } from 'unist'
2-
31
import { last } from './helper'
42
import {
53
isCloseTag,
@@ -8,7 +6,7 @@ import {
86
isOpenTag,
97
isSelfClosingTag,
108
} from './regexp'
11-
import { TraverseOptions, Traverser } from './types'
9+
import { Node, Parent, TraverseOptions, Traverser } from './types'
1210

1311
export class Traverse {
1412
// @internal
@@ -35,6 +33,7 @@ export class Traverse {
3533
let offset = 0
3634
const jsxNodes: Node[] = []
3735
const { length } = nodes
36+
// eslint-disable-next-line sonarjs/cognitive-complexity
3837
return nodes.reduce<Node[]>((acc, node, index) => {
3938
if (node.type === 'jsx') {
4039
const value = node.value as string

packages/eslint-mdx/src/types.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
import { JSXElement, JSXFragment } from '@babel/types'
1+
/* eslint-disable @typescript-eslint/no-type-alias */
22
import { AST, Linter } from 'eslint'
3-
import { Node, Parent, Point } from 'unist'
3+
4+
export type JSXElement = import('@babel/types').JSXElement
5+
export type JSXFragment = import('@babel/types').JSXFragment
6+
export type Node = import('unist').Node
7+
export type Parent = import('unist').Parent
8+
export type Point = import('unist').Point
49

510
export type JsxNode = (JSXElement | JSXFragment) & { range: [number, number] }
611

7-
// eslint-disable-next-line @typescript-eslint/no-type-alias
812
export type JsxTypes = Readonly<[JSXElement['type'], JSXFragment['type']]>
913

10-
// eslint-disable-next-line @typescript-eslint/no-type-alias
1114
export type JsxType = JsxTypes[number]
1215

13-
// eslint-disable-next-line @typescript-eslint/no-type-alias
1416
export type Arrayable<T> = T[] | readonly T[]
1517

1618
export type ParserFn = (

packages/eslint-plugin-mdx/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@
4040
"vfile": "^4.0.1"
4141
},
4242
"optionalDependencies": {
43-
"rebass": "^4.0.6"
43+
"rebass": "^4.0.7"
4444
}
4545
}

0 commit comments

Comments
 (0)