Skip to content

Commit

Permalink
feat(sh): new experimentalWasm option to use sh-syntax (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Jul 29, 2022
1 parent ab82965 commit 4b37afd
Show file tree
Hide file tree
Showing 47 changed files with 19,350 additions and 17,728 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-crabs-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"prettier-plugin-sql": patch
---

fix: add missing `tslib` dependency
5 changes: 5 additions & 0 deletions .changeset/loud-vans-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"prettier-plugin-sh": patch
---

feat: new `experimentalWasm` option to use `sh-syntax`
7 changes: 7 additions & 0 deletions .changeset/tasty-carpets-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"prettier-plugin-pkg": patch
"prettier-plugin-sh": patch
"prettier-plugin-sql": patch
---

chore(types): migrate to `type` import
1 change: 1 addition & 0 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"node": "16",
"installCommand": "codesandbox:install",
"sandboxes": []
}
6 changes: 6 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"root": true,
"extends": "@1stg",
"overrides": [
{
"files": ".github/*.yml",
"rules": {
"unicorn/filename-case": "off"
}
},
{
"files": "docs/**/*.tsx",
"rules": {
Expand Down
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=auto eol=lf
pnpm-lock.yaml -diff
26 changes: 21 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,48 @@ on:

jobs:
ci:
name: Lint and Test with Node.js ${{ matrix.node }}
name: Lint and Test with Node.js ${{ matrix.node }} on ${{ matrix.os }}
strategy:
matrix:
node:
- 14
- 16
- 18
runs-on: ubuntu-latest
os:
- macos-latest
- windows-latest
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest

- name: Setup Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: yarn
cache: pnpm

- name: Install Dependencies
run: yarn --frozen-lockfile
run: pnpm i

- id: node14
if: matrix.node == 14
run: |
pnpm add -D -w ts-node
echo "::set-output name=tsRunner::ts-node"
- name: Build, Lint and Test
run: yarn run-s build lint test typecov
run: pnpm run-s build lint test
env:
EFF_NO_LINK_RULES: true
PARSER_NO_WATCH: true
SYNCKIT_TS_RUNNER: ${{ steps.node14.outputs.tsRunner }}

- name: Codecov
uses: codecov/codecov-action@v3
6 changes: 0 additions & 6 deletions .github/workflows/pkg-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn

- name: Package Size Report
uses: pkg-size/action@v1
env:
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ jobs:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest

- name: Setup Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
cache: pnpm

- name: Install Dependencies
run: yarn --frozen-lockfile
run: pnpm i

- name: Build
run: yarn build
run: pnpm build

- name: Create Release Pull Request or Publish to npm
id: changesets
Expand All @@ -35,7 +40,7 @@ jobs:
commit: 'chore: release package(s)'
title: 'chore: release package(s)'
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: yarn release
publish: pnpm release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
18 changes: 18 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
auto-install-peers=true
enable-pre-post-scripts=true
public-hoist-pattern[]=@1stg/*
public-hoist-pattern[]=@babel/types
public-hoist-pattern[]=@commitlint/*
public-hoist-pattern[]=@pkgr/*
public-hoist-pattern[]=@types/*
public-hoist-pattern[]=core-js
public-hoist-pattern[]=*eslint*
public-hoist-pattern[]=*/loader
public-hoist-pattern[]=*-loader
public-hoist-pattern[]=lint-staged
public-hoist-pattern[]=npm-run-all
public-hoist-pattern[]=*prettier*
public-hoist-pattern[]=rimraf
public-hoist-pattern[]=simple-git-hooks
public-hoist-pattern[]=*stylelint*
strict-peer-dependencies=false
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
coverage
dist
**/test/fixtures
/pnpm-lock.yaml
17 changes: 17 additions & 0 deletions auto-imports.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Generated by 'unplugin-auto-import'
export {}
declare global {
const afterAll: typeof import('vitest')['afterAll']
const afterEach: typeof import('vitest')['afterEach']
const assert: typeof import('vitest')['assert']
const beforeAll: typeof import('vitest')['beforeAll']
const beforeEach: typeof import('vitest')['beforeEach']
const chai: typeof import('vitest')['chai']
const describe: typeof import('vitest')['describe']
const expect: typeof import('vitest')['expect']
const it: typeof import('vitest')['it']
const suite: typeof import('vitest')['suite']
const test: typeof import('vitest')['test']
const vi: typeof import('vitest')['vi']
const vitest: typeof import('vitest')['vitest']
}
76 changes: 27 additions & 49 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,64 +10,63 @@
"workspaces": [
"packages/*"
],
"packageManager": "yarn@1.22.19",
"packageManager": "pnpm@7.6.0",
"scripts": {
"build": "run-p build:*",
"build:r": "r -f cjs",
"build:ts": "tsc -b",
"clean": "rimraf 'packages/*/{lib,*.tsbuildinfo}'",
"dev": "w -e docs --disableDotRule --publicPath /",
"clean": "rimraf dist coverage 'packages/*/{lib,*.tsbuildinfo}'",
"codesandbox:install": "npx pnpm@7.6.0 i",
"dev": "vitest",
"docs:build": "w -e docs -p --publicPath /",
"docs:dev": "w -e docs --disableDotRule --publicPath /",
"format": "tsx scripts/format",
"languages": "tsx scripts/languages",
"lint": "run-p lint:*",
"lint:es": "eslint . --cache -f friendly",
"lint:style": "stylelint . --cache",
"lint:tsc": "tsc --noEmit",
"prepare": "patch-package && simple-git-hooks && yarn languages && yarn-deduplicate --strategy fewer || exit 0",
"prepare": "simple-git-hooks && pnpm languages || exit 0",
"release": "changeset publish",
"serve": "sirv dist",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
"test": "vitest run --coverage",
"typecov": "type-coverage",
"vercel-build": "w -e docs -p --publicPath /"
},
"dependencies": {
"prettier-plugin-pkg": "link:packages/pkg"
"vercel-build": "pnpm docs:build"
},
"devDependencies": {
"@1stg/app-config": "^6.1.4",
"@1stg/lib-config": "^9.0.1",
"@babel/types": "^7.18.9",
"@1stg/app-config": "^6.1.5",
"@1stg/lib-config": "^9.0.2",
"@changesets/changelog-github": "^0.4.6",
"@changesets/cli": "^2.24.0",
"@pkgr/imagemin": "^3.1.1",
"@changesets/cli": "^2.24.1",
"@pkgr/webpack-mdx": "^2.0.3",
"@types/jest": "^28.1.6",
"@types/js-yaml": "^4.0.5",
"@types/lodash": "^4.14.182",
"@types/mvdan-sh": "^0.5.1",
"@types/prettier": "^2.6.3",
"@types/mvdan-sh": "^0.10.0",
"@types/prettier": "^2.6.4",
"@types/react": "^18.0.15",
"@types/react-dom": "^18.0.6",
"@types/web": "^0.0.69",
"@types/web": "^0.0.70",
"c8": "^7.12.0",
"github-markdown-css": "^5.1.0",
"https-proxy-agent": "^5.0.1",
"jest": "^28.1.3",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"patch-package": "^6.4.7",
"prettier-plugin-pkg": "workspace:*",
"prettier-plugin-sh": "workspace:*",
"prettier-plugin-sql": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.3.0",
"remark-gfm": "^3.0.1",
"sirv-cli": "^2.0.2",
"ts-jest": "^28.0.7",
"tsx": "^3.8.0",
"type-coverage": "^2.22.0",
"typescript": "^4.7.4",
"yarn-deduplicate": "^5.0.0"
"unplugin-auto-import": "^0.10.2",
"vitest": "^0.19.1"
},
"resolutions": {
"prettier-plugin-pkg": "link:packages/pkg"
"prettier": "^2.7.1"
},
"browserslist": [
"extends @1stg/browserslist-config/modern"
Expand All @@ -80,35 +79,14 @@
"eslintIgnore": [
"coverage",
"dist",
"**/fixtures",
"**/lib",
"**/CHANGELOG.md",
"packages/**/fixtures",
"packages/**/lib",
"packages/**/CHANGELOG.md",
"packages/*/src/languages.ts",
"/pnpm-lock.yaml",
"!/.github",
"!/.*.js"
],
"jest": {
"preset": "ts-jest",
"reporters": [
"default",
"github-actions"
],
"collectCoverage": true,
"extensionsToTreatAsEsm": [
".ts"
],
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1",
"^prettier-plugin-(.*)$": "<rootDir>/packages/$1"
},
"globals": {
"ts-jest": {
"useESM": true,
"tsconfig": {
"importHelpers": false
}
}
}
},
"renovate": {
"extends": [
"@1stg"
Expand Down
2 changes: 1 addition & 1 deletion packages/pkg/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
included in all copies or substantial portions of this Source Code Form.
*/

import { Plugin } from 'prettier'
import type { Plugin } from 'prettier'
import babelParser from 'prettier/parser-babel.js'

import { files } from './rules/files.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/pkg/src/rules/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
included in all copies or substantial portions of this Source Code Form.
*/

import {
import type {
ObjectProperty,
StringArrayExpression,
StringLiteral,
Expand Down
2 changes: 1 addition & 1 deletion packages/pkg/src/rules/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
included in all copies or substantial portions of this Source Code Form.
*/

import { ObjectExpression, ObjectProperty } from '../types.js'
import type { ObjectExpression, ObjectProperty } from '../types.js'
import { sortObject } from '../utils.js'

const process = (props: ObjectProperty[], key: string) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/pkg/src/rules/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
included in all copies or substantial portions of this Source Code Form.
*/

import { ObjectProperty } from '../types.js'
import type { ObjectProperty } from '../types.js'
import { alphabetSort, sortObject } from '../utils.js'

export const dependencyNames = [
Expand Down
2 changes: 1 addition & 1 deletion packages/pkg/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
ArrayExpression as _ArrayExpression,
ObjectExpression as _ObjectExpression,
ObjectProperty as _ObjectProperty,
Expand Down
3 changes: 2 additions & 1 deletion packages/pkg/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ObjectProperty, StringLiteral } from './types.js'
import type { ObjectProperty, StringLiteral } from './types.js'

export function alphabetSort(a: number, b: number): number
export function alphabetSort(a: string, b: string): number
export function alphabetSort(a: number | string, b: number | string) {
/* c8 ignore next */
return a > b ? 1 : a < b ? -1 : 0
}

Expand Down
2 changes: 1 addition & 1 deletion packages/pkg/test/__snapshots__/engines.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1

exports[`engines 1`] = `
"{
Expand Down
2 changes: 1 addition & 1 deletion packages/pkg/test/__snapshots__/files.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1

exports[`files 1`] = `
"{
Expand Down
2 changes: 1 addition & 1 deletion packages/pkg/test/__snapshots__/test.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1

exports[`preprocess 1`] = `
"{
Expand Down
2 changes: 1 addition & 1 deletion packages/pkg/test/engines.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import prettier from 'prettier'

import PkgPlugin from '../src/index.js'
import PkgPlugin from 'prettier-plugin-pkg'

test('engines', () => {
const fixture = {
Expand Down

0 comments on commit 4b37afd

Please sign in to comment.