Repository: stylelint/vscode-stylelint (ts)

Issue:
[Bug]: Updates to Stylelint config files do not relint file
1. Make changes to the Stylelint config file (e.g. disable a failing rule).
2. Notice that relinting does not occur on the file.

Restarting VS Code relints the file. I believe the problem lies with the watch list being outdated:
https://github.com/stylelint/vscode-stylelint/blob/6d748cd31b106d138910e4908987f19892e5957a/src/extension/extension.ts#L43-L44

The recommended config file names are as follows:

* `stylelint.config.js`
* `stylelint.config.mjs`
* `stylelint.config.cjs`

Alternative filenames include the following:

![Image](https://github.com/user-attachments/assets/e0e11654-7689-4c1d-8da4-ba15c92b4c19)

Pull request:
fix: add file watchers for .mjs and .cjs configs
<!-- Each pull request must be associated with an open issue unless it's a documentation fix. If a corresponding issue does not exist, please create one so we can discuss the change first. -->

<!-- Please answer the following. We close pull requests that don't. -->

> Which issue, if any, is this issue related to?

Closes #647 

> Is there anything in the PR that needs further explanation?

I split `stylelint.config.{js,cjs,mjs}` and `.stylelintignore` into separate watchers for readability and to avoid nested brackets.


Patch:
diff --git a/src/extension/extension.ts b/src/extension/extension.ts
index 6729c27..e6f10eb 100644
--- a/src/extension/extension.ts
+++ b/src/extension/extension.ts
@@ -40,8 +40,9 @@ export async function activate({ subscriptions }: ExtensionContext): Promise<Pub
 			diagnosticCollectionName: 'Stylelint',
 			synchronize: {
 				fileEvents: [
-					workspace.createFileSystemWatcher('**/.stylelintrc{,.js,.json,.yaml,.yml}'),
-					workspace.createFileSystemWatcher('**/{stylelint.config.js,.stylelintignore}'),
+					workspace.createFileSystemWatcher('**/.stylelintrc{,.js,.cjs,.mjs,.json,.yaml,.yml}'),
+					workspace.createFileSystemWatcher('**/stylelint.config.{js,cjs,mjs}'),
+					workspace.createFileSystemWatcher('**/.stylelintignore'),
 				],
 			},
 		},


Test patch:
diff --git a/src/extension/__tests__/__snapshots__/extension.ts.snap b/src/extension/__tests__/__snapshots__/extension.ts.snap
index d8a2299..b027a77 100644
--- a/src/extension/__tests__/__snapshots__/extension.ts.snap
+++ b/src/extension/__tests__/__snapshots__/extension.ts.snap
@@ -31,6 +31,7 @@ exports[`Extension entry point should create a language client 1`] = `
       "fileEvents": [
         undefined,
         undefined,
+        undefined,
       ],
     },
   },
diff --git a/src/extension/__tests__/extension.ts b/src/extension/__tests__/extension.ts
index 9555020..5c69315 100644
--- a/src/extension/__tests__/extension.ts
+++ b/src/extension/__tests__/extension.ts
@@ -116,13 +116,14 @@ describe('Extension entry point', () => {
 	it('should watch for changes to Stylelint configuration files', async () => {
 		await activate(mockExtensionContext);
 
-		expect(mockWorkspace.createFileSystemWatcher).toHaveBeenCalledTimes(2);
+		expect(mockWorkspace.createFileSystemWatcher).toHaveBeenCalledTimes(3);
 		expect(mockWorkspace.createFileSystemWatcher.mock.calls[0]).toEqual([
-			'**/.stylelintrc{,.js,.json,.yaml,.yml}',
+			'**/.stylelintrc{,.js,.cjs,.mjs,.json,.yaml,.yml}',
 		]);
 		expect(mockWorkspace.createFileSystemWatcher.mock.calls[1]).toEqual([
-			'**/{stylelint.config.js,.stylelintignore}',
+			'**/stylelint.config.{js,cjs,mjs}',
 		]);
+		expect(mockWorkspace.createFileSystemWatcher.mock.calls[2]).toEqual(['**/.stylelintignore']);
 	});
 
 	it('should register an auto-fix command', async () => {