Skip to content

Commit 68799e1

Browse files
committed
fix: correct repository field in package.json, bump devDependencies
1 parent 914892e commit 68799e1

26 files changed

+648
-371
lines changed

.eslintrc.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
require('ts-node').register({
2-
transpileOnly: true,
3-
})
4-
51
module.exports = {
62
root: true,
73
extends: ['@1stg/eslint-config/recommended'],
@@ -14,7 +10,9 @@ module.exports = {
1410
},
1511
},
1612
rules: {
13+
'@typescript-eslint/no-unnecessary-condition': 0,
1714
'@typescript-eslint/unbound-method': 0, // See https://github.com/typescript-eslint/typescript-eslint/issues/636
15+
'@typescript-eslint/triple-slash-reference': 0,
1816
},
1917
},
2018
],

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ cache:
77
- directories:
88
- .changelog
99

10+
env: EFF_NO_LINK_RULES=true
11+
1012
before_install:
1113
- curl -o- -L https://yarnpkg.com/install.sh | bash
1214
- export PATH="$HOME/.yarn/bin:$PATH"
@@ -16,8 +18,8 @@ before_install:
1618
install: yarn --frozen-lockfile
1719

1820
script:
19-
- yarn lint
2021
- yarn build
22+
- yarn lint
2123
- yarn test
2224

2325
after_success:

package.json

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "eslint-mdx",
2+
"name": "@rxts/eslint-mdx",
33
"version": "0.0.0",
44
"description": "ESLint Parser/Plugin for MDX",
55
"repository": "[email protected]:rx-ts/eslint-mdx.git",
@@ -11,59 +11,52 @@
1111
],
1212
"scripts": {
1313
"build": "tsc -b",
14-
"test": "ts-node -T node_modules/.bin/jest",
15-
"lint": "EFF_NO_LINK_RULES=true eslint . --ext js,md,mdx,ts,tsx -f friendly",
14+
"test": "jest",
15+
"lint:es": "eslint . --ext js,md,ts -f friendly",
16+
"lint:ts": "tslint -p . -t stylish",
17+
"lint": "run-p lint:*",
1618
"type-coverage": "type-coverage --cache --ignore-catch --detail --ignore-files *.d.ts --strict"
1719
},
1820
"devDependencies": {
19-
"@1stg/babel-preset": "^0.6.2",
20-
"@1stg/browserslist-config": "^0.2.1",
21-
"@1stg/eslint-config": "^0.11.0",
21+
"@1stg/babel-preset": "^0.7.0",
22+
"@1stg/commitlint-config": "^0.1.0",
23+
"@1stg/eslint-config": "^0.12.10",
2224
"@1stg/husky-config": "^0.3.0",
23-
"@1stg/lint-staged": "^0.6.1",
25+
"@1stg/lint-staged": "^0.7.4",
2426
"@1stg/prettier-config": "^0.2.0",
2527
"@1stg/remark-config": "^0.2.1",
2628
"@1stg/tsconfig": "^0.5.1",
29+
"@1stg/tslint-config": "^0.3.3",
2730
"@babel/core": "^7.6.0",
28-
"@commitlint/cli": "^8.1.0",
29-
"@commitlint/config-conventional": "^8.1.0",
31+
"@commitlint/cli": "^8.2.0",
3032
"@types/cosmiconfig": "^5.0.3",
3133
"@types/eslint": "^6.1.1",
3234
"@types/jest": "^24.0.18",
3335
"@types/node": "^12.7.5",
3436
"@types/react": "^16.9.2",
3537
"@types/rebass": "^4.0.0",
3638
"@types/unist": "^2.0.3",
37-
"babel-eslint": "^11.0.0-beta.0",
38-
"browserslist": "^4.7.0",
3939
"eslint": "^6.4.0",
40-
"eslint-formatter-friendly": "^7.0.0",
41-
"eslint-mdx": "link:packages/eslint-mdx/src",
42-
"eslint-plugin-mdx": "link:packages/eslint-plugin-mdx/src",
43-
"eslint-plugin-react": "^7.14.3",
4440
"husky": "^3.0.5",
4541
"jest": "^24.9.0",
4642
"lerna": "^3.16.4",
4743
"lerna-changelog": "^0.8.2",
4844
"lint-staged": "^9.2.5",
45+
"npm-run-all": "^4.1.5",
4946
"prettier": "1.18.2",
5047
"react": "^16.9.0",
51-
"ts-jest": "~24.0.2",
52-
"ts-node": "^8.4.1",
48+
"ts-jest": "^24.1.0",
49+
"tslint": "^5.20.0",
5350
"type-coverage": "^2.3.0",
5451
"typescript": "^3.6.3"
5552
},
56-
"browserslist": [
57-
"extends @1stg/browserslist-config/latest"
58-
],
5953
"commitlint": {
6054
"extends": [
61-
"@commitlint/config-conventional"
55+
"@1stg"
6256
]
6357
},
6458
"eslintIgnore": [
65-
"**/fixtures/**/*.md",
66-
"**/fixtures/**/*.mdx",
59+
"**/fixtures/**",
6760
"CHANGELOG.md",
6861
"coverage",
6962
"lib"
@@ -78,9 +71,6 @@
7871
"statements": 100
7972
}
8073
},
81-
"modulePathIgnorePatterns": [
82-
"<rootDir>/packages/"
83-
],
8474
"preset": "ts-jest"
8575
},
8676
"prettier": "@1stg/prettier-config",

