Skip to content

Commit

Permalink
chore: upgrade (dev)Dependencies, prepare for eslint 8
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Oct 14, 2021
1 parent e0461d1 commit 24cfe78
Show file tree
Hide file tree
Showing 11 changed files with 2,093 additions and 2,336 deletions.
19 changes: 0 additions & 19 deletions codechecks.yml

This file was deleted.

20 changes: 9 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"clean": "rimraf packages/*/{lib,*.tsbuildinfo} node_modules/@1stg/eslint-config/node_modules",
"lint": "run-p lint:*",
"lint:es": "eslint . --cache -f friendly",
"lint:ts": "tslint -p . -t stylish",
"lint:tsc": "tsc --noEmit",
"postinstall": "simple-git-hooks && yarn-deduplicate --strategy fewer || exit 0",
"prelint": "yarn build",
"prerelease": "yarn build",
Expand All @@ -25,28 +25,26 @@
"typecov": "type-coverage"
},
"devDependencies": {
"@1stg/lib-config": "^3.0.0",
"@1stg/tslint-config": "^2.1.0",
"@types/eslint": "^7.28.0",
"@1stg/lib-config": "^4.1.2",
"@types/eslint": "^7.28.1",
"@types/eslint-plugin-markdown": "^2.0.0",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.1",
"@types/react": "^17.0.19",
"@types/jest": "^27.0.2",
"@types/node": "^16.10.9",
"@types/react": "^17.0.29",
"@types/unist": "^2.0.6",
"lerna": "^4.0.0",
"npm-run-all": "^4.1.5",
"react": "^17.0.2",
"remark-frontmatter": "2",
"remark-validate-links": "^10.0.4",
"ts-jest": "^27.0.5",
"ts-node": "^10.2.1",
"tslint": "^6.1.3",
"ts-node": "^10.3.0",
"type-coverage": "^2.18.2",
"typescript": "^4.3.5",
"typescript": "^4.4.4",
"yarn-deduplicate": "^3.1.0"
},
"resolutions": {
"prettier": "^2.3.2"
"prettier": "^2.4.1"
},
"commitlint": {
"extends": [
Expand Down
14 changes: 8 additions & 6 deletions packages/eslint-mdx/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,14 @@ export class Parser {

parseForESLint(code: string, options: ParserOptions) {
const extname = path.extname(options.filePath)
const isMdx = DEFAULT_EXTENSIONS.concat(options.extensions || []).includes(
extname,
)
const isMarkdown = MARKDOWN_EXTENSIONS.concat(
options.markdownExtensions || [],
).includes(extname)
const isMdx = [
...DEFAULT_EXTENSIONS,
...(options.extensions || []),
].includes(extname)
const isMarkdown = [
...MARKDOWN_EXTENSIONS,
...(options.markdownExtensions || []),
].includes(extname)
if (!isMdx && !isMarkdown) {
return this._eslintParse(code, options)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-plugin-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
},
"dependencies": {
"eslint-mdx": "^1.15.1",
"eslint-plugin-markdown": "^2.2.0",
"synckit": "^0.3.4",
"eslint-plugin-markdown": "^2.2.1",
"synckit": "^0.4.1",
"tslib": "^2.3.1",
"vfile": "^4.2.1"
}
Expand Down
22 changes: 14 additions & 8 deletions packages/eslint-plugin-mdx/src/rules/remark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { createSyncFn } from 'synckit'
import type { FrozenProcessor } from 'unified'
import type { VFile, VFileOptions } from 'vfile'
import vfile from 'vfile'
import type { VFileMessage } from 'vfile-message'

import type { RemarkLintMessage } from './types'

Expand Down Expand Up @@ -48,12 +49,14 @@ export const remark: Rule.RuleModule = {
const extname = path.extname(filename)
const sourceCode = context.getSourceCode()
const options = context.parserOptions as ParserOptions
const isMdx = DEFAULT_EXTENSIONS.concat(options.extensions || []).includes(
extname,
)
const isMarkdown = MARKDOWN_EXTENSIONS.concat(
options.markdownExtensions || [],
).includes(extname)
const isMdx = [
...DEFAULT_EXTENSIONS,
...(options.extensions || []),
].includes(extname)
const isMarkdown = [
...MARKDOWN_EXTENSIONS,
...(options.markdownExtensions || []),
].includes(extname)
return {
// eslint-disable-next-line sonarjs/cognitive-complexity
Program(node) {
Expand Down Expand Up @@ -102,8 +105,11 @@ export const remark: Rule.RuleModule = {
)
file.messages = messages
fixedText = content
} else if (!file.messages.includes(err)) {
file.message(err).fatal = true
} else if (!file.messages.includes(err as VFileMessage)) {
file.message(
// @ts-expect-error Error is fine
err,
).fatal = true
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions packages/eslint-plugin-mdx/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { getRemarkProcessor } from 'eslint-mdx'
import { runAsWorker } from 'synckit'
import type { VFileOptions } from 'vfile'
import vfile from 'vfile'
import type { VFileMessage } from 'vfile-message'

runAsWorker(
async (
Expand All @@ -14,8 +15,11 @@ runAsWorker(
try {
await remarkProcessor.process(file)
} catch (err) {
if (!file.messages.includes(err)) {
file.message(err).fatal = true
if (!file.messages.includes(err as VFileMessage)) {
file.message(
// @ts-expect-error Error is fine
err,
).fatal = true
}
}
return {
Expand Down
4 changes: 2 additions & 2 deletions test/no-unused-expressions.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { parser, ruleTester } from './helpers'

import { DEFAULT_PARSER_OPTIONS as parserOptions } from 'eslint-mdx'
import { noUnusedExpressions } from 'eslint-plugin-mdx'

import { parser, ruleTester } from './helpers'

ruleTester.run('no-unused-expressions', noUnusedExpressions, {
valid: [
{
Expand Down
4 changes: 2 additions & 2 deletions test/parser.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable sonarjs/no-duplicate-string */
import { noop } from './helpers'

import type { Node, Parent, ParserConfig, ParserOptions } from 'eslint-mdx'
import {
DEFAULT_PARSER_OPTIONS as parserOptions,
Expand All @@ -9,8 +11,6 @@ import {
parser,
} from 'eslint-mdx'

import { noop } from './helpers'

const stringToNode = (text: string) =>
first(
(getRemarkProcessor(PLACEHOLDER_FILE_PATH, true).parse(text) as Parent)
Expand Down
6 changes: 3 additions & 3 deletions test/remark.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { homedir } from 'os'
import path from 'path'

import { parser, ruleTester } from './helpers'

import {
DEFAULT_PARSER_OPTIONS as parserOptions,
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
// @ts-ignore
processorCache,
} from 'eslint-mdx'
import { remark } from 'eslint-plugin-mdx'
import { homedir } from 'os'

import { parser, ruleTester } from './helpers'

const userDir = homedir()

Expand Down
9 changes: 0 additions & 9 deletions tslint.json

This file was deleted.

Loading

0 comments on commit 24cfe78

Please sign in to comment.