Skip to content

Commit

Permalink
feat: simplify implement by reduce, test with preset-lint-consistent too
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Sep 7, 2019
1 parent 08775d2 commit 9122f95
Show file tree
Hide file tree
Showing 7 changed files with 423 additions and 247 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
lib
CHANGELOG.md
3 changes: 0 additions & 3 deletions .prettierignore

This file was deleted.

14 changes: 0 additions & 14 deletions .prettierrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .remarkrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"plugins": [
"preset-lint-consistent",
"preset-lint-recommended",
"preset-lint-markdown-style-guide",
"preset-prettier"
Expand Down
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "remark-preset-prettier",
"version": "0.1.1",
"version": "0.2.0",
"description": "Turns off all rules that are unnecessary or might conflict with Prettier.",
"repository": "git@github.com:JounQin/remark-preset-prettier.git",
"author": "JounQin <admin@1stg.me>",
Expand All @@ -14,30 +14,31 @@
"src"
],
"scripts": {
"lint": "eslint . --ext js,md,mdx,ts",
"lint": "eslint . --ext js,md,ts",
"build:ts": "tsc -b",
"build:bundle": "rollup -c",
"build": "rimraf lib && run-p build:*"
},
"peerDependencies": {
"prettier": "^1.18.2"
"prettier": ">=1.0.0"
},
"devDependencies": {
"@1stg/babel-preset": "^0.5.0",
"@1stg/eslint-config": "^0.6.0",
"@1stg/babel-preset": "^0.6.0",
"@1stg/eslint-config": "^0.9.0",
"@1stg/husky-config": "^0.3.0",
"@1stg/lint-staged": "^0.5.0",
"@1stg/lint-staged": "^0.6.0",
"@1stg/prettier-config": "^0.2.0",
"@1stg/rollup-config": "^0.3.0",
"@1stg/tsconfig": "^0.3.0",
"@babel/core": "^7.5.5",
"@1stg/rollup-config": "^0.4.1",
"@1stg/tsconfig": "^0.5.0",
"@babel/core": "^7.6.0",
"@commitlint/cli": "^8.1.0",
"@commitlint/config-conventional": "^8.1.0",
"eslint": "^6.3.0",
"husky": "^3.0.5",
"lint-staged": "^9.2.5",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"remark-preset-lint-consistent": "^2.0.3",
"remark-preset-lint-markdown-style-guide": "^2.1.3",
"remark-preset-lint-recommended": "^3.0.3",
"remark-preset-prettier": "link:src",
Expand Down
11 changes: 4 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { Plugin } from 'unified'

export const plugins: Array<[Plugin, false]> = []

const remarkLintPlugins = [
export const plugins = [
'blank-lines-1-0-2',
'blockquote-indentation',
'books-links',
Expand Down Expand Up @@ -38,14 +36,13 @@ const remarkLintPlugins = [
'table-pipe-alignment',
'table-pipes',
'unordered-list-marker-style',
]

remarkLintPlugins.forEach(plugin => {
].reduce<Array<[Plugin, false]>>((plugins, plugin) => {
try {
plugins.push([
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('remark-lint-' + plugin),
false,
])
} catch (e) {}
})
return plugins
}, [])

0 comments on commit 9122f95

Please sign in to comment.