feat(style): Introduce Prettier for automated code style enforcement#359
Draft
pgfeller wants to merge 2 commits into
Draft
feat(style): Introduce Prettier for automated code style enforcement#359pgfeller wants to merge 2 commits into
pgfeller wants to merge 2 commits into
Conversation
- Add .prettierrc configuration (printWidth=120, tabWidth=4, singleQuote, semi=false, trailingComma=es5, LF line endings) - Add .prettierignore to exclude build outputs, node_modules, coverage, generated files, and vendored grammar/icon-theme files - Add husky pre-commit hook running lint-staged - Add lint-staged config: runs prettier --write + eslint on TS/JS files, prettier --write on JSON/MD files - Add npm scripts: format, format:check, lint:fix - Add eslint-config-prettier to disable ESLint rules that conflict with Prettier - Apply Prettier formatting to all existing source files Closes openhab#334 Signed-off-by: Patrik Gfeller <patrik.gfeller@proton.me>
There was a problem hiding this comment.
Pull request overview
This PR introduces automated code formatting via Prettier (with pre-commit enforcement through Husky + lint-staged) and applies the formatter across the existing codebase to standardize style and reduce formatting-only review noise.
Changes:
- Add Prettier configuration/ignore rules plus Husky + lint-staged pre-commit enforcement and formatting/lint scripts.
- Reformat TS/JS/JSON/MD/CSS and workflow/config files to match the new style (4-space indent, single quotes, no semicolons, etc.).
- Add CI jobs to check formatting and run ESLint.
Reviewed changes
Copilot reviewed 76 out of 97 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Reformats TS project config to match Prettier JSON style. |
| snippets/openhab_sitemaps.json | Reformats snippet JSON. |
| snippets/openhab_rules_typeconversions.json | Reformats snippet JSON. |
| snippets/openhab_rules_designpattern.json | Reformats snippet JSON. |
| snippets/openhab_rules.json | Reformats snippet JSON (incl. whitespace cleanup). |
| snippets/openhab.json | Normalizes line endings/formatting for snippet JSON. |
| shared.webpack.config.js | Reformats shared webpack config to Prettier style. |
| serverJS/webpack.config.js | Reformats server webpack config to Prettier style. |
| serverJS/src/Server.js | Reformats language server implementation to Prettier style. |
| serverJS/src/LSPServer.js | Reformats module export object (comma/trailing style). |
| serverJS/src/ItemCompletion/ItemCompletionProvider.js | Reformats provider implementation; no intentional logic changes. |
| serverJS/src/ItemCompletion/Item.js | Reformats Item model implementation. |
| serverJS/src/DocumentValidation/DocumentValidator.js | Reformats validator module export formatting. |
| serverJS/package.json | Reformats package metadata JSON. |
| serverJS/jest-unit.json | Reformats Jest unit config JSON. |
| serverJS/jest-integration.json | Reformats Jest integration config JSON. |
| serverJS/tests/unit/Server.test.js | Reformats unit tests. |
| serverJS/tests/unit/LSPServer.test.js | Reformats unit tests. |
| serverJS/tests/unit/ItemCompletion/Item.test.js | Reformats unit tests. |
| serverJS/tests/unit/DocumentValidation/DocumentValidator.test.js | Reformats unit tests. |
| serverJS/tests/integration/Server.test.js | Reformats integration tests. |
| serverJS/tests/integration/LSPServer.test.js | Reformats integration tests. |
| serverJS/tests/integration/ItemCompletion/ItemCompletionProvider.test.js | Reformats integration tests. |
| serverJS/mocks/vscode-languageserver.js | Reformats Jest mock module. |
| serverJS/mocks/Server.js | Reformats Jest mock module. |
| serverJS/mocks/ItemCompletion/ItemCompletionProvider.js | Reformats Jest mock module. |
| serverJS/mocks/DocumentValidation/DocumentValidator.js | Reformats Jest mock module. |
| scripts/dev-help.js | Reformats dev helper script output concatenation. |
| package.json | Adds format/lint scripts, Husky/lint-staged/Prettier deps, lint-staged config, and view icons. |
| meta/language-configuration.json | Reformats language configuration JSON. |
| docs/USAGE.md | Reformats markdown (quotes/emphasis/escaping) to Prettier style. |
| client/webpack.config.js | Reformats client webpack config. |
| client/tsconfig.test.json | Reformats test TS config. |
| client/tsconfig.json | Reformats client TS config. |
| client/src/extension.ts | Reformats extension activation/commands wiring. |
| client/src/WebViews/media/vscode.css | Reformats CSS to consistent indentation/quoting. |
| client/src/WebViews/media/updateNoticePanel.css | Reformats CSS, including expanded selector formatting. |
| client/src/WebViews/media/reset.css | Reformats CSS reset file. |
| client/src/WebViews/getNonce.ts | Reformats nonce helper code style. |
| client/src/WebViews/UpdateNoticePanel.ts | Reformats Update Notice webview panel code. |
| client/src/WebViews/PreviewPanel.ts | Reformats preview webview panel code. |
| client/src/Utils/types.ts | Reformats exported constants/objects. |
| client/src/Utils/Utils.ts | Reformats utility functions and promise chains. |
| client/src/Utils/MigrationManager.ts | Reformats migration helper logic. |
| client/src/Utils/ConfigManager.ts | Reformats config manager implementation and event handler formatting. |
| client/src/ThingsExplorer/ThingsModel.ts | Reformats model code and fetch promise chain formatting. |
| client/src/ThingsExplorer/ThingsExplorer.ts | Reformats explorer tree provider. |
| client/src/ThingsExplorer/Thing.ts | Reformats Thing wrapper class. |
| client/src/ThingsExplorer/ItemsProvider.ts | Reformats snippet generation helpers/providers. |
| client/src/ThingsExplorer/IThing.ts | Reformats TS interface declaration. |
| client/src/ThingsExplorer/IChannel.ts | Reformats TS interface declaration. |
| client/src/ThingsExplorer/Channel.ts | Reformats Channel wrapper class. |
| client/src/LanguageClient/RemoteLanguageClientProvider.ts | Reformats remote LSP client provider. |
| client/src/LanguageClient/LocalLanguageClientProvider.ts | Reformats local LSP client provider. |
| client/src/ItemsExplorer/SitemapPartialProvider.ts | Reformats sitemap snippet provider. |
| client/src/ItemsExplorer/RuleProvider.ts | Reformats rule snippet provider. |
| client/src/ItemsExplorer/ItemsModel.ts | Reformats REST-backed items model. |
| client/src/ItemsExplorer/ItemsExplorer.ts | Reformats items tree provider. |
| client/src/ItemsExplorer/ItemsCompletion.ts | Reformats completion provider. |
| client/src/ItemsExplorer/Item.ts | Reformats Item wrapper class. |
| client/src/ItemsExplorer/IItem.ts | Reformats TS interface declaration. |
| client/src/HoverProvider/HoverProvider.ts | Reformats hover provider logic and promise chains. |
| client/package.json | Reformats client package JSON. |
| client/jest.config.js | Reformats Jest config JS object formatting. |
| client/tests/tsconfig.json | Reformats test TS config JSON. |
| client/tests/Utils.test.ts | Reformats client unit tests. |
| client/tests/ThingsModel.test.ts | Reformats client unit tests. |
| client/tests/ThingsExplorer.test.ts | Reformats client unit tests. |
| client/tests/ItemsModel.test.ts | Reformats client unit tests. |
| client/tests/ItemsExplorer.test.ts | Reformats client unit tests. |
| client/tests/HoverProvider.test.ts | Reformats client unit tests. |
| client/tests/ConfigManager.test.ts | Reformats client unit tests. |
| client/mocks/vscode.ts | Reformats VS Code API mock. |
| client/mocks/tsconfig.json | Reformats mock TS config JSON. |
| client/mocks/ascii-table.ts | Reformats mock module formatting. |
| README.md | Reformats markdown and reference definitions. |
| CHANGELOG.md | Normalizes line endings and formatting. |
| .vscode/tasks.json | Reformats VS Code tasks JSON. |
| .vscode/settings.json | Adds Prettier default formatter + format-on-save and reformats settings JSON. |
| .vscode/launch.json | Reformats VS Code launch configurations. |
| .vscode/extensions.json | Updates/reorders recommended extensions and reformats JSON. |
| .volta.json | Reformats Volta config JSON. |
| .prettierrc | Adds Prettier configuration. |
| .prettierignore | Adds Prettier ignore rules for generated/build outputs and vendored files. |
| .markdownlint.json | Minor formatting normalization. |
| .husky/pre-commit | Adds pre-commit hook to run lint-staged. |
| .github/workflows/stale.yml | Reformats workflow YAML indentation. |
| .github/workflows/ci.yml | Reformats CI YAML and adds format + lint jobs. |
| .github/hooks/block-github-browser.json | Reformats JSON hook configuration. |
| .github/ISSUE_TEMPLATE/feature_request.md | Reformats markdown template spacing. |
| .github/ISSUE_TEMPLATE/bug_report.md | Reformats markdown template spacing/lists. |
| .eslintrc.cjs | Reformats ESLint config to match Prettier style. |
Comment on lines
+2
to
+6
| --container-paddding: 20px; | ||
| --input-padding-vertical: 6px; | ||
| --input-padding-horizontal: 4px; | ||
| --input-margin-vertical: 4px; | ||
| --input-margin-horizontal: 0; |
Contributor
Author
There was a problem hiding this comment.
@copilot apply changes based on this feedback
- Remove deprecated husky v8 shebang from .husky/pre-commit; file now contains only 'npx lint-staged' as required by husky v9/v10 - Simplify cross-fork PR section in copilot-instructions.md: keep only repo-specific branch/fork naming; reference global github-pr-cli instructions for the general owner:branch rule Signed-off-by: Patrik Gfeller <patrik.gfeller@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #334
Introduces Prettier as the automated code style formatter for this repository, along with pre-commit enforcement via Husky and lint-staged.
Changes
Tooling setup
.prettierrc— Prettier configuration:printWidth=120,tabWidth=4,singleQuote,semi=false,trailingComma: es5, LF line endings.prettierignore— Excludes build outputs,node_modules, coverage reports, and generated/vendored files (openhab.tmLanguage.json,openhab-icon-theme.json).husky/pre-commit— Pre-commit hook that runslint-stagedlint-stagedconfig inpackage.json— runsprettier --write+eslinton staged TS/JS files;prettier --writeon JSON/MD fileseslint-config-prettier— disables ESLint formatting rules that conflict with Prettierformat,format:check,lint:fixFormatter applied to existing files
All existing source files have been reformatted to bring the codebase into compliance with the new style rules.
Testing
The pre-commit hook was verified locally. All existing tests continue to pass (formatting-only changes, no logic affected).
Notes