diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 28cba67..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1,25 +0,0 @@ -module.exports = { - "env": { - "commonjs": true, - "es2021": true, - }, - "extends": "google", - "overrides": [], - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module", - }, - "rules": { - "indent": ["error", 2, { "SwitchCase": 1 }], - "max-len": [ - "error", - { - "code": 160, - "ignoreComments": true, - "ignoreUrls": true, - "ignoreStrings": true, - }, - ], - "one-var": ["error", "consecutive"], - }, -}; diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ebbbc8b..10af0eb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,15 +4,15 @@ 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: denoland/setup-deno@v1 + with: + deno-version: "~1.39" + - run: deno lint + - run: deno fmt --check test: runs-on: ${{ matrix.os }} @@ -28,3 +28,4 @@ jobs: - run: npm install - run: npm test # FIXME: also parse tests/*.just + diff --git a/.gitignore b/.gitignore index a3c047b..3ba209d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ target/** node_modules build +log.html diff --git a/deno.jsonc b/deno.jsonc new file mode 100644 index 0000000..55e8fbd --- /dev/null +++ b/deno.jsonc @@ -0,0 +1,3 @@ +{ + "exclude": ["src/", "bindings/", "*.md"] +} diff --git a/grammar.js b/grammar.js index 19c16b6..a3da915 100644 --- a/grammar.js +++ b/grammar.js @@ -43,7 +43,7 @@ module.exports = grammar({ "set", field("name", $.NAME), field("right", optional(seq(":=", choice($.boolean, $.settinglist)))), - $.eol + $.eol, ), seq( "set", @@ -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(","), "]") ), @@ -88,11 +88,11 @@ module.exports = grammar({ "else", "{", field("else", $.expression), - "}" + "}", ), seq($.value, "+", $.expression), seq($.value, "/", $.expression), - $.value + $.value, ), // condition : expression '==' expression @@ -102,7 +102,7 @@ module.exports = grammar({ choice( seq($.expression, "==", $.expression), seq($.expression, "!=", $.expression), - seq($.expression, "=~", $.expression) + seq($.expression, "=~", $.expression), ), // value : NAME '(' sequence? ')' @@ -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), ")"), @@ -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? @@ -146,7 +146,7 @@ module.exports = grammar({ optional($.parameters), ":", optional(" "), - optional($.dependencies) + optional($.dependencies), ), parameters: ($) => @@ -157,7 +157,7 @@ module.exports = grammar({ parameter: ($) => choice( seq(optional("$"), $.NAME), - seq(optional("$"), $.NAME, "=", $.value) + seq(optional("$"), $.NAME, "=", $.value), ), // variadic_parameters : '*' parameter @@ -178,7 +178,7 @@ module.exports = grammar({ seq( $.INDENT, choice($.shebang_recipe, optional($.recipe_body)), - $.DEDENT + $.DEDENT, ), // seq($.INDENT, $.recipebody, $.DEDENT), @@ -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), @@ -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, "}}"), diff --git a/package.json b/package.json index 85568c8..420eac4 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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": [ {