pickier-vscode 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/.vscodeignore +14 -0
  2. package/README.md +102 -0
  3. package/build.ts +14 -0
  4. package/docs/USAGE.md +213 -0
  5. package/examples/01-hover-help-text.ts +58 -0
  6. package/examples/02-codelens-annotations.ts +50 -0
  7. package/examples/03-code-actions.ts +70 -0
  8. package/examples/04-problems-panel.ts +67 -0
  9. package/examples/05-import-issues.ts +35 -0
  10. package/examples/06-all-severities.ts +60 -0
  11. package/examples/07-auto-fixable-vs-manual.ts +69 -0
  12. package/examples/08-disable-comments.ts +73 -0
  13. package/examples/09-clean-file.ts +65 -0
  14. package/examples/10-comprehensive-test.ts +153 -0
  15. package/examples/README.md +336 -0
  16. package/examples/advanced-config.ts +116 -0
  17. package/examples/basic-config.ts +38 -0
  18. package/examples/team-config.ts +179 -0
  19. package/examples/vscode-settings.json +88 -0
  20. package/package.json +231 -0
  21. package/src/code-actions.ts +310 -0
  22. package/src/codelens.ts +156 -0
  23. package/src/commands.ts +120 -0
  24. package/src/config.ts +128 -0
  25. package/src/diagnostics.ts +256 -0
  26. package/src/extension.ts +473 -0
  27. package/src/formatter.ts +75 -0
  28. package/src/hover.ts +108 -0
  29. package/src/index.ts +8 -0
  30. package/src/status-bar.ts +125 -0
  31. package/test/code-actions.test.ts +298 -0
  32. package/test/commands.test.ts +131 -0
  33. package/test/config.test.ts +223 -0
  34. package/test/diagnostics.test.ts +102 -0
  35. package/test/extension.test.ts +111 -0
  36. package/test/fixtures/edge-case-boundary.ts +101 -0
  37. package/test/fixtures/edge-case-comments.ts +50 -0
  38. package/test/fixtures/edge-case-multiline-constructs.ts +108 -0
  39. package/test/fixtures/edge-case-nested-structures.ts +78 -0
  40. package/test/fixtures/edge-case-real-world.ts +103 -0
  41. package/test/fixtures/edge-case-strings-templates.ts +56 -0
  42. package/test/fixtures/edge-case-unicode-special.ts +64 -0
  43. package/test/fixtures/fixable.ts +4 -0
  44. package/test/fixtures/format-indent.ts +22 -0
  45. package/test/fixtures/format-quotes.ts +12 -0
  46. package/test/fixtures/format-semi.ts +43 -0
  47. package/test/fixtures/format-whitespace.ts +19 -0
  48. package/test/fixtures/lint-cond-assign.ts +34 -0
  49. package/test/fixtures/lint-debugger-console.ts +34 -0
  50. package/test/fixtures/lint-errors.ts +10 -0
  51. package/test/fixtures/no-errors.ts +4 -0
  52. package/test/fixtures/pickier-import-dedupe.ts +14 -0
  53. package/test/fixtures/pickier-import-paths.ts +20 -0
  54. package/test/fixtures/pickier-no-unused-vars.ts +44 -0
  55. package/test/fixtures/pickier-prefer-const.ts +29 -0
  56. package/test/fixtures/pickier-sort-exports.ts +28 -0
  57. package/test/fixtures/pickier-sort-heritage-clauses.ts +40 -0
  58. package/test/fixtures/pickier-sort-imports.ts +22 -0
  59. package/test/fixtures/pickier-sort-objects.ts +37 -0
  60. package/test/fixtures/pickier-top-level-function.ts +37 -0
  61. package/test/fixtures/regexp-rules.ts +32 -0
  62. package/test/fixtures/style-consistent-chaining.ts +37 -0
  63. package/test/fixtures/style-consistent-list-newline.ts +49 -0
  64. package/test/fixtures/style-curly.ts +36 -0
  65. package/test/fixtures/style-if-newline.ts +34 -0
  66. package/test/fixtures/style-statements-per-line.ts +22 -0
  67. package/test/fixtures/ts-no-require.ts +21 -0
  68. package/test/fixtures/ts-no-top-level-await.ts +28 -0
  69. package/test/fixtures/ts-no-ts-export-equal.ts +19 -0
  70. package/test/fixtures/unordered-imports.ts +6 -0
  71. package/test/fixtures.test.ts +750 -0
  72. package/test/formatter.test.ts +79 -0
  73. package/test/index.test.ts +45 -0
  74. package/test/status-bar.test.ts +57 -0
  75. package/test/utils/pickier-mock.ts +14 -0
  76. package/test/utils/vscode-mock.ts +279 -0
  77. package/tsconfig.json +18 -0
