chore: add prettier and format all files

- Install prettier ^3.6.2
- Add .prettierrc with project formatting rules
- Add .prettierignore to exclude generated files and dependencies
- Add npm scripts: format and format:check
- Format all files with prettier
This commit is contained in:
2025-11-25 23:59:44 +02:00
parent dcad1573a8
commit 41b3c5d345
10 changed files with 76 additions and 29 deletions

View File

@@ -1,6 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>ivuorinen/renovate-config"
]
"extends": ["github>ivuorinen/renovate-config"]
}

View File

@@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: ['actions,javascript', 'cpp'] # Add languages used in your actions
language: ["actions,javascript", "cpp"] # Add languages used in your actions
steps:
- name: Checkout repository

24
.prettierignore Normal file
View File

@@ -0,0 +1,24 @@
# Dependencies
node_modules/
# Generated files
src/parser.c
src/grammar.json
src/node-types.json
src/tree_sitter/
# Build artifacts
build/
dist/
# Logs
*.log
megalinter-reports/
# Test specs (shell scripts have specific formatting)
test/spec/
# Lock files
package-lock.json
pnpm-lock.yaml
yarn.lock

11
.prettierrc Normal file
View File

@@ -0,0 +1,11 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": false,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"arrowParens": "always",
"endOfLine": "lf",
"proseWrap": "preserve"
}

View File

@@ -30,20 +30,20 @@ module.exports = grammar(bashGrammar, {
[$.pipeline],
// 2 essential ShellSpec conflicts
[$.command_name, $.shellspec_data_block],
[$.shellspec_hook_block]
[$.shellspec_hook_block],
],
rules: {
// 8 ShellSpec rule extensions
shellspec_describe_block, // Describe/fDescribe/xDescribe
shellspec_context_block, // Context/ExampleGroup variants
shellspec_it_block, // It/Example/Specify variants
shellspec_hook_block, // BeforeEach/AfterEach/etc blocks
shellspec_utility_block, // Parameters/Skip/Pending/Todo
shellspec_data_block, // Data blocks with statements/arguments
shellspec_hook_statement, // Before/After statements
shellspec_directive_statement // Include/Skip if
}
})
shellspec_describe_block, // Describe/fDescribe/xDescribe
shellspec_context_block, // Context/ExampleGroup variants
shellspec_it_block, // It/Example/Specify variants
shellspec_hook_block, // BeforeEach/AfterEach/etc blocks
shellspec_utility_block, // Parameters/Skip/Pending/Todo
shellspec_data_block, // Data blocks with statements/arguments
shellspec_hook_statement, // Before/After statements
shellspec_directive_statement, // Include/Skip if
},
});
```
### Supported ShellSpec Constructs

View File

@@ -139,7 +139,7 @@ check-ci:
### 2. Release Workflow (`release.yml`)
- **Triggers**: tags (v*.*.*), manual dispatch
- **Triggers**: tags (v*.*.\*), manual dispatch
- **Jobs**: validate, check-ci, security, release
- **Purpose**: Streamlined release process with CI dependency

View File

@@ -1,6 +1,6 @@
ignore_all_files_in_gitignore: true
ignored_paths:
- megalinter-reports
- megalinter-reports
read_only: false
# list of tool names to exclude. We recommend not excluding any tools, see the readme for more details.
@@ -46,8 +46,8 @@ excluded_tools: []
initial_prompt: ""
project_name: "tree-sitter-shellspec"
languages:
- cpp
- typescript
- bash
- cpp
- typescript
- bash
included_optional_tools: []
encoding: utf-8

17
package-lock.json generated
View File

@@ -14,6 +14,7 @@
"devDependencies": {
"markdownlint-cli": "^0.46.0",
"nodemon": "^3.0.1",
"prettier": "^3.6.2",
"tree-sitter-cli": "^0.25.0"
}
},
@@ -1278,6 +1279,22 @@
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/prettier": {
"version": "3.6.2",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz",
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
"dev": true,
"license": "MIT",
"bin": {
"prettier": "bin/prettier.cjs"
},
"engines": {
"node": ">=14"
},
"funding": {
"url": "https://github.com/prettier/prettier?sponsor=1"
}
},
"node_modules/pstree.remy": {
"version": "1.1.8",
"resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",

View File

@@ -16,6 +16,8 @@
"lint": "npx mega-linter-runner",
"lint:yaml": "yamllint .",
"lint:markdown": "markdownlint . --config .markdownlint.json --ignore node_modules --fix",
"format": "prettier --write .",
"format:check": "prettier --check .",
"precommit": "pre-commit run --all-files",
"clean": "rm -rf src/parser.c src/grammar.json src/node-types.json",
"rebuild": "npm run clean && npm run generate"
@@ -37,6 +39,7 @@
"devDependencies": {
"markdownlint-cli": "^0.46.0",
"nodemon": "^3.0.1",
"prettier": "^3.6.2",
"tree-sitter-cli": "^0.25.0"
}
}

View File

@@ -5,15 +5,9 @@
"camelcase": "Shellspec",
"scope": "source.shellspec",
"path": ".",
"file-types": [
"shellspec"
],
"highlights": [
"queries/highlights.scm"
],
"locals": [
"queries/locals.scm"
],
"file-types": ["shellspec"],
"highlights": ["queries/highlights.scm"],
"locals": ["queries/locals.scm"],
"injection-regex": "shellspec"
}
],