shakapacker 9.3.0 → 9.3.1
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.
- checksums.yaml +4 -4
- data/.claude/commands/update-changelog.md +224 -0
- data/.github/actionlint-matcher.json +17 -0
- data/.github/workflows/dummy.yml +9 -0
- data/.github/workflows/generator.yml +13 -0
- data/.github/workflows/node.yml +83 -0
- data/.github/workflows/ruby.yml +11 -0
- data/.github/workflows/test-bundlers.yml +10 -0
- data/CHANGELOG.md +15 -8
- data/CLAUDE.md +6 -10
- data/CONTRIBUTING.md +57 -0
- data/Gemfile.lock +1 -1
- data/README.md +58 -33
- data/docs/api-reference.md +519 -0
- data/docs/configuration.md +11 -5
- data/docs/css-modules-export-mode.md +40 -6
- data/docs/transpiler-migration.md +12 -9
- data/docs/using_swc_loader.md +13 -10
- data/docs/v9_upgrade.md +11 -2
- data/eslint.config.fast.js +120 -8
- data/eslint.config.js +50 -31
- data/lib/install/config/shakapacker.yml +14 -1
- data/lib/shakapacker/configuration.rb +47 -4
- data/lib/shakapacker/dev_server_runner.rb +4 -0
- data/lib/shakapacker/doctor.rb +1 -1
- data/lib/shakapacker/version.rb +1 -1
- data/package/config.ts +2 -3
- data/package/configExporter/cli.ts +29 -24
- data/package/dev_server.ts +2 -2
- data/package/env.ts +1 -1
- data/package/environments/__type-tests__/rspack-plugin-compatibility.ts +6 -6
- data/package/environments/base.ts +2 -2
- data/package/environments/development.ts +3 -6
- data/package/environments/production.ts +2 -2
- data/package/environments/test.ts +2 -1
- data/package/esbuild/index.ts +0 -2
- data/package/index.d.ts +1 -0
- data/package/index.d.ts.template +1 -0
- data/package/index.ts +0 -1
- data/package/plugins/rspack.ts +3 -1
- data/package/plugins/webpack.ts +5 -3
- data/package/rspack/index.ts +3 -3
- data/package/rules/file.ts +1 -1
- data/package/rules/raw.ts +3 -1
- data/package/rules/rspack.ts +0 -2
- data/package/rules/sass.ts +0 -2
- data/package/rules/webpack.ts +0 -1
- data/package/swc/index.ts +0 -2
- data/package/types.ts +8 -11
- data/package/utils/debug.ts +0 -4
- data/package/utils/getStyleRule.ts +17 -9
- data/package/utils/helpers.ts +8 -3
- data/package/utils/pathValidation.ts +10 -11
- data/package/utils/requireOrError.ts +4 -3
- data/package/webpackDevServerConfig.ts +4 -4
- data/package.json +1 -1
- data/test/package/transpiler-defaults.test.js +42 -0
- metadata +5 -2
data/docs/configuration.md
CHANGED
|
@@ -25,7 +25,7 @@ Common configuration options with their defaults:
|
|
|
25
25
|
| ------------------------------ | ------- | --------------------------------------- | ---------------------------------------------------------- |
|
|
26
26
|
| `assets_bundler` | string | `"webpack"` | Bundler to use: `"webpack"` or `"rspack"` |
|
|
27
27
|
| `assets_bundler_config_path` | string | `"config/webpack"` or `"config/rspack"` | Directory containing bundler config files |
|
|
28
|
-
| `javascript_transpiler` | string | `"swc"
|
|
28
|
+
| `javascript_transpiler` | string | `"swc"`\* | Transpiler: `"swc"`, `"babel"`, or `"esbuild"` |
|
|
29
29
|
| `source_path` | string | `"app/javascript"` | Root directory for JavaScript source files |
|
|
30
30
|
| `source_entry_path` | string | `"packs"` | Subdirectory within `source_path` for entry points |
|
|
31
31
|
| `nested_entries` | boolean | `true` | Discover entry points in subdirectories |
|
|
@@ -44,6 +44,8 @@ Common configuration options with their defaults:
|
|
|
44
44
|
|
|
45
45
|
For detailed explanations, examples, and additional options, see the sections below.
|
|
46
46
|
|
|
47
|
+
**\*Note on `javascript_transpiler` default**: The installation template sets this to `"swc"` for new projects. However, at runtime, if no explicit value is configured, webpack defaults to `"babel"` (for backward compatibility) while rspack defaults to `"swc"`.
|
|
48
|
+
|
|
47
49
|
## Basic Configuration
|
|
48
50
|
|
|
49
51
|
### `assets_bundler`
|
|
@@ -91,23 +93,27 @@ assets_bundler_config_path: "."
|
|
|
91
93
|
### `javascript_transpiler`
|
|
92
94
|
|
|
93
95
|
**Type:** `string`
|
|
94
|
-
**Default:** `"swc"` (
|
|
96
|
+
**Default:** `"swc"` (new installations), `"babel"` (webpack runtime), `"swc"` (rspack runtime)
|
|
95
97
|
**Options:** `"swc"`, `"babel"`, or `"esbuild"`
|
|
96
98
|
|
|
97
99
|
Specifies which transpiler to use for JavaScript/TypeScript.
|
|
98
100
|
|
|
99
101
|
```yaml
|
|
100
|
-
# Use SWC (recommended - 20x faster than Babel)
|
|
102
|
+
# Use SWC (recommended - 20x faster than Babel, set by default in new installations)
|
|
101
103
|
javascript_transpiler: "swc"
|
|
102
104
|
|
|
103
|
-
# Use Babel (for maximum compatibility)
|
|
105
|
+
# Use Babel (for maximum compatibility, webpack runtime default if not configured)
|
|
104
106
|
javascript_transpiler: "babel"
|
|
105
107
|
|
|
106
108
|
# Use esbuild (fastest, but may have compatibility issues)
|
|
107
109
|
javascript_transpiler: "esbuild"
|
|
108
110
|
```
|
|
109
111
|
|
|
110
|
-
**
|
|
112
|
+
**Important default behavior:**
|
|
113
|
+
|
|
114
|
+
- **New installations**: The installation template explicitly sets `javascript_transpiler: "swc"`
|
|
115
|
+
- **Webpack runtime default**: If not explicitly configured, defaults to `"babel"` for backward compatibility
|
|
116
|
+
- **Rspack runtime default**: If not explicitly configured, defaults to `"swc"` as rspack is a newer bundler
|
|
111
117
|
|
|
112
118
|
See [Transpiler Performance Guide](transpiler-performance.md) for benchmarks and migration guides.
|
|
113
119
|
|
|
@@ -150,11 +150,45 @@ If you prefer to keep the v8 default export behavior during migration, you can o
|
|
|
150
150
|
|
|
151
151
|
## Reverting to Default Exports (v8 Behavior)
|
|
152
152
|
|
|
153
|
-
To use the v8-style default exports instead of v9's named exports:
|
|
153
|
+
To use the v8-style default exports instead of v9's named exports, you have several options:
|
|
154
154
|
|
|
155
|
-
### Option 1:
|
|
155
|
+
### Option 1: Configuration File (Easiest - Recommended)
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
The simplest way to restore v8 behavior is to set the `css_modules_export_mode` option in your `config/shakapacker.yml`:
|
|
158
|
+
|
|
159
|
+
```yaml
|
|
160
|
+
# config/shakapacker.yml
|
|
161
|
+
default: &default
|
|
162
|
+
# ... other settings ...
|
|
163
|
+
|
|
164
|
+
# CSS Modules export mode
|
|
165
|
+
# named (default) - Use named exports with camelCase conversion (v9 default)
|
|
166
|
+
# default - Use default export with both original and camelCase names (v8 behavior)
|
|
167
|
+
css_modules_export_mode: default
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
This configuration automatically adjusts the CSS loader settings:
|
|
171
|
+
|
|
172
|
+
- Sets `namedExport: false` to enable default exports
|
|
173
|
+
- Sets `exportLocalsConvention: 'camelCase'` to export both original and camelCase versions
|
|
174
|
+
|
|
175
|
+
**Restart your development server** after changing this setting for the changes to take effect.
|
|
176
|
+
|
|
177
|
+
With this configuration, you can continue using v8-style imports:
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
// Works with css_modules_export_mode: default
|
|
181
|
+
import styles from "./Component.module.css"
|
|
182
|
+
;<div className={styles.container}>
|
|
183
|
+
<button className={styles.button}>Click me</button>
|
|
184
|
+
<button className={styles["my-button"]}>Kebab-case</button>
|
|
185
|
+
<button className={styles.myButton}>Also available</button>
|
|
186
|
+
</div>
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Option 2: Manual Webpack Configuration (Advanced)
|
|
190
|
+
|
|
191
|
+
If you need more control or can't use the configuration file approach, you can manually modify the webpack configuration that applies to all environments:
|
|
158
192
|
|
|
159
193
|
```js
|
|
160
194
|
// config/webpack/commonWebpackConfig.js
|
|
@@ -198,7 +232,7 @@ const commonWebpackConfig = () => {
|
|
|
198
232
|
module.exports = commonWebpackConfig
|
|
199
233
|
```
|
|
200
234
|
|
|
201
|
-
### Option
|
|
235
|
+
### Option 3: Create `config/webpack/environment.js` (Alternative)
|
|
202
236
|
|
|
203
237
|
If you prefer using a separate environment file:
|
|
204
238
|
|
|
@@ -239,12 +273,12 @@ module.exports = environment
|
|
|
239
273
|
|
|
240
274
|
Then reference this in your environment-specific configs (development.js, production.js, etc.).
|
|
241
275
|
|
|
242
|
-
### Option
|
|
276
|
+
### Option 4: (Optional) Sass Modules
|
|
243
277
|
|
|
244
278
|
If you also use Sass modules, add similar configuration for SCSS files:
|
|
245
279
|
|
|
246
280
|
```js
|
|
247
|
-
// For Option
|
|
281
|
+
// For Option 2 approach (manual webpack config), extend the overrideCssModulesConfig function:
|
|
248
282
|
const overrideCssModulesConfig = (config) => {
|
|
249
283
|
// Handle both CSS and SCSS rules
|
|
250
284
|
const styleRules = config.module.rules.filter(
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
## Default Transpilers
|
|
6
6
|
|
|
7
|
-
Shakapacker
|
|
7
|
+
Shakapacker v9 transpiler defaults depend on the bundler and installation:
|
|
8
8
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
9
|
+
- **New installations (v9+)**: `swc` - Installation template explicitly sets SWC (20x faster than Babel)
|
|
10
|
+
- **Webpack runtime default**: `babel` - Used when no explicit config is provided (maintains backward compatibility)
|
|
11
|
+
- **Rspack runtime default**: `swc` - Rspack defaults to SWC as it's a newer bundler with modern defaults
|
|
12
|
+
|
|
13
|
+
**Key distinction**: The installation template (`lib/install/config/shakapacker.yml`) explicitly sets `javascript_transpiler: "swc"` for new projects, but if you're upgrading or have no explicit config, webpack falls back to Babel for backward compatibility.
|
|
11
14
|
|
|
12
15
|
## Available Transpilers
|
|
13
16
|
|
|
@@ -22,15 +25,15 @@ Set the transpiler in your `config/shakapacker.yml`:
|
|
|
22
25
|
|
|
23
26
|
```yaml
|
|
24
27
|
default: &default
|
|
25
|
-
#
|
|
26
|
-
javascript_transpiler: babel
|
|
27
|
-
|
|
28
|
-
# To opt-in to SWC for better performance
|
|
28
|
+
# SWC is the default (recommended - 20x faster than Babel)
|
|
29
29
|
javascript_transpiler: swc
|
|
30
30
|
|
|
31
|
-
#
|
|
31
|
+
# To use Babel for backward compatibility
|
|
32
|
+
javascript_transpiler: babel
|
|
33
|
+
|
|
34
|
+
# For rspack users (defaults to swc if not specified)
|
|
32
35
|
assets_bundler: rspack
|
|
33
|
-
javascript_transpiler
|
|
36
|
+
# javascript_transpiler can be set, but rspack defaults to swc
|
|
34
37
|
```
|
|
35
38
|
|
|
36
39
|
## Migration Guide
|
data/docs/using_swc_loader.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# Using SWC Loader
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
If you face any issues, please report at https://github.com/shakacode/shakapacker/issues.
|
|
3
|
+
SWC is the recommended JavaScript transpiler in Shakapacker v9+, and is set as the default in new installations. If you face any issues, please report them at [Shakapacker Issues](https://github.com/shakacode/shakapacker/issues).
|
|
6
4
|
|
|
7
5
|
## About SWC
|
|
8
6
|
|
|
@@ -12,20 +10,23 @@ It supports all ECMAScript features and it's designed to be a drop-in replacemen
|
|
|
12
10
|
|
|
13
11
|
For comparison between SWC and Babel, see the docs at https://swc.rs/docs/migrating-from-babel.
|
|
14
12
|
|
|
15
|
-
> **Note:** SWC is also natively built into RSpack bundler, providing even faster compilation speeds. When using RSpack (`assets_bundler: 'rspack'`), SWC is
|
|
13
|
+
> **Note:** SWC is also natively built into RSpack bundler, providing even faster compilation speeds. When using RSpack (`assets_bundler: 'rspack'`), SWC is the default if `javascript_transpiler` is not explicitly set.
|
|
14
|
+
|
|
15
|
+
## Using SWC in your Shakapacker project
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
For new installations of Shakapacker v9+, SWC is automatically configured in the installation template.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
**Note**: While the installation template sets SWC as the default, webpack's runtime fallback (when no explicit config exists) remains Babel for backward compatibility. Rspack always defaults to SWC.
|
|
20
|
+
|
|
21
|
+
If you're upgrading from v8 or earlier and want to switch from Babel to SWC:
|
|
20
22
|
|
|
21
23
|
1. Make sure you've installed `@swc/core` and `swc-loader` packages.
|
|
22
24
|
|
|
23
|
-
```
|
|
25
|
+
```bash
|
|
24
26
|
npm install @swc/core swc-loader
|
|
25
27
|
```
|
|
26
28
|
|
|
27
|
-
2.
|
|
28
|
-
The default configuration of babel is done by using `package.json` to use the file within the `shakapacker` package.
|
|
29
|
+
2. Confirm `javascript_transpiler` is set to `swc` in your `config/shakapacker.yml`:
|
|
29
30
|
|
|
30
31
|
```yml
|
|
31
32
|
default: &default
|
|
@@ -43,7 +44,9 @@ default: &default
|
|
|
43
44
|
# Reload manifest.json on all requests so we reload latest compiled packs
|
|
44
45
|
cache_manifest: false
|
|
45
46
|
|
|
46
|
-
# Select JavaScript transpiler to use
|
|
47
|
+
# Select JavaScript transpiler to use
|
|
48
|
+
# Available options: 'swc' (default, 20x faster), 'babel', or 'esbuild'
|
|
49
|
+
# Note: When using rspack, swc is used automatically regardless of this setting
|
|
47
50
|
javascript_transpiler: "swc"
|
|
48
51
|
```
|
|
49
52
|
|
data/docs/v9_upgrade.md
CHANGED
|
@@ -145,9 +145,18 @@ import * as styles from './Component.module.css';
|
|
|
145
145
|
- TypeScript: Change to namespace imports (`import * as styles`)
|
|
146
146
|
- Kebab-case class names are automatically converted to camelCase
|
|
147
147
|
|
|
148
|
-
2. **Keep v8 behavior** temporarily:
|
|
148
|
+
2. **Keep v8 behavior** temporarily using configuration file (Easiest):
|
|
149
|
+
|
|
150
|
+
```yaml
|
|
151
|
+
# config/shakapacker.yml
|
|
152
|
+
css_modules_export_mode: default
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
This allows you to keep using default imports while migrating gradually
|
|
156
|
+
|
|
157
|
+
3. **Keep v8 behavior** using webpack configuration (Advanced):
|
|
149
158
|
- Override the css-loader configuration as shown in [CSS Modules Export Mode documentation](./css-modules-export-mode.md)
|
|
150
|
-
-
|
|
159
|
+
- Provides more control over the configuration
|
|
151
160
|
|
|
152
161
|
**Benefits of the change:**
|
|
153
162
|
|
data/eslint.config.fast.js
CHANGED
|
@@ -17,11 +17,12 @@ module.exports = [
|
|
|
17
17
|
// Global ignores (replaces .eslintignore)
|
|
18
18
|
{
|
|
19
19
|
ignores: [
|
|
20
|
-
"lib/**",
|
|
21
|
-
"**/node_modules/**",
|
|
22
|
-
"vendor/**",
|
|
23
|
-
"spec/**",
|
|
24
|
-
"package
|
|
20
|
+
"lib/**", // Ruby files, not JavaScript
|
|
21
|
+
"**/node_modules/**", // Third-party dependencies
|
|
22
|
+
"vendor/**", // Vendored dependencies
|
|
23
|
+
"spec/**", // Ruby specs, not JavaScript
|
|
24
|
+
"package/**/*.js", // Generated/compiled JavaScript from TypeScript
|
|
25
|
+
"package/**/*.d.ts" // Generated TypeScript declaration files
|
|
25
26
|
]
|
|
26
27
|
},
|
|
27
28
|
|
|
@@ -63,7 +64,11 @@ module.exports = [
|
|
|
63
64
|
"import/no-extraneous-dependencies": "off",
|
|
64
65
|
// TypeScript handles extensions, not needed for JS imports
|
|
65
66
|
"import/extensions": "off",
|
|
66
|
-
indent: ["error", 2]
|
|
67
|
+
indent: ["error", 2],
|
|
68
|
+
// Allow for...of loops - modern JS syntax
|
|
69
|
+
"no-restricted-syntax": "off",
|
|
70
|
+
// Allow console statements - used for debugging/logging throughout
|
|
71
|
+
"no-console": "off"
|
|
67
72
|
},
|
|
68
73
|
settings: {
|
|
69
74
|
react: {
|
|
@@ -130,13 +135,120 @@ module.exports = [
|
|
|
130
135
|
"@typescript-eslint/no-use-before-define": ["error"],
|
|
131
136
|
"@typescript-eslint/no-unused-vars": [
|
|
132
137
|
"error",
|
|
133
|
-
{ argsIgnorePattern: "^_" }
|
|
138
|
+
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" }
|
|
134
139
|
],
|
|
135
140
|
"@typescript-eslint/no-explicit-any": "error",
|
|
136
|
-
"@typescript-eslint/explicit-module-boundary-types": "off"
|
|
141
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
142
|
+
"no-undef": "off"
|
|
137
143
|
}
|
|
138
144
|
},
|
|
139
145
|
|
|
146
|
+
// Global rule for all TypeScript files in package/
|
|
147
|
+
// Suppress require() imports - these are intentional for CommonJS compatibility
|
|
148
|
+
// Will be addressed in Phase 3 (breaking changes) - see #708
|
|
149
|
+
{
|
|
150
|
+
files: ["package/**/*.ts"],
|
|
151
|
+
rules: {
|
|
152
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
153
|
+
"global-require": "off",
|
|
154
|
+
"import/no-import-module-exports": "off"
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
// Consolidated override for package/config.ts and package/babel/preset.ts
|
|
159
|
+
{
|
|
160
|
+
files: ["package/babel/preset.ts", "package/config.ts"],
|
|
161
|
+
rules: {
|
|
162
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
163
|
+
"import/order": "off",
|
|
164
|
+
"import/newline-after-import": "off",
|
|
165
|
+
"import/first": "off",
|
|
166
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
167
|
+
"no-useless-escape": "off"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
// configExporter module overrides
|
|
172
|
+
{
|
|
173
|
+
files: ["package/configExporter/**/*.ts"],
|
|
174
|
+
rules: {
|
|
175
|
+
"@typescript-eslint/no-use-before-define": "off",
|
|
176
|
+
"import/no-dynamic-require": "off",
|
|
177
|
+
"class-methods-use-this": "off",
|
|
178
|
+
"import/prefer-default-export": "off",
|
|
179
|
+
"no-underscore-dangle": "off",
|
|
180
|
+
"no-restricted-globals": "off",
|
|
181
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
182
|
+
"@typescript-eslint/no-explicit-any": "off"
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
// Utils module overrides
|
|
187
|
+
{
|
|
188
|
+
files: [
|
|
189
|
+
"package/utils/inliningCss.ts",
|
|
190
|
+
"package/utils/errorCodes.ts",
|
|
191
|
+
"package/utils/errorHelpers.ts",
|
|
192
|
+
"package/utils/pathValidation.ts",
|
|
193
|
+
"package/utils/getStyleRule.ts",
|
|
194
|
+
"package/utils/helpers.ts",
|
|
195
|
+
"package/utils/validateDependencies.ts",
|
|
196
|
+
"package/webpackDevServerConfig.ts"
|
|
197
|
+
],
|
|
198
|
+
rules: {
|
|
199
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
200
|
+
"no-useless-escape": "off"
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
// Plugins and optimization overrides
|
|
205
|
+
{
|
|
206
|
+
files: ["package/plugins/**/*.ts", "package/optimization/**/*.ts"],
|
|
207
|
+
rules: {
|
|
208
|
+
"import/prefer-default-export": "off"
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
// Rules, rspack, swc, esbuild, and other modules
|
|
213
|
+
{
|
|
214
|
+
files: [
|
|
215
|
+
"package/index.ts",
|
|
216
|
+
"package/rspack/index.ts",
|
|
217
|
+
"package/rules/**/*.ts",
|
|
218
|
+
"package/swc/index.ts",
|
|
219
|
+
"package/esbuild/index.ts",
|
|
220
|
+
"package/dev_server.ts",
|
|
221
|
+
"package/env.ts"
|
|
222
|
+
],
|
|
223
|
+
rules: {
|
|
224
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
225
|
+
"import/prefer-default-export": "off",
|
|
226
|
+
"no-underscore-dangle": "off"
|
|
227
|
+
}
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
// Environments module overrides
|
|
231
|
+
{
|
|
232
|
+
files: ["package/environments/**/*.ts"],
|
|
233
|
+
rules: {
|
|
234
|
+
"import/prefer-default-export": "off",
|
|
235
|
+
"no-underscore-dangle": "off"
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
// Type tests are intentionally unused - they test type compatibility
|
|
240
|
+
{
|
|
241
|
+
files: ["package/**/__type-tests__/**/*.ts"],
|
|
242
|
+
rules: {
|
|
243
|
+
"@typescript-eslint/no-unused-vars": "off"
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
// Note: Type-aware rule overrides from main config (e.g., @typescript-eslint/no-unsafe-*,
|
|
248
|
+
// @typescript-eslint/restrict-template-expressions) are intentionally omitted here since
|
|
249
|
+
// fast mode doesn't enable type-aware linting (no parserOptions.project specified).
|
|
250
|
+
// This keeps fast mode performant while maintaining consistency for non-type-aware rules.
|
|
251
|
+
|
|
140
252
|
// Prettier config must be last to override other configs
|
|
141
253
|
prettierConfig
|
|
142
254
|
]
|
data/eslint.config.js
CHANGED
|
@@ -19,13 +19,7 @@ module.exports = [
|
|
|
19
19
|
"vendor/**", // Vendored dependencies
|
|
20
20
|
"spec/**", // Ruby specs, not JavaScript
|
|
21
21
|
"package/**/*.js", // Generated/compiled JavaScript from TypeScript
|
|
22
|
-
"package/**/*.d.ts"
|
|
23
|
-
// Temporarily ignore TypeScript files until technical debt is resolved
|
|
24
|
-
// See ESLINT_TECHNICAL_DEBT.md for tracking
|
|
25
|
-
// TODO: Remove this once ESLint issues are fixed (tracked in #723)
|
|
26
|
-
// Exception: configExporter is being fixed in #707
|
|
27
|
-
"package/**/*.ts",
|
|
28
|
-
"!package/configExporter/**/*.ts" // Enable linting for configExporter (issue #707)
|
|
22
|
+
"package/**/*.d.ts" // Generated TypeScript declaration files
|
|
29
23
|
]
|
|
30
24
|
},
|
|
31
25
|
|
|
@@ -142,10 +136,10 @@ module.exports = [
|
|
|
142
136
|
// Disable base rule in favor of TypeScript version
|
|
143
137
|
"no-use-before-define": "off",
|
|
144
138
|
"@typescript-eslint/no-use-before-define": ["error"],
|
|
145
|
-
// Allow unused vars if they start with underscore (convention for ignored params)
|
|
139
|
+
// Allow unused vars if they start with underscore (convention for ignored params and type tests)
|
|
146
140
|
"@typescript-eslint/no-unused-vars": [
|
|
147
141
|
"error",
|
|
148
|
-
{ argsIgnorePattern: "^_" }
|
|
142
|
+
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" }
|
|
149
143
|
],
|
|
150
144
|
// Strict: no 'any' types allowed - use 'unknown' or specific types instead
|
|
151
145
|
"@typescript-eslint/no-explicit-any": "error",
|
|
@@ -157,37 +151,42 @@ module.exports = [
|
|
|
157
151
|
}
|
|
158
152
|
},
|
|
159
153
|
|
|
154
|
+
// Global rule for all TypeScript files in package/
|
|
155
|
+
// Suppress require() imports - these are intentional for CommonJS compatibility
|
|
156
|
+
// Will be addressed in Phase 3 (breaking changes) - see #708
|
|
157
|
+
{
|
|
158
|
+
files: ["package/**/*.ts"],
|
|
159
|
+
rules: {
|
|
160
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
161
|
+
"global-require": "off",
|
|
162
|
+
"import/no-import-module-exports": "off"
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
|
|
160
166
|
// Temporary overrides for files with remaining errors
|
|
161
167
|
// See ESLINT_TECHNICAL_DEBT.md for detailed documentation
|
|
162
168
|
//
|
|
163
|
-
// These overrides suppress ~
|
|
169
|
+
// These overrides suppress ~94 type safety errors that require:
|
|
164
170
|
// 1. Major type refactoring (any/unsafe-* rules)
|
|
165
|
-
// 2.
|
|
166
|
-
// 3. Significant code restructuring
|
|
171
|
+
// 2. Proper type definitions for config objects
|
|
167
172
|
//
|
|
168
|
-
// GitHub
|
|
169
|
-
// - #
|
|
170
|
-
// - #708: Module System: Modernize to ES6 modules with codemod
|
|
171
|
-
// - #709: Code Style: Fix remaining ESLint style issues
|
|
173
|
+
// GitHub Issue tracking this technical debt:
|
|
174
|
+
// - #790: TypeScript ESLint Phase 2b: Type Safety Improvements (~94 errors)
|
|
172
175
|
{
|
|
173
176
|
// Consolidated override for package/config.ts and package/babel/preset.ts
|
|
174
177
|
// Combines rules from both previous override blocks to avoid duplication
|
|
175
178
|
files: ["package/babel/preset.ts", "package/config.ts"],
|
|
176
179
|
rules: {
|
|
177
|
-
// From first override block
|
|
178
|
-
"@typescript-eslint/no-require-imports": "off",
|
|
179
180
|
"@typescript-eslint/no-unused-vars": "off",
|
|
180
181
|
"@typescript-eslint/no-unsafe-call": "off",
|
|
181
182
|
"import/order": "off",
|
|
182
183
|
"import/newline-after-import": "off",
|
|
183
184
|
"import/first": "off",
|
|
184
|
-
// Additional rules that were in the second override for config.ts
|
|
185
185
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
186
186
|
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
187
187
|
"@typescript-eslint/no-unsafe-argument": "off",
|
|
188
188
|
"@typescript-eslint/no-explicit-any": "off",
|
|
189
|
-
"no-useless-escape": "off"
|
|
190
|
-
"no-continue": "off"
|
|
189
|
+
"no-useless-escape": "off"
|
|
191
190
|
}
|
|
192
191
|
},
|
|
193
192
|
{
|
|
@@ -205,19 +204,14 @@ module.exports = [
|
|
|
205
204
|
// Code organization (functions before use due to large file)
|
|
206
205
|
"@typescript-eslint/no-use-before-define": "off",
|
|
207
206
|
// Import style (CommonJS require for dynamic imports)
|
|
208
|
-
"@typescript-eslint/no-require-imports": "off",
|
|
209
207
|
"import/no-dynamic-require": "off",
|
|
210
|
-
"global-require": "off",
|
|
211
208
|
// Class methods that are part of public API
|
|
212
209
|
"class-methods-use-this": "off",
|
|
213
210
|
// Template expressions (valid use cases with union types)
|
|
214
211
|
"@typescript-eslint/restrict-template-expressions": "off",
|
|
215
212
|
// Style preferences
|
|
216
|
-
"no-continue": "off",
|
|
217
213
|
"import/prefer-default-export": "off",
|
|
218
|
-
"no-await-in-loop": "off",
|
|
219
214
|
"no-underscore-dangle": "off",
|
|
220
|
-
"no-shadow": "off",
|
|
221
215
|
"no-restricted-globals": "off",
|
|
222
216
|
"@typescript-eslint/no-unused-vars": "off",
|
|
223
217
|
"@typescript-eslint/require-await": "off"
|
|
@@ -236,20 +230,26 @@ module.exports = [
|
|
|
236
230
|
}
|
|
237
231
|
},
|
|
238
232
|
{
|
|
239
|
-
// Remaining utils files
|
|
233
|
+
// Remaining utils files that need type safety improvements
|
|
234
|
+
// These use dynamic requires and helper functions that return `any`
|
|
240
235
|
files: [
|
|
241
236
|
"package/utils/inliningCss.ts",
|
|
242
237
|
"package/utils/errorCodes.ts",
|
|
243
238
|
"package/utils/errorHelpers.ts",
|
|
244
|
-
"package/utils/pathValidation.ts"
|
|
239
|
+
"package/utils/pathValidation.ts",
|
|
240
|
+
"package/utils/getStyleRule.ts",
|
|
241
|
+
"package/utils/helpers.ts",
|
|
242
|
+
"package/utils/validateDependencies.ts",
|
|
243
|
+
"package/webpackDevServerConfig.ts"
|
|
245
244
|
],
|
|
246
245
|
rules: {
|
|
247
246
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
248
247
|
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
249
248
|
"@typescript-eslint/no-unsafe-argument": "off",
|
|
249
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
250
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
250
251
|
"@typescript-eslint/no-explicit-any": "off",
|
|
251
|
-
"no-useless-escape": "off"
|
|
252
|
-
"no-continue": "off"
|
|
252
|
+
"no-useless-escape": "off"
|
|
253
253
|
}
|
|
254
254
|
},
|
|
255
255
|
{
|
|
@@ -257,13 +257,13 @@ module.exports = [
|
|
|
257
257
|
rules: {
|
|
258
258
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
259
259
|
"@typescript-eslint/no-unsafe-call": "off",
|
|
260
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
260
261
|
"@typescript-eslint/no-redundant-type-constituents": "off",
|
|
261
262
|
"import/prefer-default-export": "off"
|
|
262
263
|
}
|
|
263
264
|
},
|
|
264
265
|
{
|
|
265
266
|
files: [
|
|
266
|
-
"package/environments/**/*.ts",
|
|
267
267
|
"package/index.ts",
|
|
268
268
|
"package/rspack/index.ts",
|
|
269
269
|
"package/rules/**/*.ts",
|
|
@@ -276,6 +276,8 @@ module.exports = [
|
|
|
276
276
|
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
277
277
|
"@typescript-eslint/no-unsafe-call": "off",
|
|
278
278
|
"@typescript-eslint/no-unsafe-return": "off",
|
|
279
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
280
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
279
281
|
"@typescript-eslint/no-redundant-type-constituents": "off",
|
|
280
282
|
"@typescript-eslint/no-unused-vars": "off",
|
|
281
283
|
"@typescript-eslint/no-unsafe-function-type": "off",
|
|
@@ -283,6 +285,23 @@ module.exports = [
|
|
|
283
285
|
"no-underscore-dangle": "off"
|
|
284
286
|
}
|
|
285
287
|
},
|
|
288
|
+
{
|
|
289
|
+
// package/environments/**/*.ts now passes no-unused-vars rule
|
|
290
|
+
// Type test functions use underscore prefix (argsIgnorePattern: "^_")
|
|
291
|
+
// All other variables are used in the code
|
|
292
|
+
files: ["package/environments/**/*.ts"],
|
|
293
|
+
rules: {
|
|
294
|
+
"@typescript-eslint/no-unsafe-assignment": "off",
|
|
295
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
296
|
+
"@typescript-eslint/no-unsafe-return": "off",
|
|
297
|
+
"@typescript-eslint/no-unsafe-member-access": "off",
|
|
298
|
+
"@typescript-eslint/no-unsafe-argument": "off",
|
|
299
|
+
"@typescript-eslint/no-redundant-type-constituents": "off",
|
|
300
|
+
"@typescript-eslint/no-unsafe-function-type": "off",
|
|
301
|
+
"import/prefer-default-export": "off",
|
|
302
|
+
"no-underscore-dangle": "off"
|
|
303
|
+
}
|
|
304
|
+
},
|
|
286
305
|
|
|
287
306
|
// Prettier config must be last to override other configs
|
|
288
307
|
prettierConfig
|
|
@@ -19,6 +19,18 @@ default: &default
|
|
|
19
19
|
# css_extract_ignore_order_warnings to true
|
|
20
20
|
css_extract_ignore_order_warnings: false
|
|
21
21
|
|
|
22
|
+
# CSS Modules export mode
|
|
23
|
+
# Controls how CSS Module class names are exported in JavaScript
|
|
24
|
+
# Defaults to 'named' if not specified. Uncomment and change to 'default' for v8 behavior.
|
|
25
|
+
# Options:
|
|
26
|
+
# - named (default): Use named exports with camelCase conversion (v9 default)
|
|
27
|
+
# Example: import { button } from './styles.module.css'
|
|
28
|
+
# - default: Use default export with both original and camelCase names (v8 behavior)
|
|
29
|
+
# Example: import styles from './styles.module.css'
|
|
30
|
+
# For gradual migration, you can set this to default to maintain v8 behavior
|
|
31
|
+
# See https://github.com/shakacode/shakapacker/blob/main/docs/css-modules-export-mode.md
|
|
32
|
+
# css_modules_export_mode: named
|
|
33
|
+
|
|
22
34
|
public_root_path: public
|
|
23
35
|
public_output_path: packs
|
|
24
36
|
cache_path: tmp/shakapacker
|
|
@@ -41,7 +53,8 @@ default: &default
|
|
|
41
53
|
cache_manifest: false
|
|
42
54
|
|
|
43
55
|
# Select JavaScript transpiler to use
|
|
44
|
-
# Available options: 'swc' (default, 20x faster), 'babel', or '
|
|
56
|
+
# Available options: 'swc' (default, 20x faster), 'babel', 'esbuild', or 'none'
|
|
57
|
+
# Use 'none' when providing a completely custom webpack configuration
|
|
45
58
|
# Note: When using rspack, swc is used automatically regardless of this setting
|
|
46
59
|
javascript_transpiler: "swc"
|
|
47
60
|
|