Skip to content

Commit 85659b5

Browse files
authored
Merge pull request #1 from EfeDeveloper/develop
✨[core]Refactor case conversion commands and enhance testing suite
2 parents 1e4b29a + 4f3ea46 commit 85659b5

13 files changed

Lines changed: 1015 additions & 175 deletions

File tree

.eslintrc.json

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
{
2-
"root": true,
3-
"parser": "@typescript-eslint/parser",
4-
"parserOptions": {
5-
"ecmaVersion": 6,
6-
"sourceType": "module"
7-
},
8-
"plugins": [
9-
"@typescript-eslint"
2+
"root": true,
3+
"parser": "@typescript-eslint/parser",
4+
"parserOptions": {
5+
"ecmaVersion": 2022,
6+
"sourceType": "module"
7+
},
8+
"plugins": ["@typescript-eslint"],
9+
"rules": {
10+
"@typescript-eslint/naming-convention": [
11+
"warn",
12+
{
13+
"selector": "import",
14+
"format": ["camelCase", "PascalCase"]
15+
}
1016
],
11-
"rules": {
12-
"@typescript-eslint/naming-convention": [
13-
"warn",
14-
{
15-
"selector": "import",
16-
"format": [ "camelCase", "PascalCase" ]
17-
}
18-
],
19-
"@typescript-eslint/semi": "warn",
20-
"curly": "warn",
21-
"eqeqeq": "warn",
22-
"no-throw-literal": "warn",
23-
"semi": "off"
24-
},
25-
"ignorePatterns": [
26-
"out",
27-
"dist",
28-
"**/*.d.ts"
29-
]
30-
}
17+
"@typescript-eslint/no-unused-vars": "error",
18+
"@typescript-eslint/semi": "warn",
19+
"curly": "error",
20+
"eqeqeq": "error",
21+
"no-throw-literal": "warn",
22+
"no-console": "warn",
23+
"prefer-const": "error",
24+
"semi": "off"
25+
},
26+
"ignorePatterns": ["out", "dist", "**/*.d.ts"]
27+
}

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
lint-and-build:
11+
name: Lint & Build
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
cache: npm
19+
- run: npm ci
20+
- run: npm run lint
21+
- run: npm run compile
22+
23+
test:
24+
name: Test
25+
runs-on: ubuntu-latest
26+
needs: lint-and-build
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: actions/setup-node@v4
30+
with:
31+
node-version: 20
32+
cache: npm
33+
- run: npm ci
34+
- run: npm run compile
35+
- name: Run tests (with virtual display)
36+
run: xvfb-run -a npm test

.vscode/launch.json

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,26 @@
33
// Hover to view descriptions of existing attributes.
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
{
6-
"version": "0.2.0",
7-
"configurations": [
8-
9-
{
10-
"name": "Run Extension",
11-
"type": "extensionHost",
12-
"request": "launch",
13-
"args": [
14-
"--extensionDevelopmentPath=${workspaceFolder}"
15-
],
16-
"outFiles": [
17-
"${workspaceFolder}/out/**/*.js"
18-
],
19-
"preLaunchTask": "${defaultBuildTask}"
20-
}
21-
]
6+
"version": "0.2.0",
7+
"configurations": [
8+
{
9+
"name": "Run Extension",
10+
"type": "extensionHost",
11+
"request": "launch",
12+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
13+
"outFiles": ["${workspaceFolder}/out/**/*.js"],
14+
"preLaunchTask": "${defaultBuildTask}"
15+
},
16+
{
17+
"name": "Extension Tests",
18+
"type": "extensionHost",
19+
"request": "launch",
20+
"args": [
21+
"--extensionDevelopmentPath=${workspaceFolder}",
22+
"--extensionTestsPath=${workspaceFolder}/out/test/extension.test"
23+
],
24+
"outFiles": ["${workspaceFolder}/out/**/*.js"],
25+
"preLaunchTask": "${defaultBuildTask}"
26+
}
27+
]
2228
}

CHANGELOG.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,36 @@
22

33
All notable changes to the "format-switcher" extension will be documented in this file.
44