packages/eslint-mdx/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
"name": "eslint-mdx",
33
"version": "1.4.5",
44
"description": "ESLint Parser for MDX",
5-
"repository": "https://github.com/rx-ts/eslint-mdx/blob/master/packages/eslint-mdx",
5+
"repository": {
6+
"type": "git",
7+
"url": "git+https://github.com/rx-ts/eslint-mdx.git",
8+
"directory": "packages/eslint-mdx"
9+
},
610
"author": "JounQin <[email protected]>",
711
"license": "MIT",
812
"main": "lib",

packages/eslint-mdx/src/helper.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1-
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
21
/// <reference path="../typings.d.ts" />
32

3+
import { AST } from 'eslint'
44
import { parse as esParse } from 'espree'
5+
import { SourceLocation } from 'estree'
6+
import { Position } from 'unist'
57

68
import {
79
Arrayable,
810
JsxNode,
911
JsxType,
1012
JsxTypes,
11-
ParserOptions,
1213
ParserFn,
14+
ParserOptions,
1315
} from './types'
1416

15-
import { Position } from 'unist'
16-
// `SourceLocation` is not exported from estree, but it is actually working
17-
// eslint-disable-next-line import/named
18-
import { SourceLocation } from 'estree'
19-
import { AST } from 'eslint'
20-
2117
export const FALLBACK_PARSERS = [
2218
'@typescript-eslint/parser',
2319
'babel-eslint',

packages/eslint-mdx/src/parser.ts

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1+
import { AST, Linter } from 'eslint'
2+
import { ExpressionStatement } from 'estree'
13
import path from 'path'
2-
34
import remarkMdx from 'remark-mdx'
45
import remarkParse from 'remark-parse'
56
import unified from 'unified'
7+
import { Node, Parent } from 'unist'
68

79
import {
810
hasProperties,
911
isJsxNode,
12+
last,
1013
normalizeParser,
1114
normalizePosition,
1215
restoreNodeLocation,
13-
last,
1416
} from './helper'
15-
import { isComment, COMMENT_CONTENT_REGEX } from './regexp'
17+
import { COMMENT_CONTENT_REGEX, isComment } from './regexp'
1618
import { traverse } from './traverse'
17-
import { ParserOptions, LocationError, Comment, ParserFn } from './types'
18-
19-
import { AST, Linter } from 'eslint'
20-
import { Parent, Node } from 'unist'
21-
import { ExpressionStatement } from 'estree'
19+
import { Comment, LocationError, ParserFn, ParserOptions } from './types'
2220

2321
export const mdxProcessor = unified()
2422
.use(remarkParse)
@@ -44,6 +42,10 @@ export const DEFAULT_PARSER_OPTIONS: ParserOptions = {
4442
filePath: '__placeholder__.mdx',
4543
}
4644

45+
const JSX_WRAPPER_START = '<$>'
46+
const JSX_WRAPPER_END = '</$>'
47+
const OFFSET = JSX_WRAPPER_START.length
48+
4749
export class Parser {
4850
// @internal
4951
private _parser: ParserFn
@@ -71,9 +73,9 @@ export class Parser {
7173
return node
7274
}
7375

74-
const matched = COMMENT_CONTENT_REGEX.exec(value)
76+
const commentContent = COMMENT_CONTENT_REGEX.exec(value)
7577

76-
if (matched) {
78+
if (commentContent) {
7779
const comments: Comment[] = []
7880
const {
7981
position: {
@@ -176,7 +178,7 @@ export class Parser {
176178

177179
let normalized = this.normalizeJsxNode(node, parent)
178180
normalized = Array.isArray(normalized) ? normalized : [normalized]
179-
normalized.forEach(node => this._nodeToAst(node, options))
181+
normalized.forEach(_node => this._nodeToAst(_node, options))
180182
},
181183
})
182184
}
@@ -212,15 +214,18 @@ export class Parser {
212214

213215
try {
214216
// wrap into single element which is valid jsx but not valid jsx in mdx, so that it won't break on adjacent JSX nodes
215-
program = this._eslintParse(`<$>${value}</$>`).ast
217+
program = this._eslintParse(
218+
`${JSX_WRAPPER_START}${value}${JSX_WRAPPER_END}`,
219+
).ast
216220
} catch (e) {
217221
if (hasProperties<LocationError>(e, LOC_ERROR_PROPERTIES)) {
218222
const {
219223
position: { start },
220224
} = node
221225

222-
e.index += start.offset - 3
223-
e.column = e.lineNumber > 1 ? e.column : e.column + start.column - 3
226+
e.index += start.offset - OFFSET
227+
e.column =
228+
e.lineNumber > 1 ? e.column : e.column + start.column - OFFSET
224229
e.lineNumber += start.line - 1
225230

226231
throw e
@@ -251,21 +256,21 @@ export class Parser {
251256
} = jsNode
252257
const startLine = line + start.line - 1
253258
const endLine = line + end.line - 1
254-
const startOffset = range[0] - 3
255-
const endOffset = range[1] - 3
259+
const startOffset = range[0] - OFFSET
260+
const endOffset = range[1] - OFFSET
256261
nodes.push({
257262
type: 'jsx',
258263
data: nodes.length ? null : node.data,
259264
value: value.slice(startOffset, endOffset),
260265
position: {
261266
start: {
262267
line: startLine,
263-
column: line === startLine ? start.column - 3 : start.column,
268+
column: line === startLine ? start.column - OFFSET : start.column,
264269
offset: offset + startOffset,
265270
},
266271
end: {
267272
line: endLine,
268-
column: line === startLine ? end.column - 3 : end.column,
273+
column: line === startLine ? end.column - OFFSET : end.column,
269274
offset: offset + endOffset,
270275
},
271276
},
@@ -288,7 +293,7 @@ export class Parser {
288293
}
289294

290295
const { loc, start } = normalizePosition(node.position)
291-
const startLine = loc.start.line - 1 //! line is 1-indexed, change to 0-indexed to simplify usage
296+
const startLine = loc.start.line - 1 // ! line is 1-indexed, change to 0-indexed to simplify usage
292297

293298
let program: AST.Program
294299

@@ -310,7 +315,6 @@ export class Parser {
310315
AST_PROPS.forEach(prop =>
311316
this._ast[prop].push(
312317
// unfortunately, TS complains about incompatible signature
313-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
314318
// @ts-ignore
315319
...program[prop].map(item =>
316320
restoreNodeLocation(item, startLine, offset),

packages/eslint-mdx/src/traverse.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import { Node, Parent } from 'unist'
2+
13
import { last } from './helper'
24
import {
3-
isOpenTag,
45
isCloseTag,
56
isComment,
6-
isSelfClosingTag,
77
isOpenCloseTag,
8+
isOpenTag,
9+
isSelfClosingTag,
810
} from './regexp'
9-
import { Traverser, TraverseOptions } from './types'
10-
11-
import { Node, Parent } from 'unist'
11+
import { TraverseOptions, Traverser } from './types'
1212

1313
export class Traverse {
1414
// @internal

packages/eslint-mdx/src/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { JSXElement, JSXFragment } from '@babel/types'
2-
3-
import { Linter, AST } from 'eslint'
2+
import { AST, Linter } from 'eslint'
43
import { Node, Parent, Point } from 'unist'
54

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

packages/eslint-plugin-mdx/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
"name": "eslint-plugin-mdx",
33
"version": "1.5.0",
44
"description": "ESLint Plugin for MDX",
5-
"repository": "https://github.com/rx-ts/eslint-mdx/blob/master/packages/eslint-plugin-mdx",
5+
"repository": {
6+
"type": "git",
7+
"url": "git+https://github.com/rx-ts/eslint-mdx.git",
8+
"directory": "packages/eslint-plugin-mdx"
9+
},
610
"author": "JounQin <[email protected]>",
711
"license": "MIT",
812
"main": "lib",

packages/eslint-plugin-mdx/src/configs/helper.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export const getGlobals = <
1111
[source]: false,
1212
}),
1313
// FIXME: find a better solution
14-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
1514
// @ts-ignore
1615
initialGlobals,
1716
)

0 commit comments

Comments
 (0)