@enact/cli 7.0.0-alpha.3 → 7.0.0-alpha.5

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## 7.0.0-alpha.5 (February 26, 2025)
2
+
3
+ ### lint
4
+
5
+ * Updated `eslint` to v9 and adopted flat config.
6
+
7
+ ## 7.0.0-alpha.4 (January 17, 2025)
8
+
9
+ * Updated all dependencies to the latest including React 19.
10
+ * Updated the minimum version of Node to `20.5.0`.
11
+
12
+ ### pack
13
+
14
+ * Changed classnames to be hashed when production build.
15
+
1
16
  ## 7.0.0-alpha.3 (December 12, 2024)
2
17
 
3
18
  ### pack
package/commands/eject.js CHANGED
@@ -44,7 +44,7 @@ const bareTasks = {
44
44
  'pack-p': 'webpack --env production --config config/webpack.config.js && cpy public dist',
45
45
  watch: 'cpy public dist && webpack --env development --config config/webpack.config.js --watch',
46
46
  clean: 'rimraf build dist',
47
- lint: 'eslint --no-eslintrc --config enact --ignore-pattern config/* .',
47
+ lint: 'eslint --no-config-lookup --config enact --ignore-pattern config/* .',
48
48
  license: 'license-checker ',
49
49
  test: 'jest --config config/jest/jest.config.js',
50
50
  'test-watch': 'jest --config config/jest/jest.config.js --watch'
@@ -216,7 +216,7 @@ function configurePackage(bare) {
216
216
  app.eslintConfig = eslintConfig;
217
217
  app.eslintIgnore = app.eslintIgnore || [];
218
218
  app.eslintIgnore = app.eslintIgnore.concat(eslintIgnore.filter(l => !app.eslintIgnore.includes(l)));
219
- backupOld(['.eslintignore', '.eslintrc.js', '.eslintrc.yaml', '.eslintrc.yml', '.eslintrc.json', '.eslintrc']);
219
+ backupOld(['.eslintignore', 'eslint.config.js']);
220
220
 
221
221
  // Sort the package.json output
222
222
  ['dependencies', 'devDependencies'].forEach(obj => {
package/commands/lint.js CHANGED
@@ -37,9 +37,9 @@ function shouldESLint() {
37
37
  function eslint({strict = false, local = false, fix = false, eslintArgs = []} = {}) {
38
38
  let args = [];
39
39
  if (strict) {
40
- args.push('--no-eslintrc', '--config', require.resolve('eslint-config-enact/strict'));
40
+ args.push('--no-config-lookup', '--config', require.resolve('eslint-config-enact/strict'));
41
41
  } else if (!local) {
42
- args.push('--no-eslintrc', '--config', require.resolve('eslint-config-enact'));
42
+ args.push('--no-config-lookup', '--config', require.resolve('eslint-config-enact'));
43
43
  }
44
44
  if (local) {
45
45
  args.push('--ignore-pattern', '**/node_modules/*');
package/commands/pack.js CHANGED
@@ -252,6 +252,8 @@ function api(opts = {}) {
252
252
  app.applyEnactMeta({template: path.join(__dirname, '..', 'config', 'custom-skin-template.ejs')});
253
253
  }
254
254
 
255
+ // make the framework option available globally in order to be used by the eslint-webpack-plugin custom configuration
256
+ process.env.FRAMEWORK = opts.framework;
255
257
  // Do this as the first thing so that any code reading it knows the right env.
256
258
  const configFactory = require('../config/webpack.config');
257
259
  const config = configFactory(
@@ -260,7 +262,6 @@ function api(opts = {}) {
260
262
  opts.isomorphic,
261
263
  !opts.animation,
262
264
  !opts['split-css'],
263
- opts.framework,
264
265
  opts['ilib-additional-path']
265
266
  );
266
267
 
@@ -0,0 +1,30 @@
1
+ const eslintConfigEnact = require('eslint-config-enact/index');
2
+ const eslintConfigEnactStrict = require('eslint-config-enact/strict');
3
+
4
+ // Check if JSX transform is able
5
+ const hasJsxRuntime = (() => {
6
+ if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
7
+ return false;
8
+ }
9
+
10
+ try {
11
+ require.resolve('react/jsx-runtime');
12
+ return true;
13
+ } catch (e) {
14
+ return false;
15
+ }
16
+ })();
17
+
18
+ const loadedEnactConfig = process.env.FRAMEWORK ? eslintConfigEnactStrict : eslintConfigEnact;
19
+
20
+ module.exports = [
21
+ ...loadedEnactConfig,
22
+ {
23
+ rules: {
24
+ ...(!hasJsxRuntime && {
25
+ 'react/jsx-uses-react': 'warn',
26
+ 'react/react-in-jsx-scope': 'warn'
27
+ })
28
+ }
29
+ }
30
+ ];
@@ -46,7 +46,6 @@ module.exports = function (
46
46
  isomorphic = false,
47
47
  noAnimation = false,
48
48
  noSplitCSS = false,
49
- framework = false,
50
49
  ilibAdditionalResourcesPath
51
50
  ) {
52
51
  process.chdir(app.context);
@@ -57,20 +56,6 @@ module.exports = function (
57
56
  // Sets the browserslist default fallback set of browsers to the Enact default browser support list.
58
57
  app.setEnactTargetsAsDefault();
59
58
 
60
- // Check if JSX transform is able
61
- const hasJsxRuntime = (() => {
62
- if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
63
- return false;
64
- }
65
-
66
- try {
67
- require.resolve('react/jsx-runtime');
68
- return true;
69
- } catch (e) {
70
- return false;
71
- }
72
- })();
73
-
74
59
  // Check if TypeScript is setup
75
60
  const useTypeScript = fs.existsSync('tsconfig.json');
76
61
 
@@ -335,7 +320,7 @@ module.exports = function (
335
320
  use: getStyleLoaders({
336
321
  importLoaders: 1,
337
322
  modules: {
338
- getLocalIdent
323
+ ...(isEnvProduction ? {} : {getLocalIdent})
339
324
  }
340
325
  })
341
326
  },
@@ -346,7 +331,8 @@ module.exports = function (
346
331
  use: getStyleLoaders({
347
332
  importLoaders: 1,
348
333
  modules: {
349
- ...(app.forceCSSModules ? {getLocalIdent} : {mode: 'icss'})
334
+ ...(app.forceCSSModules ? {} : {mode: 'icss'}),
335
+ ...(!app.forceCSSModules && isEnvProduction ? {} : {getLocalIdent})
350
336
  }
351
337
  }),
352
338
  // Don't consider CSS imports dead code even if the
@@ -360,7 +346,7 @@ module.exports = function (
360
346
  use: getLessStyleLoaders({
361
347
  importLoaders: 2,
362
348
  modules: {
363
- getLocalIdent
349
+ ...(isEnvProduction ? {} : {getLocalIdent})
364
350
  }
365
351
  })
366
352
  },
@@ -369,7 +355,8 @@ module.exports = function (
369
355
  use: getLessStyleLoaders({
370
356
  importLoaders: 2,
371
357
  modules: {
372
- ...(app.forceCSSModules ? {getLocalIdent} : {mode: 'icss'})
358
+ ...(app.forceCSSModules ? {} : {mode: 'icss'}),
359
+ ...(!app.forceCSSModules && isEnvProduction ? {} : {getLocalIdent})
373
360
  }
374
361
  }),
375
362
  sideEffects: true
@@ -381,7 +368,7 @@ module.exports = function (
381
368
  use: getScssStyleLoaders({
382
369
  importLoaders: 3,
383
370
  modules: {
384
- getLocalIdent
371
+ ...(isEnvProduction ? {} : {getLocalIdent})
385
372
  }
386
373
  })
387
374
  },
@@ -391,7 +378,8 @@ module.exports = function (
391
378
  use: getScssStyleLoaders({
392
379
  importLoaders: 3,
393
380
  modules: {
394
- ...(app.forceCSSModules ? {getLocalIdent} : {mode: 'icss'})
381
+ ...(app.forceCSSModules ? {} : {mode: 'icss'}),
382
+ ...(!app.forceCSSModules && isEnvProduction ? {} : {getLocalIdent})
395
383
  }
396
384
  })
397
385
  },
@@ -521,7 +509,9 @@ module.exports = function (
521
509
  ignoreOrder: noSplitCSS
522
510
  }),
523
511
  // Webpack5 removed node polyfills but we need this to run screenshot tests
524
- new NodePolyfillPlugin(),
512
+ new NodePolyfillPlugin({
513
+ additionalAliases: ['console', 'domain', 'process', 'stream']
514
+ }),
525
515
  // Provide meaningful information when modules are not found
526
516
  new ModuleNotFoundPlugin(app.context),
527
517
  // Ensure correct casing in module filepathes
@@ -582,26 +572,12 @@ module.exports = function (
582
572
  }),
583
573
  new ESLintPlugin({
584
574
  // Plugin options
575
+ configType: 'flat',
585
576
  extensions: ['js', 'mjs', 'jsx', 'ts', 'tsx'],
586
577
  formatter: require.resolve('react-dev-utils/eslintFormatter'),
587
578
  eslintPath: require.resolve('eslint'),
588
- // ESLint class options
589
- resolvePluginsRelativeTo: __dirname,
590
579
  // @remove-on-eject-begin
591
- baseConfig: {
592
- extends: [
593
- framework
594
- ? require.resolve('eslint-config-enact/strict.js')
595
- : require.resolve('eslint-config-enact/index.js')
596
- ],
597
- rules: {
598
- ...(!hasJsxRuntime && {
599
- 'react/jsx-uses-react': 'warn',
600
- 'react/react-in-jsx-scope': 'warn'
601
- })
602
- }
603
- },
604
- useEslintrc: false,
580
+ overrideConfigFile: require.resolve('./eslintWebpackPluginConfig'),
605
581
  // @remove-on-eject-end
606
582
  cache: true
607
583
  })
@@ -0,0 +1,47 @@
1
+ const enactConfig = require('eslint-config-enact');
2
+ const prettierConfig = require('eslint-config-prettier');
3
+ const importPlugin = require('eslint-plugin-import');
4
+ const prettierPlugin = require('eslint-plugin-prettier');
5
+ const globals = require('globals');
6
+
7
+ module.exports = [
8
+ ...enactConfig,
9
+ {
10
+ languageOptions: {
11
+ ecmaVersion: 'latest',
12
+ sourceType: 'module',
13
+ globals: {
14
+ ...globals.node
15
+ },
16
+ parserOptions: {
17
+ ecmaFeatures: {
18
+ jsx: true
19
+ }
20
+ }
21
+ },
22
+ plugins: {
23
+ import: importPlugin,
24
+ prettier: prettierPlugin
25
+ },
26
+ rules: {
27
+ // import plugin rules
28
+ 'import/no-unresolved': ['error', {commonjs: true, caseSensitive: true}],
29
+ 'import/named': 'error',
30
+ 'import/first': 'warn',
31
+ 'import/no-duplicates': 'error',
32
+ 'import/extensions': ['warn', 'always', {js: 'never', json: 'always'}],
33
+ 'import/newline-after-import': 'warn',
34
+ 'import/order': [
35
+ 'warn',
36
+ {
37
+ 'newlines-between': 'never',
38
+ groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index']
39
+ }
40
+ ],
41
+
42
+ // prettier rules
43
+ ...prettierPlugin.configs.recommended.rules,
44
+ ...prettierConfig.rules
45
+ }
46
+ }
47
+ ];