5-
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
5+
Format follows [Keep a Changelog](https://keepachangelog.com/).
66

77
## [Unreleased]
88

9-
- Initial release
9+
## [0.3.0] - 2026-03-08
10+
11+
### Added
12+
13+
- **Two new formats**: `lower words` (space-separated lowercase) and `UPPER WORDS` (space-separated uppercase).
14+
- **Cycle command** (`extension.formatSwitcher.cycleCase`) — automatically detects the current format and advances to the next in the cycle: `camelCase → snake_case → kebab-case → CONSTANT_CASE → Train-Case → lower words → UPPER WORDS → camelCase`.
15+
- **Keyboard shortcut** `Ctrl+Shift+F` mapped to the cycle command (only active when editor has a selection, avoiding conflicts with "Find in Files").
16+
- **Multi-cursor support** — all active selections are converted simultaneously.
17+
- `LICENSE` file (MIT).
18+
- GitHub Actions CI pipeline (lint → build → test).
19+
20+
### Changed
21+
22+
- Replaced `lodash` runtime dependency (~4.7 MB) with native TypeScript implementations, reducing the packaged extension size by over 95%.
23+
- Case conversion logic extracted to a standalone `caseConverters` module for testability.
24+
- Comprehensive unit test suite (40+ assertions) replacing the placeholder boilerplate.
25+
26+
### Fixed
27+
28+
- Context menu submenu now only appears when text is actually selected (`when: editorHasSelection`).
29+
- Internal `CaseType` literal `'Constant case'` corrected to `'upperSnakeCase'` for consistency.
30+
31+
## [0.2.0] - 2024-01-01
32+
33+
### Added
34+
35+
- Initial release with five case conversions: `camelCase`, `snake_case`, `CONSTANT_CASE`, `kebab-case`, `Train-Case`.
36+
- Right-click context menu submenu "Change case".
37+
- `lodash` used internally for text segmentation.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 EfeDeveloper
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,83 @@
22
<img src="./images/icon.png" alt="logo" width="100" />
33

44
<h1>Format Switcher</h1>
5-
</div>
65

7-
## **Table of contents**
6+
[![Visual Studio Marketplace Version](https://img.shields.io/visual-studio-marketplace/v/EdFerVIIIA.format-switcher)](https://marketplace.visualstudio.com/items?itemName=EdFerVIIIA.format-switcher)
7+
[![CI](https://github.com/EfeDeveloper/format-switcher/actions/workflows/ci.yml/badge.svg)](https://github.com/EfeDeveloper/format-switcher/actions/workflows/ci.yml)
88

9-
1. [Features](#features)
9+
</div>
1010

11-
2. [Usage](#usage)
11+
## Table of contents
1212

13-
3. [Requirements](#requirements)
13+
1. [Features](#features)
14+
2. [Installation](#installation)
15+
3. [Usage](#usage)
16+
4. [Keyboard Shortcut](#keyboard-shortcut)
17+
5. [Contributing](#contributing)
18+
6. [License](#license)
1419

1520
## Features
1621

17-
`Format Switcher` is a simple extension that allows you to change the formatting of selected text in the editor. The extension adds a new menu item to the context menu.
22+
`Format Switcher` is a VS Code extension that transforms selected text between seven naming-convention formats via the right-click context menu or a keyboard shortcut.
1823

19-
The extension supports the following cases:
24+
Supported formats:
2025

21-
```plaintext
22-
CamelCase
26+
```
27+
camelCase
2328
snake_case
2429
CONSTANT_CASE
2530
kebab-case
2631
Train-Case
32+
lower words
33+
UPPER WORDS
34+
```
35+
36+
- **Multi-cursor support** — all active selections are converted simultaneously.
37+
- **Context menu** only appears when text is selected (no more silent no-ops).
38+
39+
## Installation
40+
41+
**From the Marketplace:**
42+
43+
1. Open VS Code
44+
2. Press `Ctrl+P` and run: `ext install EdFerVIIIA.format-switcher`
45+
3. Or search **"Format Switcher"** in the Extensions view (`Ctrl+Shift+X`)
46+
47+
**From a VSIX file:**
48+
49+
```
50+
code --install-extension format-switcher-<version>.vsix
2751
```
2852

2953
## Usage
3054

31-
![Format Switcher](./images/ExtExample.gif)
55+
Select any text, right-click, and choose **Change case** → pick the desired format.
3256

33-
## Requirements
57+
## Keyboard Shortcut
3458

35-
This extension uses the following libraries
59+
Press **`Ctrl+Shift+F`** with text selected to **cycle** through formats in order:
3660

37-
```json
38-
"lodash": "^4.17.21"
3961
```
62+
camelCase → snake_case → kebab-case → CONSTANT_CASE → Train-Case → lower words → UPPER WORDS → camelCase → …
63+
```
64+
65+
The shortcut only activates when the cursor is inside the editor with a selection, so it does not conflict with the default "Find in Files" shortcut. You can customise the keybinding any time via **File → Preferences → Keyboard Shortcuts**.
66+
67+
## Contributing
68+
69+
Bug reports and feature requests are welcome — please [open an issue](https://github.com/EfeDeveloper/format-switcher/issues).
70+
71+
Pull requests are also welcome. To get started:
72+
73+
```bash
74+
git clone https://github.com/EfeDeveloper/format-switcher.git
75+
cd format-switcher
76+
npm install
77+
npm test
78+
```
79+
80+
Press **F5** in VS Code to launch the Extension Development Host, or use the **"Extension Tests"** launch config to debug tests.
81+
82+
## License
4083

41-
**Enjoy!**
84+
[MIT](LICENSE) © EfeDeveloper

images/ExtExample.gif

-3.62 MB
Binary file not shown.

0 commit comments

Comments
 (0)