@automattic/i18n-check-webpack-plugin 1.1.8 → 1.1.10

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
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.10] - 2024-08-21
9
+ ### Changed
10
+ - Internal updates.
11
+
12
+ ## [1.1.9] - 2024-06-12
13
+ ### Changed
14
+ - Updated package dependencies. [#37796]
15
+
8
16
  ## [1.1.8] - 2024-05-06
9
17
  ### Changed
10
18
  - Internal updates.
@@ -206,6 +214,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
206
214
  ### Added
207
215
  - Initial release.
208
216
 
217
+ [1.1.10]: https://github.com/Automattic/i18n-check-webpack-plugin/compare/v1.1.9...v1.1.10
218
+ [1.1.9]: https://github.com/Automattic/i18n-check-webpack-plugin/compare/v1.1.8...v1.1.9
209
219
  [1.1.8]: https://github.com/Automattic/i18n-check-webpack-plugin/compare/v1.1.7...v1.1.8
210
220
  [1.1.7]: https://github.com/Automattic/i18n-check-webpack-plugin/compare/v1.1.6...v1.1.7
211
221
  [1.1.6]: https://github.com/Automattic/i18n-check-webpack-plugin/compare/v1.1.5...v1.1.6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/i18n-check-webpack-plugin",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "description": "A Webpack plugin to check that WordPress i18n hasn't been mangled by Webpack optimizations.",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/i18n-check-webpack-plugin/#readme",
6
6
  "bugs": {
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "devDependencies": {
23
23
  "@automattic/jetpack-webpack-config": "workspace:*",
24
- "@babel/core": "7.24.0",
24
+ "@babel/core": "7.24.7",
25
25
  "jest": "29.7.0",
26
26
  "webpack": "5.76.0",
27
27
  "webpack-cli": "4.9.1"
@@ -22,12 +22,12 @@ class GettextEntry {
22
22
  /**
23
23
  * Constructor.
24
24
  *
25
- * @param {object} data - Entry data.
26
- * @param {string} data.msgid - Message string.
27
- * @param {string} data.plural - Plural string.
28
- * @param {string} data.context - Context.
29
- * @param {string} data.domain - Text domain.
30
- * @param {Iterable<string>} data.comments - Comments.
25
+ * @param {object} data - Entry data.
26
+ * @param {string} data.msgid - Message string.
27
+ * @param {string} data.plural - Plural string.
28
+ * @param {string} data.context - Context.
29
+ * @param {string} data.domain - Text domain.
30
+ * @param {Iterable<string>} data.comments - Comments.
31
31
  * @param {Iterable<string>} data.locations - Locations.
32
32
  */
33
33
  constructor( data ) {
@@ -38,10 +38,10 @@ class GettextExtractor {
38
38
  /**
39
39
  * Constructor.
40
40
  *
41
- * @param {object} options - Configuration options.
42
- * @param {object} options.babelOptions - Options for Babel.
43
- * @param {Object<string, (string | null)[]>} options.functions - Functions to extract. Defaults are available as a static property `defaultFunctions`.
44
- * @param {Function} options.lintLogger - Lint logging callback. See `this.setLintLogger()`.
41
+ * @param {object} options - Configuration options.
42
+ * @param {object} options.babelOptions - Options for Babel.
43
+ * @param {Object<string, (string | null)[]>} options.functions - Functions to extract. Defaults are available as a static property `defaultFunctions`.
44
+ * @param {Function} options.lintLogger - Lint logging callback. See `this.setLintLogger()`.
45
45
  */
46
46
  constructor( options = {} ) {
47
47
  this.#babelOptions = options.babelOptions || {};
@@ -54,7 +54,7 @@ class GettextExtractor {
54
54
  *
55
55
  * @param {string} file - File name.
56
56
  * @param {object} opts - Babel options.
57
- * @returns {GettextEntries} Set of entries.
57
+ * @return {GettextEntries} Set of entries.
58
58
  */
59
59
  async extractFromFile( file, opts = {} ) {
60
60
  const contents = await fs.readFile( file, { encoding: 'utf8' } );
@@ -65,8 +65,8 @@ class GettextExtractor {
65
65
  * Parse source.
66
66
  *
67
67
  * @param {string} source - JavaScript source.
68
- * @param {object} opts - Babel options.
69
- * @returns {babel.File} Babel File object.
68
+ * @param {object} opts - Babel options.
69
+ * @return {babel.File} Babel File object.
70
70
  */
71
71
  async parse( source, opts = {} ) {
72
72
  const options = { ...this.#babelOptions, ...opts };
@@ -79,8 +79,8 @@ class GettextExtractor {
79
79
  * Extract gettext strings from source.
80
80
  *
81
81
  * @param {string} source - JavaScript source.
82
- * @param {object} opts - Babel options.
83
- * @returns {GettextEntries} Set of entries.
82
+ * @param {object} opts - Babel options.
83
+ * @return {GettextEntries} Set of entries.
84
84
  */
85
85
  async extract( source, opts ) {
86
86
  return this.extractFromAst( await this.parse( source, opts ), opts );
@@ -90,8 +90,8 @@ class GettextExtractor {
90
90
  * Extract gettext strings from a Babel File object.
91
91
  *
92
92
  * @param {babel.File} file - Babel File object, e.g. from `this.parse()`.
93
- * @param {object} opts - Babel options.
94
- * @returns {GettextEntries} Set of entries.
93
+ * @param {object} opts - Babel options.
94
+ * @return {GettextEntries} Set of entries.
95
95
  */
96
96
  extractFromAst( file, opts = {} ) {
97
97
  const entries = new GettextEntries();
@@ -101,11 +101,11 @@ class GettextExtractor {
101
101
  /**
102
102
  * Extract gettext strings from a Babel File object.
103
103
  *
104
- * @param {babel.File} file - Babel File object, e.g. from `this.parse()`.
105
- * @param {GettextEntries} entries - Entries object to fill in.
106
- * @param {number|false} evalline - If this is a recursive call from an `eval()`, the line of the eval.
107
- * @param {object} opts - Babel options.
108
- * @returns {GettextEntries} `entries`.
104
+ * @param {babel.File} file - Babel File object, e.g. from `this.parse()`.
105
+ * @param {GettextEntries} entries - Entries object to fill in.
106
+ * @param {number|false} evalline - If this is a recursive call from an `eval()`, the line of the eval.
107
+ * @param {object} opts - Babel options.
108
+ * @return {GettextEntries} `entries`.
109
109
  */
110
110
  #extractFromAst( file, entries, evalline, opts ) {
111
111
  const options = { ...this.#babelOptions, ...opts };
@@ -311,7 +311,7 @@ class GettextExtractor {
311
311
  *
312
312
  * @see https://github.com/wp-cli/i18n-command/blob/e9eef8aab4b5e43c3aa09bf60e1e7a9d6d30d302/src/JsFunctionsScanner.php#L254
313
313
  * @param {babel.CallExpression} node - CallExpression node.
314
- * @returns {{ name: string, comments: string[] }|undefined} Callee name and comments, or undefined.
314
+ * @return {{ name: string, comments: string[] }|undefined} Callee name and comments, or undefined.
315
315
  */
316
316
  #resolveExpressionCallee( node ) {
317
317
  const callee = node.callee;
@@ -422,8 +422,8 @@ class GettextExtractor {
422
422
  *
423
423
  * @see https://github.com/wp-cli/i18n-command/blob/e9eef8aab4b5e43c3aa09bf60e1e7a9d6d30d302/src/JsFunctionsScanner.php#L364
424
424
  * @param {babel.Comment} comment - Comment.
425
- * @param {babel.Node} node - Node.
426
- * @returns {boolean} Whether the comment comes before the node.
425
+ * @param {babel.Node} node - Node.
426
+ * @return {boolean} Whether the comment comes before the node.
427
427
  */
428
428
  #commentPrecedesNode( comment, node ) {
429
429
  // Comments should be on the same or an earlier line than the translation.
@@ -127,8 +127,8 @@ class I18nCheckPlugin {
127
127
  * Record the resources for an asset.
128
128
  *
129
129
  * @param {webpack.Compilation} compilation - Compilation.
130
- * @param {string} filename - Asset filename.
131
- * @param {webpack.Module[]} modules - Modules in the asset.
130
+ * @param {string} filename - Asset filename.
131
+ * @param {webpack.Module[]} modules - Modules in the asset.
132
132
  */
133
133
  #recordResourcesForAsset( compilation, filename, modules ) {
134
134
  const resources = new Set();
@@ -159,7 +159,7 @@ class I18nCheckPlugin {
159
159
  * Stringify an entry to msgid + context.
160
160
  *
161
161
  * @param {GettextEntry} entry - Entry.
162
- * @returns {string} String.
162
+ * @return {string} String.
163
163
  */
164
164
  #strentry( entry ) {
165
165
  let ret = '"' + entry.msgid.replace( /[\\"]/g, '\\$&' ).replaceAll( '\n', '\\n' ) + '"';
@@ -210,8 +210,8 @@ class I18nCheckPlugin {
210
210
  * Process an asset.
211
211
  *
212
212
  * @param {webpack.Compilation} compilation - Compilation.
213
- * @param {string} filename - Asset filename.
214
- * @param {Map} moduleCache - Cache for processed modules.
213
+ * @param {string} filename - Asset filename.
214
+ * @param {Map} moduleCache - Cache for processed modules.
215
215
  */
216
216
  async #processAsset( compilation, filename, moduleCache ) {
217
217
  const t0 = Date.now();
@@ -26,7 +26,7 @@ const { assignDeterministicIds } = require( 'webpack/lib/ids/IdHelpers' );
26
26
  /**
27
27
  * Determine if we can mangle.
28
28
  * @param {ExportsInfo} exportsInfo - exports info
29
- * @returns {boolean} mangle is possible
29
+ * @return {boolean} mangle is possible
30
30
  */
31
31
  const canMangle = exportsInfo => {
32
32
  if ( exportsInfo.otherExportsInfo.getUsed( undefined ) !== UsageState.Unused ) {
@@ -45,10 +45,10 @@ const canMangle = exportsInfo => {
45
45
  const comparator = compareSelect( e => e.name, compareStringsNumeric );
46
46
  /**
47
47
  * Mangle exports.
48
- * @param {boolean} deterministic - use deterministic names
49
- * @param {ExportsInfo} exportsInfo - exports info
50
- * @param {boolean | undefined} isNamespace - is namespace object
51
- * @returns {void}
48
+ * @param {boolean} deterministic - use deterministic names
49
+ * @param {ExportsInfo} exportsInfo - exports info
50
+ * @param {boolean | undefined} isNamespace - is namespace object
51
+ * @return {void}
52
52
  */
53
53
  const mangleExportsInfo = ( deterministic, exportsInfo, isNamespace ) => {
54
54
  if ( ! canMangle( exportsInfo ) ) {
@@ -153,7 +153,7 @@ class MangleExportsPlugin {
153
153
  /**
154
154
  * Apply the plugin
155
155
  * @param {Compiler} compiler - the compiler instance
156
- * @returns {void}
156
+ * @return {void}
157
157
  */
158
158
  apply( compiler ) {
159
159
  const { _deterministic: deterministic } = this;