Skip to content

Commit 0fded41

Browse files
authored
Merge pull request #1032 from prettier-solidity/slang
Slang
2 parents 889a5bb + 22edc8e commit 0fded41

File tree

492 files changed

+15285
-660
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

492 files changed

+15285
-660
lines changed

.c8rc

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
{
22
"check-coverage": true,
3-
"branches": 99,
4-
"lines": 100,
5-
"functions": 100,
6-
"statements": 100,
7-
"exclude": ["/node_modules/", "/src/prettier-comments/"],
8-
"include": [
9-
"src/**/*.js",
10-
"!src/prettier-comments/**/*.js",
11-
"!src/common/backward-compatibility.js"
12-
],
3+
"branches": 90,
4+
"lines": 90,
5+
"functions": 90,
6+
"statements": 90,
7+
"exclude": ["/node_modules/"],
8+
"include": ["src/**/*.ts", "!src/slang-utils/backward-compatibility.ts"],
139
"reporter": ["lcov", "text"],
1410
"temp-dir": "./coverage/"
1511
}

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
coverage/**/*.js
2+
dist/**/*.cjs
23
dist/**/*.js
4+
tests/**/*.snap
35
tests/format/**/*.sol
46
tests/format/Markdown/Markdown.md
57
tests/format/RespectDefaultOptions/respect-default-options.js

.eslintrc

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,42 @@
22
"env": {
33
"jest": true
44
},
5-
"extends": ["airbnb-base", "prettier"],
65
"globals": {
7-
"run_spec": false
8-
},
9-
"parserOptions": {
10-
"ecmaVersion": "latest",
11-
"sourceType": "module"
6+
"runFormatTest": "readonly"
127
},
138
"rules": {
14-
"import/extensions": "off",
15-
"import/prefer-default-export": "off"
16-
}
9+
"no-console": ["error", { "allow": ["warn"] }]
10+
},
11+
"overrides": [
12+
{
13+
"files": ["**/*.ts"],
14+
"extends": [
15+
"prettier",
16+
"plugin:@typescript-eslint/recommended",
17+
"plugin:@typescript-eslint/stylistic",
18+
"plugin:@typescript-eslint/recommended-type-checked"
19+
],
20+
"parser": "@typescript-eslint/parser",
21+
"plugins": ["@typescript-eslint"],
22+
"parserOptions": {
23+
"project": ["tsconfig.json"]
24+
},
25+
"rules": {
26+
"@typescript-eslint/explicit-function-return-type": "error"
27+
}
28+
},
29+
{
30+
"files": ["**/*.*js"],
31+
"extends": ["airbnb-base", "prettier"],
32+
"parserOptions": {
33+
"ecmaVersion": "latest",
34+
"sourceType": "module"
35+
},
36+
"rules": {
37+
"import/extensions": "off",
38+
"import/prefer-default-export": "off",
39+
"class-methods-use-this": "off"
40+
}
41+
}
42+
]
1743
}

.github/workflows/CI.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@ jobs:
2323
- name: lint
2424
run: npm run lint
2525

26-
test_bundle:
27-
name: Test production
28-
runs-on: ubuntu-latest
29-
steps:
30-
- uses: actions/checkout@v3
31-
- uses: actions/setup-node@v3
32-
with:
33-
node-version: 16
34-
cache: 'npm'
35-
- name: Install
36-
run: npm install
37-
- name: Build
38-
run: npm run build
39-
- name: Build test app
40-
run: npm run build:test
41-
- name: Run tests
42-
run: npm run test:standalone
26+
# test_bundle:
27+
# name: Test production
28+
# runs-on: ubuntu-latest
29+
# steps:
30+
# - uses: actions/checkout@v3
31+
# - uses: actions/setup-node@v3
32+
# with:
33+
# node-version: 16
34+
# cache: 'npm'
35+
# - name: Install
36+
# run: npm install
37+
# - name: Build
38+
# run: npm run build
39+
# - name: Build test app
40+
# run: npm run build:test
41+
# - name: Run tests
42+
# run: npm run test:standalone
4343

