mirror of
https://github.com/ivuorinen/tree-sitter-shellspec.git
synced 2026-02-14 20:52:14 +00:00
fix: address code review findings and critical issues
Critical Fixes: - Fixed EditorConfig violations in grammar.js, scanner.c, README.md, .mega-linter.yml - Changed JSDoc comments from 1-space to 2-space indent per .editorconfig - Fixed line length violations in README.md and .mega-linter.yml - Updated test count badge from 59/59 to 61/61 in README.md - Created queries/highlights.scm for syntax highlighting support - Updated package.json with repository and files fields Configuration Updates: - Added repository field pointing to GitHub - Added files field to control npm package contents - Properly formatted CONTRIBUTING.md with prettier All 61 tests passing (100% success rate) All critical EditorConfig violations resolved
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
---
|
---
|
||||||
# yaml-language-server: $schema=https://raw.githubusercontent.com/megalinter/megalinter/main/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json
|
# yaml-language-server:
|
||||||
|
# $schema=https://raw.githubusercontent.com/megalinter/megalinter/main/megalinter/descriptors/schemas/megalinter-configuration.jsonschema.json
|
||||||
# Configuration file for MegaLinter
|
# Configuration file for MegaLinter
|
||||||
# See all available variables at
|
# See all available variables at
|
||||||
# https://megalinter.io/configuration/ and in linters documentation
|
# https://megalinter.io/configuration/ and in linters documentation
|
||||||
|
|||||||
120
CONTRIBUTING.md
120
CONTRIBUTING.md
@@ -28,42 +28,42 @@ Thank you for your interest in contributing to tree-sitter-shellspec! This docum
|
|||||||
1. Fork the repository on GitHub
|
1. Fork the repository on GitHub
|
||||||
2. Clone your fork locally:
|
2. Clone your fork locally:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/YOUR_USERNAME/tree-sitter-shellspec.git
|
git clone https://github.com/YOUR_USERNAME/tree-sitter-shellspec.git
|
||||||
cd tree-sitter-shellspec
|
cd tree-sitter-shellspec
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Add the upstream repository:
|
3. Add the upstream repository:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git remote add upstream https://github.com/ivuorinen/tree-sitter-shellspec.git
|
git remote add upstream https://github.com/ivuorinen/tree-sitter-shellspec.git
|
||||||
```
|
```
|
||||||
|
|
||||||
## Development Setup
|
## Development Setup
|
||||||
|
|
||||||
1. **Install dependencies:**
|
1. **Install dependencies:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Generate the grammar:**
|
2. **Generate the grammar:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run generate
|
npm run generate
|
||||||
```
|
```
|
||||||
|
|
||||||
3. **Run tests:**
|
3. **Run tests:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm test
|
npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
4. **Build the parser:**
|
4. **Build the parser:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run build
|
npm run build
|
||||||
```
|
```
|
||||||
|
|
||||||
### Development Workflow
|
### Development Workflow
|
||||||
|
|
||||||
@@ -209,33 +209,34 @@ tree-sitter test --debug
|
|||||||
|
|
||||||
1. **Create a feature branch:**
|
1. **Create a feature branch:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git checkout -b feature/your-feature-name
|
git checkout -b feature/your-feature-name
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Make your changes** following the guidelines above
|
2. **Make your changes** following the guidelines above
|
||||||
|
|
||||||
3. **Commit with clear messages:**
|
3. **Commit with clear messages:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git commit -m "feat: add support for Data block modifiers
|
git commit -m "feat: add support for Data block modifiers
|
||||||
|
|
||||||
- Add :raw and :expand modifier support
|
- Add :raw and :expand modifier support
|
||||||
- Update test cases for new syntax
|
- Update test cases for new syntax
|
||||||
- Add documentation examples"
|
- Add documentation examples"
|
||||||
```
|
```
|
||||||
|
|
||||||
4. **Push to your fork:**
|
4. **Push to your fork:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git push origin feature/your-feature-name
|
git push origin feature/your-feature-name
|
||||||
```
|
```
|
||||||
|
|
||||||
5. **Create a Pull Request** with:
|
5. **Create a Pull Request** with:
|
||||||
- Clear description of changes
|
|
||||||
- References to related issues
|
- Clear description of changes
|
||||||
- Test results and coverage
|
- References to related issues
|
||||||
- Breaking change notes (if any)
|
- Test results and coverage
|
||||||
|
- Breaking change notes (if any)
|
||||||
|
|
||||||
### Commit Message Guidelines
|
### Commit Message Guidelines
|
||||||
|
|
||||||
@@ -282,43 +283,50 @@ Use the [Grammar Issue template](.github/ISSUE_TEMPLATE/grammar_issue.md) for:
|
|||||||
### High Priority
|
### High Priority
|
||||||
|
|
||||||
1. **Enhanced Data block support**
|
1. **Enhanced Data block support**
|
||||||
- `:raw` and `:expand` modifiers
|
|
||||||
- Pipe filter syntax (`Data | command`)
|
- `:raw` and `:expand` modifiers
|
||||||
- Multi-line `#|` syntax
|
- Pipe filter syntax (`Data | command`)
|
||||||
|
- Multi-line `#|` syntax
|
||||||
|
|
||||||
2. **Assertion parsing**
|
2. **Assertion parsing**
|
||||||
- When/The statement structures
|
|
||||||
- Matcher syntax parsing
|
- When/The statement structures
|
||||||
- Subject/predicate analysis
|
- Matcher syntax parsing
|
||||||
|
- Subject/predicate analysis
|
||||||
|
|
||||||
3. **Performance optimization**
|
3. **Performance optimization**
|
||||||
- Reduce parser conflicts
|
|
||||||
- Optimize grammar rules
|
- Reduce parser conflicts
|
||||||
- Improve parsing speed
|
- Optimize grammar rules
|
||||||
|
- Improve parsing speed
|
||||||
|
|
||||||
### Medium Priority
|
### Medium Priority
|
||||||
|
|
||||||
1. **Editor integration**
|
1. **Editor integration**
|
||||||
- Neovim configuration examples
|
|
||||||
- VS Code extension support
|
- Neovim configuration examples
|
||||||
- Emacs tree-sitter integration
|
- VS Code extension support
|
||||||
|
- Emacs tree-sitter integration
|
||||||
|
|
||||||
2. **Tooling improvements**
|
2. **Tooling improvements**
|
||||||
- Syntax highlighting themes
|
|
||||||
- Language server features
|
- Syntax highlighting themes
|
||||||
- Code formatting rules
|
- Language server features
|
||||||
|
- Code formatting rules
|
||||||
|
|
||||||
3. **Documentation**
|
3. **Documentation**
|
||||||
- Usage tutorials
|
|
||||||
- Grammar development guide
|
- Usage tutorials
|
||||||
- Editor setup instructions
|
- Grammar development guide
|
||||||
|
- Editor setup instructions
|
||||||
|
|
||||||
### Low Priority
|
### Low Priority
|
||||||
|
|
||||||
1. **Advanced features**
|
1. **Advanced features**
|
||||||
- ShellSpec custom matchers
|
|
||||||
- Configuration file parsing
|
- ShellSpec custom matchers
|
||||||
- Metadata extraction
|
- Configuration file parsing
|
||||||
|
- Metadata extraction
|
||||||
|
|
||||||
## Development Resources
|
## Development Resources
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
# tree-sitter-shellspec
|
# tree-sitter-shellspec
|
||||||
|
|
||||||
[](https://github.com/ivuorinen/tree-sitter-shellspec)
|
[](https://github.com/ivuorinen/tree-sitter-shellspec)
|
||||||
[](https://github.com/ivuorinen/tree-sitter-shellspec)
|
[](https://github.com/ivuorinen/tree-sitter-shellspec)
|
||||||
[](https://tree-sitter.github.io/)
|
[](https://tree-sitter.github.io/)
|
||||||
|
|
||||||
A comprehensive [Tree-sitter](https://tree-sitter.github.io/) grammar for [ShellSpec](https://shellspec.info/) - a BDD (Behavior Driven Development) testing framework for POSIX shell scripts.
|
A comprehensive [Tree-sitter](https://tree-sitter.github.io/) grammar for
|
||||||
|
[ShellSpec](https://shellspec.info/) - a BDD (Behavior Driven Development) testing framework for POSIX shell scripts.
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
This grammar extends the [tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash) grammar to provide complete parsing support for ShellSpec's BDD constructs.
|
This grammar extends the [tree-sitter-bash](https://github.com/tree-sitter/tree-sitter-bash) grammar to provide complete parsing support
|
||||||
|
for ShellSpec's BDD constructs.
|
||||||
|
|
||||||
It enables syntax highlighting, code navigation, and tooling integration for ShellSpec test files.
|
It enables syntax highlighting, code navigation, and tooling integration for ShellSpec test files.
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* @file ShellSpec grammar for tree-sitter (extends bash)
|
* @file ShellSpec grammar for tree-sitter (extends bash)
|
||||||
* @author Ismo Vuorinen <ismo@ivuorinen.net>
|
* @author Ismo Vuorinen <ismo@ivuorinen.net>
|
||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/// <reference types="tree-sitter-cli/dsl" />
|
/// <reference types="tree-sitter-cli/dsl" />
|
||||||
// @ts-check
|
// @ts-check
|
||||||
|
|||||||
12
package.json
12
package.json
@@ -5,6 +5,18 @@
|
|||||||
"main": "grammar.js",
|
"main": "grammar.js",
|
||||||
"author": "Ismo Vuorinen",
|
"author": "Ismo Vuorinen",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/ivuorinen/tree-sitter-shellspec.git"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"grammar.js",
|
||||||
|
"src",
|
||||||
|
"queries",
|
||||||
|
"binding.gyp",
|
||||||
|
"bindings",
|
||||||
|
"scripts"
|
||||||
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"generate": "tree-sitter generate && ./scripts/post-generate.sh",
|
"generate": "tree-sitter generate && ./scripts/post-generate.sh",
|
||||||
"generate:only": "tree-sitter generate",
|
"generate:only": "tree-sitter generate",
|
||||||
|
|||||||
85
queries/highlights.scm
Normal file
85
queries/highlights.scm
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
; ShellSpec Syntax Highlighting
|
||||||
|
; Extends tree-sitter-bash highlighting
|
||||||
|
|
||||||
|
; Block keywords (BDD test structure)
|
||||||
|
[
|
||||||
|
"Describe"
|
||||||
|
"Context"
|
||||||
|
"ExampleGroup"
|
||||||
|
"It"
|
||||||
|
"Example"
|
||||||
|
"Specify"
|
||||||
|
] @keyword.function
|
||||||
|
|
||||||
|
; Focused blocks (for running specific tests)
|
||||||
|
[
|
||||||
|
"fDescribe"
|
||||||
|
"fContext"
|
||||||
|
"fIt"
|
||||||
|
"fExample"
|
||||||
|
"fSpecify"
|
||||||
|
] @keyword.function.focused
|
||||||
|
|
||||||
|
; Skipped blocks (for temporarily disabling tests)
|
||||||
|
[
|
||||||
|
"xDescribe"
|
||||||
|
"xContext"
|
||||||
|
"xIt"
|
||||||
|
"xExample"
|
||||||
|
"xSpecify"
|
||||||
|
] @keyword.function.skipped
|
||||||
|
|
||||||
|
; Hook keywords
|
||||||
|
[
|
||||||
|
"Before"
|
||||||
|
"After"
|
||||||
|
"BeforeAll"
|
||||||
|
"AfterAll"
|
||||||
|
"BeforeEach"
|
||||||
|
"AfterEach"
|
||||||
|
"BeforeRun"
|
||||||
|
"AfterRun"
|
||||||
|
"BeforeCall"
|
||||||
|
"AfterCall"
|
||||||
|
] @keyword.control.hook
|
||||||
|
|
||||||
|
; Utility blocks
|
||||||
|
[
|
||||||
|
"Data"
|
||||||
|
"Parameters"
|
||||||
|
] @keyword.function.data
|
||||||
|
|
||||||
|
; Skip/Pending/Todo blocks
|
||||||
|
[
|
||||||
|
"Skip"
|
||||||
|
"Pending"
|
||||||
|
"Todo"
|
||||||
|
] @keyword.function.pending
|
||||||
|
|
||||||
|
; Directives
|
||||||
|
[
|
||||||
|
"Include"
|
||||||
|
] @keyword.directive
|
||||||
|
|
||||||
|
; Comments (inherit from bash)
|
||||||
|
(comment) @comment
|
||||||
|
|
||||||
|
; Strings (inherit from bash)
|
||||||
|
(string) @string
|
||||||
|
(raw_string) @string
|
||||||
|
|
||||||
|
; Functions (inherit from bash)
|
||||||
|
(function_definition
|
||||||
|
name: (word) @function)
|
||||||
|
|
||||||
|
; Variables (inherit from bash)
|
||||||
|
(variable_name) @variable
|
||||||
|
|
||||||
|
; Operators (inherit from bash)
|
||||||
|
[
|
||||||
|
"&&"
|
||||||
|
"||"
|
||||||
|
"|"
|
||||||
|
";"
|
||||||
|
"&"
|
||||||
|
] @operator
|
||||||
@@ -7923,4 +7923,4 @@
|
|||||||
"_primary_expression"
|
"_primary_expression"
|
||||||
],
|
],
|
||||||
"reserved": {}
|
"reserved": {}
|
||||||
}
|
}
|
||||||
@@ -3307,4 +3307,4 @@
|
|||||||
"type": "~",
|
"type": "~",
|
||||||
"named": false
|
"named": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -174,12 +174,12 @@ static void deserialize(Scanner *scanner, const char *buffer, unsigned length) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Consume a "word" in POSIX parlance, and returns it unquoted.
|
* Consume a "word" in POSIX parlance, and returns it unquoted.
|
||||||
*
|
*
|
||||||
* This is an approximate implementation that doesn't deal with any
|
* This is an approximate implementation that doesn't deal with any
|
||||||
* POSIX-mandated substitution, and assumes the default value for
|
* POSIX-mandated substitution, and assumes the default value for
|
||||||
* IFS.
|
* IFS.
|
||||||
*/
|
*/
|
||||||
static bool advance_word(TSLexer *lexer, String *unquoted_word) {
|
static bool advance_word(TSLexer *lexer, String *unquoted_word) {
|
||||||
bool empty = true;
|
bool empty = true;
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ extern "C" {
|
|||||||
/// Push a new `element` onto the end of the array.
|
/// Push a new `element` onto the end of the array.
|
||||||
#define array_push(self, element) \
|
#define array_push(self, element) \
|
||||||
(_array__grow((Array *)(self), 1, array_elem_size(self)), \
|
(_array__grow((Array *)(self), 1, array_elem_size(self)), \
|
||||||
(self)->contents[(self)->size++] = (element))
|
(self)->contents[(self)->size++] = (element))
|
||||||
|
|
||||||
/// Increase the array's size by `count` elements.
|
/// Increase the array's size by `count` elements.
|
||||||
/// New elements are zero-initialized.
|
/// New elements are zero-initialized.
|
||||||
@@ -218,8 +218,8 @@ static inline void _array__grow(Array *self, uint32_t count, size_t element_size
|
|||||||
|
|
||||||
/// This is not what you're looking for, see `array_splice`.
|
/// This is not what you're looking for, see `array_splice`.
|
||||||
static inline void _array__splice(Array *self, size_t element_size,
|
static inline void _array__splice(Array *self, size_t element_size,
|
||||||
uint32_t index, uint32_t old_count,
|
uint32_t index, uint32_t old_count,
|
||||||
uint32_t new_count, const void *elements) {
|
uint32_t new_count, const void *elements) {
|
||||||
uint32_t new_size = self->size + new_count - old_count;
|
uint32_t new_size = self->size + new_count - old_count;
|
||||||
uint32_t old_end = index + old_count;
|
uint32_t old_end = index + old_count;
|
||||||
uint32_t new_end = index + new_count;
|
uint32_t new_end = index + new_count;
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ struct TSLanguage {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
|
static inline bool set_contains(const TSCharacterRange *ranges, uint32_t len, int32_t lookahead) {
|
||||||
if (len == 0) return false;
|
|
||||||
uint32_t index = 0;
|
uint32_t index = 0;
|
||||||
uint32_t size = len - index;
|
uint32_t size = len - index;
|
||||||
while (size > 1) {
|
while (size > 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user