Skip to content

Commit df34495

Browse files
committed
chore(style,grammar): add tree-sitter-eslint config file
1 parent 64ba3f8 commit df34495

2 files changed

Lines changed: 40 additions & 38 deletions

File tree

eslint.config.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import treesitter from 'eslint-config-treesitter';
2-
import prettier from 'eslint-config-prettier';
32

4-
export default [...treesitter, prettier];
3+
export default [
4+
...treesitter,
5+
];

grammar.js

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/// <reference types="tree-sitter-cli/dsl" />
22
// @ts-check
3+
34
module.exports = grammar({
45
name: 'nu',
56

@@ -911,12 +912,12 @@ module.exports = grammar({
911912

912913
_str_single_quotes: ($) =>
913914
seq(
914-
"'",
915+
'\'',
915916
alias(
916917
token.immediate(prec(prec_map().string, /[^']*/)),
917918
$.string_content,
918919
),
919-
token.immediate("'"),
920+
token.immediate('\''),
920921
),
921922

922923
_str_back_ticks: ($) =>
@@ -955,14 +956,14 @@ module.exports = grammar({
955956

956957
_inter_single_quotes: ($) =>
957958
seq(
958-
"$'",
959+
'$\'',
959960
repeat(
960961
choice(
961962
field('expr', $.expr_interpolated),
962963
$.unescaped_interpolated_content,
963964
),
964965
),
965-
token.immediate("'"),
966+
token.immediate('\''),
966967
),
967968

968969
_inter_double_quotes: ($) =>
@@ -1579,14 +1580,14 @@ function _ctrl_try_rule(parenthesized) {
15791580
keyword().try,
15801581
field('try_branch', $.block),
15811582
optional(
1582-
parenthesized
1583-
? _insert_newline($, seq_catch_array, true, false)
1584-
: seq(...seq_catch_array),
1583+
parenthesized ?
1584+
_insert_newline($, seq_catch_array, true, false) :
1585+
seq(...seq_catch_array),
15851586
),
15861587
];
1587-
return parenthesized
1588-
? _insert_newline($, seq_array, false, false)
1589-
: seq(...seq_array);
1588+
return parenthesized ?
1589+
_insert_newline($, seq_array, false, false) :
1590+
seq(...seq_array);
15901591
};
15911592
}
15921593

@@ -1611,14 +1612,14 @@ function _ctrl_if_rule(parenthesized) {
16111612
field('condition', _expr),
16121613
field('then_branch', $.block),
16131614
optional(
1614-
parenthesized
1615-
? _insert_newline($, seq_else_array, true, false)
1616-
: seq(...seq_else_array),
1615+
parenthesized ?
1616+
_insert_newline($, seq_else_array, true, false) :
1617+
seq(...seq_else_array),
16171618
),
16181619
];
1619-
return parenthesized
1620-
? _insert_newline($, seq_array, false, false)
1621-
: seq(...seq_array);
1620+
return parenthesized ?
1621+
_insert_newline($, seq_array, false, false) :
1622+
seq(...seq_array);
16221623
};
16231624
}
16241625

@@ -1627,9 +1628,9 @@ function _ctrl_if_rule(parenthesized) {
16271628
*/
16281629
function _expr_binary_rule(parenthesized) {
16291630
return (/** @type {any} */ $) => {
1630-
const _expr = parenthesized
1631-
? $._expr_binary_expression_parenthesized
1632-
: $._expr_binary_expression;
1631+
const _expr = parenthesized ?
1632+
$._expr_binary_expression_parenthesized :
1633+
$._expr_binary_expression;
16331634
return choice(
16341635
...table().map(([precedence, opr]) => {
16351636
const seq_array = [
@@ -1644,9 +1645,9 @@ function _expr_binary_rule(parenthesized) {
16441645
),
16451646
),
16461647
];
1647-
return parenthesized
1648-
? prec.left(precedence, _insert_newline($, seq_array))
1649-
: prec.left(precedence, seq(...seq_array));
1648+
return parenthesized ?
1649+
prec.left(precedence, _insert_newline($, seq_array)) :
1650+
prec.left(precedence, seq(...seq_array));
16501651
}),
16511652
);
16521653
};
@@ -1657,19 +1658,19 @@ function _expr_binary_rule(parenthesized) {
16571658
*/
16581659
function _binary_predicate_rule(parenthesized) {
16591660
return (/** @type {any} */ $) => {
1660-
const _expr = parenthesized
1661-
? $._binary_predicate_parenthesized
1662-
: $._binary_predicate;
1661+
const _expr = parenthesized ?
1662+
$._binary_predicate_parenthesized :
1663+
$._binary_predicate;
16631664
return choice(
16641665
...binary().map(([precedence, opr]) => {
16651666
const seq_array = [
16661667
field('lhs', choice($.where_predicate, _expr)),
16671668
field('opr', opr),
16681669
field('rhs', choice($.where_predicate, _expr)),
16691670
];
1670-
return parenthesized
1671-
? prec.left(precedence, _insert_newline($, seq_array))
1672-
: prec.left(precedence, seq(...seq_array));
1671+
return parenthesized ?
1672+
prec.left(precedence, _insert_newline($, seq_array)) :
1673+
prec.left(precedence, seq(...seq_array));
16731674
}),
16741675
);
16751676
};
@@ -1688,17 +1689,17 @@ function _where_clause_rule(parenthesized) {
16881689
$.where_predicate,
16891690
$.val_closure,
16901691
alias(
1691-
parenthesized
1692-
? $._binary_predicate_parenthesized
1693-
: $._binary_predicate,
1692+
parenthesized ?
1693+
$._binary_predicate_parenthesized :
1694+
$._binary_predicate,
16941695
$.where_predicate,
16951696
),
16961697
),
16971698
),
16981699
];
1699-
return parenthesized
1700-
? prec.left(_insert_newline($, seq_array))
1701-
: seq(...seq_array);
1700+
return parenthesized ?
1701+
prec.left(_insert_newline($, seq_array)) :
1702+
seq(...seq_array);
17021703
};
17031704
}
17041705

@@ -1762,8 +1763,8 @@ function _range_rule(anonymous) {
17621763
};
17631764
};
17641765

1765-
const { opr, step: opr_step } = create_opr(false);
1766-
const { opr: opr_imm, step: opr_step_imm } = create_opr(true);
1766+
const {opr, step: opr_step} = create_opr(false);
1767+
const {opr: opr_imm, step: opr_step_imm} = create_opr(true);
17671768

17681769
return (/** @type {any} */ $) => {
17691770
const member = choice(

0 commit comments

Comments
 (0)