package/.vscodeignore ADDED
@@ -0,0 +1,14 @@
1
+ .vscode/**
2
+ .vscode-test/**
3
+ src/**
4
+ .gitignore
5
+ .yarnrc
6
+ *.vsix
7
+ **/*.ts
8
+ **/*.map
9
+ .eslintrc.json
10
+ tsconfig.json
11
+ node_modules/**
12
+ bun.lockb
13
+ build.ts
14
+ .DS_Store
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # Pickier VS Code Extension
2
+
3
+ Fast, modern formatter and linter for TypeScript, JavaScript, JSON, HTML, CSS, Markdown, and YAML.
4
+
5
+ ## Features
6
+
7
+ - **Lightning Fast**: Built on Bun runtime for incredible performance
8
+ - **Real-time Linting**: See errors and warnings as you type
9
+ - **Auto-fix**: Automatically fix many issues with one command
10
+ - **Multiple Languages**: TypeScript, JavaScript, JSON, HTML, CSS, Markdown, YAML
11
+ - **Markdown Linting**: Comprehensive MD001-MD059 rule coverage
12
+ - **Problems Integration**: All issues appear in VS Code's Problems panel
13
+ - **Smart Underlines**: Visual indicators for errors (red) and warnings (yellow)
14
+ - **Hover Tooltips**: Detailed error/warning information on hover
15
+ - **Status Bar**: See issue count at a glance
16
+
17
+ ## Usage
18
+
19
+ ### Automatic Linting
20
+
21
+ The extension automatically lints files when you:
22
+ - Open a file
23
+ - Save a file (configurable)
24
+ - Type (with 500ms debounce, configurable)
25
+
26
+ ### Commands
27
+
28
+ Access commands via Command Palette (Cmd/Ctrl+Shift+P):
29
+
30
+ - `Pickier: Format Document` - Format the current file
31
+ - `Pickier: Format Selection` - Format selected text
32
+ - `Pickier: Lint Document` - Lint the current file
33
+ - `Pickier: Lint Workspace` - Lint all files in workspace
34
+ - `Pickier: Fix All Auto-fixable Issues` - Apply all available fixes
35
+ - `Pickier: Organize Imports` - Sort and organize imports
36
+ - `Pickier: Show Output Channel` - Show detailed output
37
+ - `Pickier: Restart Extension` - Restart the extension
38
+
39
+ ### Configuration
40
+
41
+ Configure Pickier in VS Code settings:
42
+
43
+ ```json
44
+ {
45
+ "pickier.enable": true,
46
+ "pickier.lintOnSave": true,
47
+ "pickier.lintOnChange": true,
48
+ "pickier.formatOnSave": false,
49
+ "pickier.formatOnPaste": false,
50
+ "pickier.statusBar.showIssueCount": true
51
+ }
52
+ ```
53
+
54
+ ### Visual Indicators
55
+
56
+ - **Red Squiggles**: Errors that must be fixed
57
+ - **Yellow Squiggles**: Warnings and style suggestions
58
+ - **Faded Text**: Unused variables/imports
59
+ - **Strikethrough**: Deprecated code
60
+
61
+ ## Requirements
62
+
63
+ - VS Code 1.74.0 or higher
64
+ - Pickier installed in your project (`bun add -d pickier`)
65
+
66
+ ## Configuration File
67
+
68
+ Create a `pickier.config.ts` in your project root:
69
+
70
+ ```typescript
71
+ import type { PickierConfig } from 'pickier'
72
+
73
+ export default {
74
+ lint: {
75
+ extensions: ['ts', 'js', 'md'],
76
+ reporter: 'stylish'
77
+ },
78
+ format: {
79
+ indent: 2,
80
+ quotes: 'single',
81
+ semi: false
82
+ }
83
+ } satisfies PickierConfig
84
+ ```
85
+
86
+ ## Supported Languages
87
+
88
+ - TypeScript (.ts, .tsx)
89
+ - JavaScript (.js, .jsx)
90
+ - JSON (.json, .jsonc)
91
+ - HTML (.html)
92
+ - CSS (.css)
93
+ - Markdown (.md)
94
+ - YAML (.yaml, .yml)
95
+
96
+ ## Issues & Feedback
97
+
98
+ Report issues at: https://github.com/stacksjs/pickier/issues
99
+
100
+ ## License
101
+
102
+ MIT License - see LICENSE file for details
package/build.ts ADDED
@@ -0,0 +1,14 @@
1
+ console.log('Building...')
2
+
3
+ await Bun.build({
4
+ entrypoints: ['src/extension.ts'],
5
+ outdir: './dist',
6
+ splitting: false,
7
+ external: ['vscode'],
8
+ target: 'node',
9
+ format: 'esm',
10
+ })
11
+
12
+ console.log('Built successfully!')
13
+
14
+ export {}
package/docs/USAGE.md ADDED
@@ -0,0 +1,213 @@
1
+ # Pickier VS Code Extension Usage Guide
2
+
3
+ The Pickier VS Code extension provides fast formatting and linting capabilities for TypeScript, JavaScript, JSON, HTML, CSS, Markdown, and YAML files.
4
+
5
+ ## Installation
6
+
7
+ 1. Open VS Code
8
+ 2. Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
9
+ 3. Search for "Pickier"
10
+ 4. Click Install
11
+
12
+ ## Features
13
+
14
+ ### Formatting
15
+
16
+ - **Format Document**: Format the entire active document
17
+ - **Format Selection**: Format only the selected text
18
+ - **Format on Save**: Automatically format files when saved (configurable)
19
+
20
+ ### Linting
21
+
22
+ - **Lint Document**: Check the current document for issues
23
+ - **Lint Workspace**: Check all files in the workspace
24
+ - **Lint on Save**: Automatically lint files when saved (enabled by default)
25
+
26
+ ### Real-time Feedback
27
+
28
+ - **Status Bar Integration**: Shows Pickier status in the status bar
29
+ - **Diagnostic Integration**: Displays lint issues inline with squiggly underlines
30
+ - **Output Channel**: Detailed logging of operations and errors
31
+
32
+ ## Commands
33
+
34
+ Access these commands via the Command Palette (Ctrl+Shift+P / Cmd+Shift+P):
35
+
36
+ - `Pickier: Format Document` - Format the current document
37
+ - `Pickier: Format Selection` - Format the selected text
38
+ - `Pickier: Lint Document` - Lint the current document
39
+ - `Pickier: Lint Workspace` - Lint all files in the workspace
40
+
41
+ ## Configuration
42
+
43
+ Configure Pickier through VS Code settings. Go to File > Preferences > Settings and search for "Pickier":
44
+
45
+ ### Available Settings
46
+
47
+ | Setting | Type | Default | Description |
48
+ |---------|------|---------|-------------|
49
+ | `pickier.enable` | boolean | `true` | Enable/disable the Pickier extension |
50
+ | `pickier.configPath` | string | `""` | Path to Pickier config file (relative to workspace root) |
51
+ | `pickier.formatOnSave` | boolean | `false` | Format files automatically on save |
52
+ | `pickier.lintOnSave` | boolean | `true` | Lint files automatically on save |
53
+ | `pickier.showOutputChannel` | boolean | `false` | Show Pickier output channel for debugging |
54
+
55
+ ### Example Settings (settings.json)
56
+
57
+ ```json
58
+ {
59
+ "pickier.enable": true,
60
+ "pickier.formatOnSave": true,
61
+ "pickier.lintOnSave": true,
62
+ "pickier.configPath": "pickier.config.ts",
63
+ "pickier.showOutputChannel": false
64
+ }
65
+ ```
66
+
67
+ ## Pickier Configuration File
68
+
69
+ Create a `pickier.config.ts` file in your workspace root to customize Pickier behavior:
70
+
71
+ ```typescript
72
+ import type { PickierConfig } from 'pickier'
73
+
74
+ const config: PickierConfig = {
75
+ verbose: false,
76
+ ignores: ['**/node_modules/**', '**/dist/**', '**/build/**'],
77
+ lint: {
78
+ extensions: ['ts', 'js', 'html', 'css', 'json', 'jsonc', 'md', 'yaml', 'yml'],
79
+ reporter: 'stylish',
80
+ cache: false,
81
+ maxWarnings: -1,
82
+ },
83
+ format: {
84
+ extensions: ['ts', 'js', 'html', 'css', 'json', 'jsonc', 'md', 'yaml', 'yml'],
85
+ trimTrailingWhitespace: true,
86
+ maxConsecutiveBlankLines: 1,
87
+ finalNewline: 'one',
88
+ indent: 2,
89
+ indentStyle: 'spaces',
90
+ quotes: 'single',
91
+ semi: false,
92
+ },
93
+ rules: {
94
+ noDebugger: 'error',
95
+ noConsole: 'warn',
96
+ noUnusedCapturingGroup: 'error',
97
+ noCondAssign: 'error',
98
+ noTemplateCurlyInString: 'warn',
99
+ },
100
+ }
101
+
102
+ export default config
103
+ ```
104
+
105
+ ## Supported File Types
106
+
107
+ Pickier supports the following file extensions:
108
+
109
+ - **TypeScript**: `.ts`, `.tsx`
110
+ - **JavaScript**: `.js`, `.jsx`
111
+ - **JSON**: `.json`
112
+ - **JSON with Comments**: `.jsonc`
113
+ - **HTML**: `.html`
114
+ - **CSS**: `.css`
115
+ - **Markdown**: `.md`
116
+ - **YAML**: `.yaml`, `.yml`
117
+
118
+ ## Integration with Other Extensions
119
+
120
+ ### Disable Conflicting Formatters
121
+
122
+ To avoid conflicts with other formatting extensions, you may want to disable them for file types that Pickier handles:
123
+
124
+ ```json
125
+ {
126
+ "[typescript]": {
127
+ "editor.defaultFormatter": "pickier.vscode"
128
+ },
129
+ "[javascript]": {
130
+ "editor.defaultFormatter": "pickier.vscode"
131
+ },
132
+ "[json]": {
133
+ "editor.defaultFormatter": "pickier.vscode"
134
+ }
135
+ }
136
+ ```
137
+
138
+ ### Working with ESLint/Prettier
139
+
140
+ Pickier can work alongside ESLint and Prettier, but you may want to configure them to avoid overlapping rules:
141
+
142
+ 1. Disable formatting rules in ESLint
143
+ 2. Use Pickier for formatting and ESLint for logical linting
144
+ 3. Configure Prettier to exclude files that Pickier handles
145
+
146
+ ## Keyboard Shortcuts
147
+
148
+ You can assign custom keyboard shortcuts to Pickier commands:
149
+
150
+ 1. Go to File > Preferences > Keyboard Shortcuts
151
+ 2. Search for "Pickier"
152
+ 3. Assign shortcuts to the commands you use most
153
+
154
+ Example keybindings.json:
155
+
156
+ ```json
157
+ [
158
+ {
159
+ "key": "ctrl+shift+f",
160
+ "command": "pickier.format",
161
+ "when": "editorTextFocus"
162
+ },
163
+ {
164
+ "key": "ctrl+shift+l",
165
+ "command": "pickier.lint",
166
+ "when": "editorTextFocus"
167
+ }
168
+ ]
169
+ ```
170
+
171
+ ## Troubleshooting
172
+
173
+ ### Common Issues
174
+
175
+ 1. **Extension not activating**: Ensure you're working with supported file types
176
+ 2. **Formatting not working**: Check that Pickier is enabled in settings
177
+ 3. **Linting issues not showing**: Verify `pickier.lintOnSave` is enabled
178
+ 4. **Performance issues**: Try enabling `pickier.showOutputChannel` to debug
179
+
180
+ ### Debug Mode
181
+
182
+ Enable the output channel to see detailed logs:
183
+
184
+ 1. Set `pickier.showOutputChannel` to `true`
185
+ 2. Open View > Output
186
+ 3. Select "Pickier" from the dropdown
187
+ 4. Perform actions to see debug information
188
+
189
+ ### Configuration Issues
190
+
191
+ If your configuration file isn't being loaded:
192
+
193
+ 1. Ensure it's in the workspace root
194
+ 2. Check the file name matches `pickier.configPath` setting
195
+ 3. Verify the configuration syntax is correct
196
+ 4. Check the output channel for error messages
197
+
198
+ ## Performance
199
+
200
+ Pickier is designed to be fast:
201
+
202
+ - **Native Speed**: Built with Bun for maximum performance
203
+ - **Minimal Dependencies**: Lightweight architecture
204
+ - **Incremental Processing**: Only processes changed files
205
+ - **Efficient Caching**: Reuses results when possible
206
+
207
+ ## Contributing
208
+
209
+ Found a bug or have a feature request? Please check our [GitHub repository](https://github.com/stacksjs/pickier) and open an issue or pull request.
210
+
211
+ ## License
212
+
213
+ MIT License - see the [LICENSE](../LICENSE.md) file for details.
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Example 1: Rich Hover with Help Text
3
+ *
4
+ * HOW TO TEST:
5
+ * 1. Hover over any squiggly underline
6
+ * 2. See the rich tooltip with:
7
+ * - Rule ID with severity icon
8
+ * - Error message
9
+ * - Help text with fix suggestions
10
+ * - "Auto-fix available" indicator
11
+ * - Links to docs and disable options
12
+ */
13
+
14
+ // Hover over 'debugger' - see help text about removing it
15
+ function example1() {
16
+ debugger
17
+ return 'test'
18
+ }
19
+
20
+ // Hover over 'unused' - see help about prefixing with underscore
21
+ function example2() {
22
+ const unused = 'This variable is never used'
23
+ return 42
24
+ }
25
+
26
+ // Hover over the string - see help about template literals
27
+ function example3() {
28
+ const name = 'World'
29
+ const message = 'Hello ' + name
30
+ return message
31
+ }
32
+
33
+ // Hover over 'let' - see help about using const instead
34
+ function example4() {
35
+ let neverReassigned = 100
36
+ return neverReassigned * 2
37
+ }
38
+
39
+ // Hover over console - see help about removing console statements
40
+ function example5() {
41
+ console.log("This shouldn't be in production")
42
+ return true
43
+ }
44
+
45
+ // Hover over the string with ${} - see help about using backticks
46
+ function example6() {
47
+ const value = 42
48
+ const msg = "The value is ${value}"
49
+ return msg
50
+ }
51
+
52
+ /**
53
+ * ✅ EXPECTED RESULTS:
54
+ * - Each hover shows detailed help text
55
+ * - Help text explains how to fix the issue
56
+ * - Auto-fixable issues show ✨ icon
57
+ * - Links to documentation are present
58
+ */
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Example 2: CodeLens Annotations
3
+ *
4
+ * HOW TO TEST:
5
+ * 1. Look at the TOP of this file (line 1)
6
+ * 2. You should see CodeLens showing:
7
+ * - "⚠️ Pickier: X errors, Y warnings (Z auto-fixable)"
8
+ * - "🔧 Fix all Z auto-fixable issues" button
9
+ * 3. Click the "Fix all" button
10
+ * 4. Watch all auto-fixable issues get fixed
11
+ * 5. CodeLens should change to "✓ Pickier: No issues found"
12
+ */
13
+
14
+ // This file has MULTIPLE issues to trigger CodeLens
15
+
16
+ // Issue 1: debugger (auto-fixable)
17
+ function test1() {
18
+ debugger
19
+ }
20
+
21
+ // Issue 2: unused variable (not auto-fixable, but shows in count)
22
+ function test2() {
23
+ const unused = 'not used'
24
+ return 42
25
+ }
26
+
27
+ // Issue 3: prefer-const (auto-fixable)
28
+ function test3() {
29
+ let x = 10
30
+ return x
31
+ }
32
+
33
+ // Issue 4: console.log (shows warning in CodeLens)
34
+ function test4() {
35
+ console.log('debug message')
36
+ }
37
+
38
+ // Issue 5: string concatenation (auto-fixable with prefer-template)
39
+ function test5() {
40
+ const msg = 'Hello' + ' ' + 'World'
41
+ return msg
42
+ }
43
+
44
+ /**
45
+ * ✅ EXPECTED RESULTS:
46
+ * - CodeLens at top shows: "⚠️ Pickier: 2 errors, 2 warnings (3 auto-fixable)"
47
+ * - Clicking "Fix all" fixes debugger, prefer-const, and prefer-template
48
+ * - After fix, CodeLens shows remaining issues (unused var + console)
49
+ * - Final state: "⚠️ Pickier: 2 warnings"
50
+ */
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Example 3: Enhanced Code Actions
3
+ *
4
+ * HOW TO TEST:
5
+ * 1. Put your cursor on any squiggly underline
6
+ * 2. Press Cmd+. (or Ctrl+. on Windows/Linux)
7
+ * 3. See 4 different code action options:
8
+ * - Fix: [issue description]
9
+ * - Disable [rule] for this line
10
+ * - Disable [rule] for entire file
11
+ * - 📖 View documentation for [rule]
12
+ * 4. Try each action type
13
+ */
14
+
15
+ // Test 1: Try code actions on 'debugger'
16
+ // Expected actions:
17
+ // - Fix: Remove debugger statement
18
+ // - Disable no-debugger for this line
19
+ // - Disable no-debugger for entire file
20
+ // - View documentation
21
+ function test1() {
22
+ debugger
23
+ }
24
+
25
+ // Test 2: Try code actions on 'let'
26
+ // Expected actions:
27
+ // - Fix: Use 'const' instead
28
+ // - Disable prefer-const for this line
29
+ // - Disable prefer-const for entire file
30
+ // - View documentation
31
+ function test2() {
32
+ let neverChanged = 42
33
+ return neverChanged
34
+ }
35
+
36
+ // Test 3: Try code actions on unused variable
37
+ // Expected actions:
38
+ // - (No auto-fix available for this one)
39
+ // - Disable pickier/no-unused-vars for this line
40
+ // - Disable pickier/no-unused-vars for entire file
41
+ // - View documentation
42
+ function test3() {
43
+ const unused = 'value'
44
+ return 100
45
+ }
46
+
47
+ // Test 4: Try "Disable for this line" action
48
+ // After selecting, it should add:
49
+ // // eslint-disable-next-line no-console
50
+ // console.log('test')
51
+ function test4() {
52
+ console.log('This will trigger console warning')
53
+ }
54
+
55
+ // Test 5: String concatenation - try the fix action
56
+ // Should convert to template literal
57
+ function test5() {
58
+ const name = 'Alice'
59
+ const greeting = 'Hello, ' + name + '!'
60
+ return greeting
61
+ }
62
+
63
+ /**
64
+ * ✅ EXPECTED RESULTS:
65
+ * - Each diagnostic shows 3-4 code actions
66
+ * - "Disable for this line" adds comment above the line
67
+ * - "Disable for entire file" adds comment at top
68
+ * - "View documentation" opens browser with rule docs
69
+ * - "Fix" applies the auto-fix
70
+ */
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Example 4: Problems Panel with Help Text
3
+ *
4
+ * HOW TO TEST:
5
+ * 1. Open the Problems panel (View → Problems or Cmd+Shift+M)
6
+ * 2. Look for Pickier issues in this file
7
+ * 3. Click on any issue
8
+ * 4. See the help text in the details section below
9
+ * 5. Help text shows actionable advice on how to fix
10
+ */
11
+
12
+ // Problem 1: debugger statement
13
+ // In Problems panel, click this issue
14
+ // Help text: "Remove debugger statements before committing code..."
15
+ function problem1() {
16
+ debugger
17
+ return 1
18
+ }
19
+
20
+ // Problem 2: unused variable
21
+ // Help text: "Either use this variable in your code, remove it, or prefix it with an underscore (_unused)..."
22
+ function problem2() {
23
+ const unused = 'not used'
24
+ const alsoUnused = 42
25
+ return 0
26
+ }
27
+
28
+ // Problem 3: prefer-const
29
+ // Help text: "Change 'let neverChanged' to 'const neverChanged' since the variable is never reassigned..."
30
+ function problem3() {
31
+ let neverChanged = 100
32
+ return neverChanged
33
+ }
34
+
35
+ // Problem 4: console.log
36
+ // Help text: "Remove console statements before committing. Use a proper logging library..."
37
+ function problem4() {
38
+ console.log('debug')
39
+ console.warn('warning')
40
+ console.error('error')
41
+ }
42
+
43
+ // Problem 5: template literal
44
+ // Help text: "Use template literals (backticks) instead of string concatenation..."
45
+ function problem5() {
46
+ const x = 10
47
+ const y = 20
48
+ const msg = 'x is ' + x + ' and y is ' + y
49
+ return msg
50
+ }
51
+
52
+ // Problem 6: template curly in string
53
+ // Help text: "Change the string quotes from ' or \" to backticks (`) to use template literal interpolation..."
54
+ function problem6() {
55
+ const name = 'Bob'
56
+ const message = 'Hello ${name}'
57
+ return message
58
+ }
59
+
60
+ /**
61
+ * ✅ EXPECTED RESULTS:
62
+ * - Problems panel shows all issues
63
+ * - Clicking each issue shows help text below
64
+ * - Help text is detailed and actionable
65
+ * - Can click "Show Fixes" from Problems panel
66
+ * - Issues are grouped by severity (errors vs warnings)
67
+ */
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Example 5: Import-related Issues
3
+ *
4
+ * HOW TO TEST:
5
+ * 1. See CodeLens showing import issues
6
+ * 2. CodeLens should show "📦 Organize Imports" button
7
+ * 3. Click it to organize imports
8
+ * 4. Hover over import issues to see help text
9
+ */
10
+
11
+ // Unordered imports (should be alphabetically sorted)
12
+ import { zebra } from './zoo'
13
+ import { apple } from './fruits'
14
+ import { car } from './vehicles'
15
+
16
+ // Duplicate imports (import-dedupe rule)
17
+ import { thing } from './module'
18
+ import { otherThing } from './module' // Should be merged with above
19
+
20
+ // These imports trigger the "Organize Imports" CodeLens button
21
+
22
+ export function useImports() {
23
+ return { zebra, apple, car, thing, otherThing }
24
+ }
25
+
26
+ /**
27
+ * ✅ EXPECTED RESULTS:
28
+ * - CodeLens shows "📦 Organize Imports" button
29
+ * - Clicking it sorts and dedupes imports
30
+ * - After organizing:
31
+ * import { apple } from './fruits'
32
+ * import { thing, otherThing } from './module'
33
+ * import { car } from './vehicles'
34
+ * import { zebra } from './zoo'
35
+ */
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Example 6: Different Severity Levels
3
+ *
4
+ * HOW TO TEST:
5
+ * 1. See how errors (red) and warnings (yellow) are displayed
6
+ * 2. CodeLens shows both: "X errors, Y warnings"
7
+ * 3. Problems panel groups by severity
8
+ * 4. Hover shows different icons for each severity
9
+ */
10
+
11
+ // ============================================
12
+ // ERRORS (Red squiggly underlines)
13
+ // ============================================
14
+
15
+ // Error 1: debugger statement
16
+ function errorExample1() {
17
+ debugger // ❌ ERROR
18
+ }
19
+
20
+ // Error 2: unused variable (configured as error)
21
+ function errorExample2() {
22
+ const unused = 'value' // ❌ ERROR
23
+ return 42
24
+ }
25
+
26
+ // Error 3: prefer-const (configured as error)
27
+ function errorExample3() {
28
+ let neverChanges = 100 // ❌ ERROR
29
+ return neverChanges
30
+ }
31
+
32
+ // ============================================
33
+ // WARNINGS (Yellow squiggly underlines)
34
+ // ============================================
35
+
36
+ // Warning 1: console.log
37
+ function warningExample1() {
38
+ console.log('debug message') // ⚠️ WARNING
39
+ }
40
+
41
+ // Warning 2: quote style
42
+ function warningExample2() {
43
+ const msg = "should use single quotes" // ⚠️ WARNING
44
+ return msg
45
+ }
46
+
47
+ // Warning 3: prefer-template
48
+ function warningExample3() {
49
+ const greeting = 'Hello' + ' ' + 'World' // ⚠️ WARNING
50
+ return greeting
51
+ }
52
+
53
+ /**
54
+ * ✅ EXPECTED RESULTS:
55
+ * - CodeLens shows: "⚠️ Pickier: 3 errors, 3 warnings (X auto-fixable)"
56
+ * - Errors have red underlines
57
+ * - Warnings have yellow underlines
58
+ * - Hover shows different icons: $(error) vs $(warning)
59
+ * - Problems panel separates errors from warnings
60
+ */