Skip to content

Commit

Permalink
Add rule for @ tokens (#106)
Browse files Browse the repository at this point in the history
* Add rule for '@' tokens

* 0.7.1

* Bump mo-fmt
  • Loading branch information
rvanasa authored Jul 21, 2023
1 parent 0d5f42b commit 9c5ca6c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prettier-plugin-motoko",
"version": "0.7.0",
"version": "0.7.1",
"description": "A code formatter for the Motoko smart contract language.",
"main": "lib/environments/node.js",
"browser": "lib/environments/web.js",
Expand Down
18 changes: 9 additions & 9 deletions packages/mo-fmt/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/mo-fmt/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mo-fmt",
"version": "0.7.0",
"version": "0.7.1",
"description": "An easy-to-use Motoko formatter command.",
"main": "src/cli.js",
"bin": {
Expand All @@ -22,7 +22,7 @@
"commander": "^9.4.0",
"fast-glob": "^3.2.11",
"prettier": "^3.0",
"prettier-plugin-motoko": "^0.7.0"
"prettier-plugin-motoko": "^0.7.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.2",
Expand Down
3 changes: 3 additions & 0 deletions src/printers/motoko-tt-ast/spaceConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ const spaceConfig: SpaceConfig = {
'keep',
],

// misc
[tokenEquals('@'), '_', 'keep'],

// default
['_', '_', 'space'],
],
Expand Down
4 changes: 4 additions & 0 deletions tests/formatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,10 @@ describe('Motoko formatter', () => {
);
});

test('@ symbol', async () => {
expect(await format('@abc')).toStrictEqual('@abc\n');
});

test('multi-line text', async () => {
await expectFormatted('"A\nB"\n');
await expectFormatted('" A\n B"\n');
Expand Down

0 comments on commit 9c5ca6c

Please sign in to comment.