@bottomlessmargaritas/formatting-configs 2.2.2 → 2.3.0

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 (2) hide show
  1. package/bin/cli.js +18 -4
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -118,12 +118,19 @@ function copyConfigFiles(projectRoot) {
118
118
  copied++;
119
119
  }
120
120
 
121
- // Remove stale namespaced config files from previous versions
121
+ // Remove stale namespaced config files from previous versions.
122
+ // Only remove files that match known config patterns (eslint/prettier) to avoid
123
+ // deleting user files that happen to contain the namespace in their name.
124
+ const KNOWN_CONFIG_PREFIXES = ["eslint.config.", "prettier.config."];
122
125
  const namespacedPattern = `.${NAMESPACE}.`;
123
126
  let removed = 0;
124
127
 
125
128
  for (const file of readdirSync(projectRoot)) {
126
- if (file.includes(namespacedPattern) && !currentNamespacedFiles.has(file)) {
129
+ if (
130
+ file.includes(namespacedPattern) &&
131
+ !currentNamespacedFiles.has(file) &&
132
+ KNOWN_CONFIG_PREFIXES.some((prefix) => file.startsWith(prefix))
133
+ ) {
127
134
  if (isDryRun) {
128
135
  console.log(`[dry-run] Would remove stale config: ${file}`);
129
136
  } else {
@@ -157,9 +164,16 @@ function updatePackageJsonScripts(projectRoot) {
157
164
  }
158
165
  }
159
166
 
160
- // Remove stale namespaced scripts from previous versions
167
+ // Remove stale namespaced scripts from previous versions.
168
+ // Only remove scripts matching known prefixes (format/lint) to avoid
169
+ // deleting user-defined scripts that happen to use the namespace prefix.
170
+ const KNOWN_SCRIPT_PREFIXES = [`${NAMESPACE}:format`, `${NAMESPACE}:lint`];
161
171
  for (const name of Object.keys(pkg.scripts)) {
162
- if (name.startsWith(`${NAMESPACE}:`) && !currentScriptNames.has(name)) {
172
+ if (
173
+ name.startsWith(`${NAMESPACE}:`) &&
174
+ !currentScriptNames.has(name) &&
175
+ KNOWN_SCRIPT_PREFIXES.some((prefix) => name.startsWith(prefix))
176
+ ) {
163
177
  delete pkg.scripts[name];
164
178
  removed++;
165
179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bottomlessmargaritas/formatting-configs",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "description": "Canonical Prettier and ESLint configs for @bottomlessmargaritas projects",
5
5
  "type": "module",
6
6
  "bin": {