Skip to content

Commit

Permalink
refactor: rewrite by typescript and esm only
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This package is ESM only: Node 12+ is needed to use it and it must be imported
instead of required. And remove preLangClass option.
  • Loading branch information
Val-istar-Guo committed Jul 15, 2021
1 parent e802421 commit 7ea69f0
Show file tree
Hide file tree
Showing 39 changed files with 695 additions and 283 deletions.
4 changes: 0 additions & 4 deletions .babelrc

This file was deleted.

1 change: 0 additions & 1 deletion .commitlintrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# mili upgrade type: cover
extends:
- '@commitlint/config-conventional'
4 changes: 3 additions & 1 deletion .czrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{ "path": "cz-conventional-changelog" }
{
"path": "cz-conventional-changelog"
}
4 changes: 0 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[{**,[!node_modules/**]}]
Expand All @@ -9,5 +6,4 @@ end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
# 设为true表示会除去换行行首的任意空白字符
trim_trailing_whitespace = true
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/lib
/es
/dist
202 changes: 202 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
extends:
- eslint:recommended
parserOptions:
ecmaVersion: 2017
sourceType: module
env:
es6: true
node: true
rules:
object-shorthand: error
eqeqeq: error
no-floating-decimal: error
no-var: error
no-implicit-coercion:
- error
- allow:
- '!!'
no-multi-spaces: error
no-useless-return: error
no-undef-init: error
no-trailing-spaces: error
no-unneeded-ternary: error
no-whitespace-before-property: error
nonblock-statement-body-position: error
space-infix-ops: error
space-unary-ops: error
switch-colon-spacing: error
arrow-body-style: error
arrow-spacing: error
generator-star-spacing: error
no-useless-computed-key: error
no-useless-rename: error
new-cap: error
no-lonely-if: error
prefer-const: error
prefer-spread: error
prefer-template: error
rest-spread-spacing: error
sort-imports: 'off'
template-curly-spacing: error
yield-star-spacing: error
multiline-comment-style:
- error
- separate-lines
indent:
- error
- 2
semi:
- error
- never
func-call-spacing:
- error
- never
yoda:
- error
- never
curly:
- error
- multi-line
- consistent
quotes:
- error
- single
- avoidEscape: true
dot-location:
- error
- property
array-bracket-spacing:
- error
- never
array-bracket-newline:
- error
- consistent
block-spacing:
- error
- always
brace-style:
- error
- 1tbs
comma-dangle:
- error
- always-multiline
comma-style:
- error
- last
computed-property-spacing:
- error
- never
function-paren-newline:
- error
- multiline
implicit-arrow-linebreak:
- error
- beside
key-spacing:
- error
- afterColon: true
beforeColon: false
mode: strict
keyword-spacing:
- error
- before: true
after: true
line-comment-position:
- error
- above
linebreak-style:
- error
- unix
lines-between-class-members:
- error
- always
- exceptAfterSingleLine: true
no-multiple-empty-lines:
- error
- max: 2
no-empty:
- error
- allowEmptyCatch: true
object-curly-newline:
- error
- multiline: true
consistent: true
object-curly-spacing:
- error
- always
one-var-declaration-per-line:
- error
- initializations
padded-blocks:
- error
- never
quote-props:
- error
- as-needed
space-before-blocks:
- error
- always
space-before-function-paren:
- error
- never
space-in-parens:
- error
- never
spaced-comment:
- error
- always
arrow-parens:
- error
- as-needed
no-unused-vars: error
overrides:
- files:
- '**/*.ts'
- '**/*.tsx'
extends:
- plugin:@typescript-eslint/recommended
- plugin:@typescript-eslint/recommended-requiring-type-checking
parser: '@typescript-eslint/parser'
parserOptions:
project:
- ./tsconfig.json
- ./tests/tsconfig.json
plugins:
- '@typescript-eslint'
rules:
'@typescript-eslint/no-unsafe-call': 'off'
'@typescript-eslint/no-unsafe-member-access': 'off'
'@typescript-eslint/no-unsafe-assignment': 'off'
new-cap:
- error
- capIsNew: false
'@typescript-eslint/no-floating-promises': error
semi: 'off'
'@typescript-eslint/semi':
- error
- never
indent: 'off'
'@typescript-eslint/indent':
- error
- 2
'@typescript-eslint/explicit-member-accessibility':
- error
- overrides:
accessors: 'off'
constructors: 'off'
properties: no-public
'@typescript-eslint/explicit-function-return-type':
- error
- allowHigherOrderFunctions: true
allowExpressions: true
allowTypedFunctionExpressions: true
'@typescript-eslint/member-delimiter-style':
- error
- multiline:
delimiter: none
no-unused-vars: 'off'
'@typescript-eslint/no-unused-vars': error
func-call-spacing: 'off'
'@typescript-eslint/func-call-spacing':
- error
- never
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a [code of conduct](https://github.com/Val-istar-Guo/mili/blob/master/.github/CODE_OF_CONDUCT.md), please follow it in all your interactions with the project.
Please note we have a [code of conduct](https://github.com/Val-istar-Guo/rehype-prism/blob/master/.github/CODE_OF_CONDUCT.md), please follow it in all your interactions with the project.


# Issue considerations
Expand Down
12 changes: 4 additions & 8 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
**IMPORTANT: Please do not create a Pull Request without creating an issue first.**
Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.
<!-- IMPORTANT: Please do not create a Pull Request without creating an issue first -->
<!-- Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request. -->


**Close issues**
List the issues solved.(e.g. 'close #xxx, close #xxx and close #xxx')


**Additional context**
Please provide enough information so that others can review your pull request.


**Please check if the PR fulfills these requirements**

- [ ] Have you followed the guidelines in our [Contributing document](https://github.com/Val-istar-Guo/mili/blob/master/.github/CODE_OF_CONDUCT.md)?
- [ ] Have you followed the guidelines in our [Contributing document](https://github.com/Val-istar-Guo/rehype-prism/blob/master/.github/CODE_OF_CONDUCT.md)?
- [ ] Have you written new tests for your core changes, as applicable?
- [ ] Have you successfully ran tests with your changes locally?
- [ ] Have you written or modified docs for your core changes, as applicable?
43 changes: 43 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "CodeQL analysis"

on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
schedule:
- cron: '0 4 * * 1'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language:
- javascript

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{matrix.language}}

- name: Autobuild
uses: github/codeql-action/autobuild@v1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
push:
branches:
- master
- main
name: Release
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
id: release
with:
token: ${{secrets.RELEASE_TOKEN}}
release-type: node
package-name: "rehype-prism"
- uses: actions/checkout@v2
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@v1
with:
node-version: 14
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.release_created }}
- run: npm i
if: ${{ steps.release.outputs.release_created }}
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
if: ${{ steps.release.outputs.release_created }}
Loading

0 comments on commit 7ea69f0

Please sign in to comment.