Skip to content

Commit

Permalink
Add deno to CI for formatting and linting
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Jan 3, 2024
1 parent 31574e9 commit 991760c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 57 deletions.
25 changes: 0 additions & 25 deletions .eslintrc.js

This file was deleted.

20 changes: 11 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ on:
push:

jobs:
# FIXME: re-enable once upgrading to the new tree-sitter format
# lint:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Install modules
# run: npm install
# - name: Run ESLint
# run: npm run lint
deno:
name: Deno format and lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v1
with:
deno-version: "~1.39"
- run: deno lint
- run: deno fmt --check

test:
runs-on: ${{ matrix.os }}
Expand All @@ -28,3 +29,4 @@ jobs:
- run: npm install
- run: npm test
# FIXME: also parse tests/*.just

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
target/**
node_modules
build
log.html
3 changes: 3 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"exclude": ["src/", "bindings/", "*.md"]
}
36 changes: 18 additions & 18 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = grammar({
"set",
field("name", $.NAME),
field("right", optional(seq(":=", choice($.boolean, $.settinglist)))),
$.eol
$.eol,
),
seq(
"set",
Expand All @@ -56,18 +56,18 @@ module.exports = grammar({
'"',
repeat(seq(optional(","), $.string)),
"]",
$.eol
)
$.eol,
),
),

// boolean : ':=' ('true' | 'false')
boolean: ($) => choice("true", "false"),
boolean: (_) => choice("true", "false"),

settinglist: ($) =>
seq(
"[",
$.stringlist,
"]"
"]",
// seq("[", $.string, repeat(seq(",", $.string)), optional(","), "]")
),

Expand All @@ -88,11 +88,11 @@ module.exports = grammar({
"else",
"{",
field("else", $.expression),
"}"
"}",
),
seq($.value, "+", $.expression),
seq($.value, "/", $.expression),
$.value
$.value,
),

// condition : expression '==' expression
Expand All @@ -102,7 +102,7 @@ module.exports = grammar({
choice(
seq($.expression, "==", $.expression),
seq($.expression, "!=", $.expression),
seq($.expression, "=~", $.expression)
seq($.expression, "=~", $.expression),
),

// value : NAME '(' sequence? ')'
Expand All @@ -114,7 +114,7 @@ module.exports = grammar({
value: ($) =>
prec.left(
0,
choice($.call, $.cmd, $.NAME, $.string, seq("(", $.expression, ")"))
choice($.call, $.cmd, $.NAME, $.string, seq("(", $.expression, ")")),
),

call: ($) => seq($.NAME, "(", optional($.sequence), ")"),
Expand All @@ -133,7 +133,7 @@ module.exports = grammar({
sequence: ($) =>
choice(
seq($.expression, ",", $.sequence),
seq($.expression, optional(","))
seq($.expression, optional(",")),
),

// recipe : '@'? NAME parameter* variadic_parameters? ':' dependency* body?
Expand All @@ -146,7 +146,7 @@ module.exports = grammar({
optional($.parameters),
":",
optional(" "),
optional($.dependencies)
optional($.dependencies),
),

parameters: ($) =>
Expand All @@ -157,7 +157,7 @@ module.exports = grammar({
parameter: ($) =>
choice(
seq(optional("$"), $.NAME),
seq(optional("$"), $.NAME, "=", $.value)
seq(optional("$"), $.NAME, "=", $.value),
),

// variadic_parameters : '*' parameter
Expand All @@ -178,7 +178,7 @@ module.exports = grammar({
seq(
$.INDENT,
choice($.shebang_recipe, optional($.recipe_body)),
$.DEDENT
$.DEDENT,
),
// seq($.INDENT, $.recipebody, $.DEDENT),

Expand All @@ -190,9 +190,9 @@ module.exports = grammar({
"#!",
choice(
seq(/.*\//, field("interpreter", $.TEXT)),
seq("/usr/bin/env", field("interpreter", $.TEXT))
seq("/usr/bin/env", field("interpreter", $.TEXT)),
),
$.NEWLINE
$.NEWLINE,
),

recipe_body: ($) => repeat1($.line),
Expand All @@ -206,14 +206,14 @@ module.exports = grammar({
$.notcomment,
// repeat(choice($.interpolation, $.notinterpolation)),
repeat(choice($.interpolation, $.TEXT)),
$.NEWLINE
$.NEWLINE,
),
// notcomment: ($) => /[^#\s{]\S*/,
notcomment: ($) => /[^#\s]\S*/,
notcomment: (_) => /[^#\s]\S*/,
comment: ($) => seq(/#[^!].*/, /.*/, $.NEWLINE),

// notinterpolation: ($) => /[^{][^{]\S*/,
notinterpolation: ($) => /[^\s{][^\s{]\S*/,
notinterpolation: (_) => /[^\s{][^\s{]\S*/,

// interpolation : '{{' expression '}}'
interpolation: ($) => seq("{{", $.expression, "}}"),
Expand Down
7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"main": "grammar.js",
"scripts": {
"test": "tree-sitter test",
"gen": "tree-sitter generate",
"lint": "eslint grammar.js"
"gen": "tree-sitter generate"
},
"repository": {
"type": "git",
Expand All @@ -25,9 +24,7 @@
"tree-sitter": "^0.20.6"
},
"devDependencies": {
"tree-sitter-cli": "^0.20.8",
"eslint": "^8.56.0",
"eslint-config-google": "^0.14.0"
"tree-sitter-cli": "^0.20.8"
},
"tree-sitter": [
{
Expand Down

0 comments on commit 991760c

Please sign in to comment.