Skip to content

Commit

Permalink
fix(dpes): bump cosmiconfig to v6.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Nov 11, 2019
1 parent 0933b89 commit 712c872
Show file tree
Hide file tree
Showing 8 changed files with 1,020 additions and 1,013 deletions.
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,30 @@
"type-coverage": "type-coverage --cache --detail --ignore-catch --ignore-files *.d.ts --strict"
},
"devDependencies": {
"@1stg/lib-config": "^0.1.6",
"@1stg/tslint-config": "^0.5.5",
"@types/cosmiconfig": "^5.0.3",
"@1stg/lib-config": "^0.1.13",
"@1stg/tslint-config": "^0.5.6",
"@types/eslint": "^6.1.3",
"@types/jest": "^24.0.21",
"@types/node": "^12.12.5",
"@types/jest": "^24.0.22",
"@types/node": "^12.12.7",
"@types/react": "^16.9.11",
"@types/rebass": "^4.0.3",
"@types/unist": "^2.0.3",
"cosmiconfig": "^6.0.0",
"eslint-mdx": "link:packages/eslint-mdx/src",
"eslint-plugin-mdx": "link:packages/eslint-plugin-mdx/src",
"lerna": "^3.18.3",
"lerna": "^3.18.4",
"npm-run-all": "^4.1.5",
"react": "^16.11.0",
"ts-jest": "^24.1.0",
"ts-node": "^8.4.1",
"tslint": "^5.20.0",
"type-coverage": "^2.3.0",
"typescript": "^3.6.4"
"ts-node": "^8.5.0",
"tslint": "^5.20.1",
"type-coverage": "^2.3.0"
},
"resolutions": {
"@babel/core": "^7.6.4",
"typescript": "^3.6.4"
"@babel/core": "^7.7.2",
"babel-eslint": "^10.0.3",
"eslint-plugin-prettier": "^3.1.1",
"typescript": "^3.7.2"
},
"commitlint": {
"extends": [
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"dependencies": {
"espree": "^6.1.2",
"remark-mdx": "^1.5.1",
"remark-parse": "^7.0.1",
"remark-parse": "^7.0.2",
"tslib": "^1.10.0",
"unified": "^8.4.1"
"unified": "^8.4.2"
}
}
2 changes: 2 additions & 0 deletions packages/eslint-mdx/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,10 +284,12 @@ export class Parser {
const {
start: nodeStart,
end: nodeEnd,
/* istanbul ignore next */
loc: { start, end } = {
start: { column: nodeStart, line: 1 },
end: { column: nodeEnd, line: 1 },
},
/* istanbul ignore next */
range = [nodeStart, nodeEnd],
} = jsNode
const startLine = line + start.line - 1
Expand Down
10 changes: 5 additions & 5 deletions packages/eslint-plugin-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
"eslint": ">=5.0.0"
},
"dependencies": {
"cosmiconfig": "^5.2.1",
"cosmiconfig": "^6.0.0",
"eslint-mdx": "^1.6.2",
"eslint-plugin-react": ">=7.0.0",
"remark-mdx": "^1.5.1",
"remark-parse": "^7.0.1",
"remark-stringify": "^7.0.3",
"remark-parse": "^7.0.2",
"remark-stringify": "^7.0.4",
"tslib": "^1.10.0",
"unified": "^8.4.1",
"vfile": "^4.0.1"
"unified": "^8.4.2",
"vfile": "^4.0.2"
},
"optionalDependencies": {
"rebass": "^4.0.7"
Expand Down
13 changes: 7 additions & 6 deletions packages/eslint-plugin-mdx/src/rules/helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'path'

import cosmiconfig, { CosmiconfigResult, Explorer } from 'cosmiconfig'
import { cosmiconfigSync } from 'cosmiconfig'
import { CosmiconfigResult } from 'cosmiconfig/dist/types'
import remarkMdx from 'remark-mdx'
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'
Expand Down Expand Up @@ -37,14 +38,14 @@ export const requirePkg = (
throw error
}

let remarkConfig: Explorer
let searchSync: (searchFrom?: string) => CosmiconfigResult
let remarkProcessor: Processor

export const getRemarkProcessor = (searchFrom: string) => {
if (!remarkConfig) {
remarkConfig = cosmiconfig('remark', {
if (!searchSync) {
searchSync = cosmiconfigSync('remark', {
packageProp: 'remarkConfig',
})
}).search
}

if (!remarkProcessor) {
Expand All @@ -55,7 +56,7 @@ export const getRemarkProcessor = (searchFrom: string) => {

/* istanbul ignore next */
const { config, filepath }: Partial<CosmiconfigResult> =
remarkConfig.searchSync(searchFrom) || {}
searchSync(searchFrom) || {}
/* istanbul ignore next */
const { plugins = [], settings }: Partial<RemarkConfig> = config || {}

Expand Down
11 changes: 6 additions & 5 deletions test/__snapshots__/fixtures.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Lorem ipsum dolor sit _amet_, consectetur adipiscing elit. Ut ac lobortis velit.
`;

exports[`fixtures should match all snapshots: blank-lines.mdx 1`] = `
"import { Box } from '@rebass/emotion'
"import {Box} from '@rebass/emotion'
# Getting Started
Expand Down Expand Up @@ -79,10 +79,11 @@ exports[`fixtures should match all snapshots: no-jsx-html-comments.mdx 1`] = `
<header>Header{/** JSX HTML comment */}</header>
<main>Main Content</main>
<header>Header
{/** JSX
HTML comment */}</header>
<header>
Header
{/** JSX
HTML comment */}
</header>
<main>Main Content</main>
Inline <header>Header<!-- JSX HTML comment --></header>
Expand Down
8 changes: 4 additions & 4 deletions test/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,17 @@ describe('parser', () => {
'Expected corresponding JSX closing tag for <h1>',
)
expect(() => parser.parse('Header\n<>', parserOptions)).toThrow(
'Unexpected token (1:2)',
'Line 1: Unexpected token',
)
expect(() => parser.parse('<main><</main>', parserOptions)).toThrow(
'Unexpected token (1:7)',
'Line 1: Unexpected token',
)
expect(() => parser.parse('<main>{<}</main>', parserOptions)).toThrow(
'Unexpected token (1:8)',
'Line 1: Unexpected token',
)
expect(() =>
parser.parse('<main>\n<section><</section></main>', parserOptions),
).toThrow('Unexpected token (2:10)')
).toThrow('Line 2: Unexpected token')
})

it('should not throw on adjacent JSX nodes', () =>
Expand Down
Loading

0 comments on commit 712c872

Please sign in to comment.