Skip to content

Commit

Permalink
Merge pull request #1056 from prettier-solidity/slang-0.18.0
Browse files Browse the repository at this point in the history
Slang 0.18.3
  • Loading branch information
Janther authored Nov 2, 2024
2 parents 921b501 + a0316e5 commit 1cf3dfd
Show file tree
Hide file tree
Showing 310 changed files with 1,903 additions and 2,074 deletions.
40 changes: 10 additions & 30 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,8 @@ jobs:
- name: lint
run: npm run lint

# test_bundle:
# name: Test production
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: 16
# cache: 'npm'
# - name: Install
# run: npm install
# - name: Build
# run: npm run build
# - name: Build test app
# run: npm run build:test
# - name: Run tests
# run: npm run test:standalone

test_prettier_v2:
name: Prettier V2
test_bundle:
name: Test production
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -52,14 +34,12 @@ jobs:
cache: 'npm'
- name: Install
run: npm install
- name: Build with Prettier V3
- name: Build
run: npm run build
- name: Downgrade Prettier to V2
run: npm install [email protected]
# - name: Build test app
# run: npm run build:test
# - name: Run standalone tests
# run: npm run test:standalone
- name: Build test app
run: npm run build:test
- name: Run tests
run: npm run test:standalone -- --runInBand

test_linux:
name: Test on Linux with Node ${{ matrix.node }}
Expand All @@ -76,7 +56,7 @@ jobs:
- name: Install
run: npm install
- name: Run tests
run: npm run test:all
run: npm run test:all -- --runInBand

test_macos:
name: Test on MacOS with Node 16
Expand All @@ -90,7 +70,7 @@ jobs:
- name: Install
run: npm install
- name: Run tests
run: npm run test:all
run: npm run test:all -- --runInBand

test_windows:
name: Test on Windows with Node 16
Expand All @@ -104,4 +84,4 @@ jobs:
- name: Install
run: npm install
- name: Run tests
run: npm run test:all
run: npm run test:all -- --runInBand
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Install both `prettier` and `prettier-plugin-solidity`:
npm install --save-dev prettier prettier-plugin-solidity
```

> :package: ** Make sure `prettier`'s version is at least `3.0.0`**
Run prettier in your contracts:

```Bash
Expand All @@ -46,25 +48,27 @@ Or you can use it as part of your linting to check that all your code is prettif

> Prettier Solidity only works with valid code. If there is a syntax error, nothing will be done and a parser error will be thrown.
### ~~Using in the Browser~~ _Disabled during v2.0.0-beta_
### Using in the Browser

_Added in v1.1.0_

To use this package in the browser, you need to load Prettier's standalone bundle before loading the build provided in this package.

```html
<script src="https://unpkg.com/prettier@latest"></script>
<script src="https://unpkg.com/prettier-plugin-solidity@latest"></script>
```

Prettier's unpkg field points to `https://unpkg.com/prettier/standalone.js`, in a similar way this plugin points to `https://unpkg.com/prettier-plugin-solidity/dist/standalone.js`.

Once the scripts are loaded you will have access the globals `prettier` and `prettierPlugins`.

We follow Prettier's strategy for populating their plugins in the object `prettierPlugins`, you can load other plugins like `https://unpkg.com/[email protected]/parser-markdown.js` and Prettier will have access to multiple parsers.

```html
<script>
<script type="module">
const prettier = await import(
'https://unpkg.com/prettier-plugin-solidity@latest'
);
const prettierSolidity = await import(
'https://unpkg.com/prettier-plugin-solidity@latest'
);
async function format(code) {
return await prettier.format(code, {
parser: 'slang-solidity',
Expand All @@ -79,7 +83,7 @@ We follow Prettier's strategy for populating their plugins in the object `pretti

For more details and please have a look at [Prettier's documentation](https://prettier.io/docs/en/browser.html).

### ~~Creating a package for the Browser~~ _Disabled during v2.0.0-beta_
### Creating a package for the Browser

_Added in v1.2.0_

Expand Down
Loading

0 comments on commit 1cf3dfd

Please sign in to comment.