Skip to content

Commit

Permalink
feat: split into two packages, use lerna as publisher (#22)
Browse files Browse the repository at this point in the history
close #21
  • Loading branch information
JounQin authored Aug 3, 2019
1 parent 367f056 commit 349b1ff
Show file tree
Hide file tree
Showing 37 changed files with 2,182 additions and 152 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
lib
node_modules
dist
*.log
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
require('ts-node').register({
transpileOnly: true,
})

module.exports = {
root: true,
settings: {
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lib
node_modules
dist
tsconfig.tsbuildinfo
*.log
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ before_install:
script:
- set -e
- yarn lint
- yarn test
- yarn build
- yarn test

before_deploy:
- set -e
- git remote set-url origin https://user:$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git
- npm set //registry.npmjs.org/:_authToken $NPM_TOKEN
- git fetch origin master:master
- git checkout master
- yarn run standard-version -a
- git push --follow-tags origin master

deploy:
provider: npm
email: admin@1stg.me
api_key: $NPM_TOKEN
provider: script
skip_cleanup: true
script: yarn run lerna publish from-package
on:
branch: release
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ npm i -D @rxts/eslint-plugin-mdx
"overrides": [
{
"files": ["*.mdx"],
"parser": "@rxts/eslint-plugin-mdx",
"parser": "eslint-mdx",
"plugins": ["@rxts/mdx"],
"rules": {
"@rxts/mdx/no-jsx-html-comments": 2,
Expand Down
9 changes: 0 additions & 9 deletions config/index.js

This file was deleted.

1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
preset: 'ts-jest',
modulePathIgnorePatterns: ['<rootDir>/packages/'],
}
6 changes: 6 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "0.0.0",
"npmClient": "yarn",
"packages": ["packages/*"],
"useWorkspaces": true
}
40 changes: 14 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,24 @@
{
"name": "@rxts/eslint-plugin-mdx",
"version": "0.7.1",
"name": "eslint-mdx",
"version": "0.0.0",
"description": "ESLint Parser/Plugin for MDX",
"repository": "git@github.com:rx-ts/eslint-plugin-mdx.git",
"author": "JounQin <admin@1stg.me>",
"main": "dist",
"license": "MIT",
"files": [
"dist",
"types.d.ts"
"private": true,
"workspaces": [
"packages"
],
"scripts": {
"prepublishOnly": "yarn build",
"build": "tsc -P src",
"postinstall": "lerna clean --yes && lerna bootstrap",
"build": "tsc -b",
"test": "jest",
"lint": "EFF_NO_LINK_RULES=true eslint . --ext js,mdx,ts,tsx -f friendly"
},
"keywords": [
"eslint",
"eslint-parser",
"eslint-plugin",
"eslint-parser-mdx",
"eslint-plugin-mdx",
"mdx",
"eslint-mdx"
],
"peerDependencies": {
"eslint": ">=5.0.0"
},
"dependencies": {
"remark-mdx": "^1.1.4",
"remark-parse": "^7.0.0",
"unified": "^8.3.2"
},
"devDependencies": {
"@commitlint/config-conventional": "^8.1.0",
"@rxts/eslint-plugin-mdx": "file:config",
"@rxts/eslint-plugin-mdx": "link:packages/eslint-plugin-mdx/src",
"@types/eslint": "^4.16.6",
"@types/jest": "^24.0.16",
"@types/node": "^12.6.9",
Expand All @@ -46,16 +29,21 @@
"eslint": "^6.1.0",
"eslint-config-1stg": "~5.4.1",
"eslint-formatter-friendly": "^7.0.0",
"eslint-mdx": "link:packages/eslint-mdx/src",
"eslint-plugin-jest": "^22.14.1",
"husky": "^3.0.2",
"jest": "^24.8.0",
"lerna": "^3.16.4",
"lint-staged": "^9.2.1",
"prettier": "1.18.2",
"prettier-config-1stg": "^0.1.0",
"react": "^16.8.6",
"remark-mdx": "^1.1.5",
"remark-parse": "^7.0.0",
"standard-version": "^7.0.0",
"ts-jest": "^24.0.2",
"ts-node": "^8.3.0",
"typescript": "^3.5.3"
"typescript": "^3.5.3",
"unified": "^8.3.2"
}
}
23 changes: 23 additions & 0 deletions packages/eslint-mdx/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "eslint-mdx",
"version": "0.8.0",
"description": "ESLint Parser for MDX",
"repository": "git@github.com:rx-ts/eslint-plugin-mdx.git",
"author": "JounQin <admin@1stg.me>",
"license": "MIT",
"main": "dist",
"files": [
"dist",
"typings.d.ts"
],
"keywords": [
"eslint",
"eslint-parser",
"eslint-parser-mdx",
"mdx",
"eslint-mdx"
],
"peerDependencies": {
"eslint": ">=5.0.0"
}
}
File renamed without changes.
5 changes: 5 additions & 0 deletions packages/eslint-mdx/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from './helper'
export * from './parser'
export * from './regexp'
export * from './traverse'
export * from './types'
2 changes: 1 addition & 1 deletion src/parser.ts → packages/eslint-mdx/src/parser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line @typescript-eslint/no-triple-slash-reference
/// <reference path="../types.d.ts" />
/// <reference path="../typings.d.ts" />

import { parse as esParse } from 'espree'
import remarkMdx from 'remark-mdx'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions packages/eslint-mdx/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib"
}
}
12 changes: 0 additions & 12 deletions types.d.ts → packages/eslint-mdx/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,6 @@ declare interface SyntaxError {
lineNumber?: number
}

declare module 'eslint/lib/rules/no-unused-expressions' {
import { Rule } from 'eslint'
const noUnUsedExpressions: Rule.RuleModule
export = noUnUsedExpressions
}

declare module 'eslint-plugin-react/lib/rules/no-unescaped-entities' {
import { Rule } from 'eslint'
const reactNoUnEscapedEntities: Rule.RuleModule
export = reactNoUnEscapedEntities
}

declare module 'espree' {
import * as estree from 'estree'

Expand Down
29 changes: 29 additions & 0 deletions packages/eslint-plugin-mdx/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "@rxts/eslint-plugin-mdx",
"version": "0.8.0",
"description": "ESLint Plugin for MDX",
"repository": "git@github.com:rx-ts/eslint-plugin-mdx.git",
"author": "JounQin <admin@1stg.me>",
"license": "MIT",
"main": "dist",
"files": [
"dist",
"typings.d.ts"
],
"keywords": [
"eslint",
"eslint-plugin",
"eslint-plugin-mdx",
"mdx",
"eslint-mdx"
],
"peerDependencies": {
"eslint": ">=5.0.0"
},
"dependencies": {
"eslint-mdx": "^0.8.0",
"remark-mdx": "^1.1.5",
"remark-parse": "^7.0.0",
"unified": "^8.3.2"
}
}
4 changes: 4 additions & 0 deletions packages/eslint-plugin-mdx/src/configs/base.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const base = {
parser: 'eslint-mdx',
plugins: ['@rxts/mdx'],
}
2 changes: 2 additions & 0 deletions packages/eslint-plugin-mdx/src/configs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './base'
export * from './recommended'
13 changes: 13 additions & 0 deletions packages/eslint-plugin-mdx/src/configs/recommended.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { base } from './base'

export const recommended = {
...base,
rules: {
'@rxts/mdx/no-jsx-html-comments': 2,
'@rxts/mdx/no-unescaped-entities': 1,
'@rxts/mdx/no-unused-expressions': 2,
'no-unused-expressions': 0,
'react/no-unescaped-entities': 0,
'react/react-in-jsx-scope': 0,
},
}
27 changes: 27 additions & 0 deletions packages/eslint-plugin-mdx/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { parse as oParse, parseForESLint as oParseForESLint } from 'eslint-mdx'

import * as configs from './configs'

import { Linter } from 'eslint'

export { configs }

export * from './rules'

const warn = () =>
console.error(
'parse from this plugin is deprecated, please use parser `eslint-mdx` directly',
)

export const parse = (code: string, options?: Linter.ParserOptions) => {
warn()
return oParse(code, options)
}

export const parseForESLint = (
code: string,
options?: Linter.ParserOptions,
) => {
warn()
oParseForESLint(code, options)
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Comment } from '../types'
import { Comment } from 'eslint-mdx'

import { JSX_TYPES } from './helper'
import { ExpressionStatementWithParent, JsxType } from './types'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// eslint-disable-next-line @typescript-eslint/no-triple-slash-reference
/// <reference path="../../types.d.ts" />
/// <reference path="../../typings.d.ts" />

import { openTag } from 'eslint-mdx'
import reactNoUnEscapedEntities from 'eslint-plugin-react/lib/rules/no-unescaped-entities'

import { openTag } from '../regexp'

import { isJsxNode } from './helper'
import { NodeWithParent } from './types'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// eslint-disable-next-line @typescript-eslint/no-triple-slash-reference
/// <reference path="../../types.d.ts" />
/// <reference path="../../typings.d.ts" />

import esLintNoUnUsedExpressions from 'eslint/lib/rules/no-unused-expressions'

Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions packages/eslint-plugin-mdx/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib"
}
}
11 changes: 11 additions & 0 deletions packages/eslint-plugin-mdx/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
declare module 'eslint/lib/rules/no-unused-expressions' {
import { Rule } from 'eslint'
const noUnUsedExpressions: Rule.RuleModule
export = noUnUsedExpressions
}

declare module 'eslint-plugin-react/lib/rules/no-unescaped-entities' {
import { Rule } from 'eslint'
const reactNoUnEscapedEntities: Rule.RuleModule
export = reactNoUnEscapedEntities
}
22 changes: 0 additions & 22 deletions src/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion test/helper.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { first, mdxProcessor, normalizeJsxNode } from '../src'
import { first, mdxProcessor, normalizeJsxNode } from 'eslint-mdx'

import { Node } from 'unist'

Expand Down
18 changes: 18 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"jsx": "preserve",
"lib": ["esnext"],
"module": "commonjs",
"moduleResolution": "node",
"outDir": "lib",
"sourceMap": true,
"strict": true,
"strictFunctionTypes": false,
"strictNullChecks": false,
"target": "es5"
}
}
Loading

0 comments on commit 349b1ff

Please sign in to comment.