4444
test_prettier_v2:
4545
name: Prettier V2
@@ -56,10 +56,10 @@ jobs:
5656
run: npm run build
5757
- name: Downgrade Prettier to V2
5858
run: npm install [email protected]
59-
- name: Build test app
60-
run: npm run build:test
61-
- name: Run standalone tests
62-
run: npm run test:standalone tests/format tests/integration tests/unit/prettier-version
59+
# - name: Build test app
60+
# run: npm run build:test
61+
# - name: Run standalone tests
62+
# run: npm run test:standalone
6363

6464
test_linux:
6565
name: Test on Linux with Node ${{ matrix.node }}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 prettier-solidity
3+
Copyright (c) 2024 prettier-solidity
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
A [Prettier plugin](https://prettier.io/docs/en/plugins.html) for automatically formatting your [Solidity](https://github.com/ethereum/solidity) code.
1212

13+
## Nomic Foundation's Slang
14+
15+
Nomic Foundation has put a lot of effort in providing a set of compiler APIs that helped us rethink our approach to parsing and rely on their flexibility, detail oriented solution and continuos support of new and old Solidity syntaxes.
16+
17+
Since v2.0.0 this package will ship with the Slang parser and this change must be implemented in existing configurations by replacing `parser: 'solidity-parse'` with `parser: 'slang-solidity'`.
18+
1319
## Installation and usage
1420

1521
### Using in NodeJS
@@ -40,7 +46,7 @@ Or you can use it as part of your linting to check that all your code is prettif
4046

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

4551
_Added in v1.1.0_
4652

@@ -61,7 +67,7 @@ We follow Prettier's strategy for populating their plugins in the object `pretti
6167
<script>
6268
async function format(code) {
6369
return await prettier.format(code, {
64-
parser: 'solidity-parse',
70+
parser: 'slang-solidity',
6571
plugins: [solidityPlugin]
6672
});
6773
}
@@ -73,7 +79,7 @@ We follow Prettier's strategy for populating their plugins in the object `pretti
7379

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

76-
### Creating a package for the Browser
82+
### ~~Creating a package for the Browser~~ _Disabled during v2.0.0-beta_
7783

7884
_Added in v1.2.0_
7985

@@ -85,7 +91,7 @@ import solidityPlugin from 'prettier-plugin-solidity/standalone';
8591

8692
async function format(code) {
8793
return await prettier.format(code, {
88-
parser: "solidity-parse",
94+
parser: "slang-solidity",
8995
plugins: [solidityPlugin],
9096
});
9197
}
@@ -106,7 +112,7 @@ The following is the default configuration internally used by this plugin.
106112
{
107113
"files": "*.sol",
108114
"options": {
109-
"parser": "solidity-parse",
115+
"parser": "slang-solidity",
110116
"printWidth": 80,
111117
"tabWidth": 4,
112118
"useTabs": false,

jest.config.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
const TEST_STANDALONE = Boolean(process.env.TEST_STANDALONE);
2-
const testMatch = [
3-
'<rootDir>/tests/format/**/jsfmt.spec.js',
4-
5-
'<rootDir>/tests/unit/**/*.test.js'
6-
];
2+
const testMatch = ['<rootDir>/tests/format/**/format.test.js'];
73

84
if (TEST_STANDALONE) {
9-
testMatch.push('<rootDir>/tests/integration/**/*.test.js');
5+
testMatch.push(
6+
'<rootDir>/tests/integration/**/*.test.js',
7+
'<rootDir>/tests/unit/prettier-version/**/*.test.js'
8+
);
9+
} else {
10+
testMatch.push('<rootDir>/tests/unit/**/*.test.js');
1011
}
1112

1213
export default {
1314
runner: 'jest-light-runner',
14-
setupFiles: ['<rootDir>/tests/config/setup.js'],
15+
setupFiles: ['<rootDir>/tests/config/format-test-setup.js'],
1516
snapshotSerializers: [
1617
'jest-snapshot-serializer-raw',
1718
'jest-snapshot-serializer-ansi'
1819
],
19-
testEnvironment: 'node',
2020
// ignore console warnings in TEST_STANDALONE
2121
silent: TEST_STANDALONE,
2222
testPathIgnorePatterns: TEST_STANDALONE
@@ -27,7 +27,6 @@ export default {
2727
]
2828
: [],
2929
testMatch,
30-
transform: {},
3130
watchPlugins: [
3231
'jest-watch-typeahead/filename',
3332
'jest-watch-typeahead/testname'

0 commit comments

Comments
 (0)