From 415da9ad91fed40425d868d82b721e11d3056682 Mon Sep 17 00:00:00 2001 From: mainframev Date: Mon, 23 Dec 2024 19:04:46 +0100 Subject: [PATCH] chore: use jsDoc import tag --- .../src/rules/ban-context-export/index.js | 13 +++++--- .../eslint-plugin/src/rules/ban-imports.js | 17 ++++------ .../ban-instanceof-html-element/index.js | 2 +- .../rules/deprecated-keyboard-event-props.js | 7 ++-- .../rules/no-context-default-value/index.js | 8 +++-- .../src/rules/no-restricted-imports/index.js | 11 ++++--- .../src/rules/no-visibility-modifiers.js | 32 +++++-------------- .../eslint-plugin/src/utils/configHelpers.js | 1 - .../eslint-plugin/src/utils/type-services.js | 4 ++- scripts/babel/src/index.js | 6 ++-- scripts/monorepo/src/getDependencies.js | 14 +++++--- scripts/storybook/src/utils.js | 21 +++++++----- scripts/triage-bot/src/triage-bot.js | 2 +- scripts/webpack/src/webpack-resources.js | 28 ++++++++-------- 14 files changed, 83 insertions(+), 83 deletions(-) diff --git a/packages/eslint-plugin/src/rules/ban-context-export/index.js b/packages/eslint-plugin/src/rules/ban-context-export/index.js index a81dda19c9b7d..5e263ccc37a75 100644 --- a/packages/eslint-plugin/src/rules/ban-context-export/index.js +++ b/packages/eslint-plugin/src/rules/ban-context-export/index.js @@ -5,8 +5,11 @@ const minimatch = require('minimatch'); const createRule = require('../../utils/createRule'); const { getTypeServices } = require('../../utils/type-services'); -/** @typedef { import('@typescript-eslint/utils').TSESTree.VariableDeclarator } VariableDeclarator*/ -/** @typedef { import('@typescript-eslint/utils').TSESTree.ExportSpecifier} ExportSpecifier */ +/** + * @import { TSESTree } from '@typescript-eslint/utils' + * @import { Type } from "typescript" + */ + /** * @typedef {{ * exclude?: string[]; @@ -45,8 +48,8 @@ module.exports = createRule({ const [{ exclude = /** @type string[]*/ ([]) } = {}] = context.options; /** - * @param { ExportSpecifier | VariableDeclarator } node - * @param {string} exportName + * @param { TSESTree.ExportSpecifier | TSESTree.VariableDeclarator } node + * @param { string } exportName */ function checkContextType(node, exportName) { const currentFileName = context.filename; @@ -73,7 +76,7 @@ module.exports = createRule({ * - `createContext` from `@fluentui/react-context-selector` return type is `type Context` we use `aliasSymbol` * * @see https://github.com/microsoft/TypeScript/issues/46921#issuecomment-985048637 - * @typedef {Extract} TypeProperty + * @typedef {Extract} TypeProperty */ /** diff --git a/packages/eslint-plugin/src/rules/ban-imports.js b/packages/eslint-plugin/src/rules/ban-imports.js index 9cb305cf22676..e8ecec0bffffa 100644 --- a/packages/eslint-plugin/src/rules/ban-imports.js +++ b/packages/eslint-plugin/src/rules/ban-imports.js @@ -2,15 +2,10 @@ const { AST_NODE_TYPES } = require('@typescript-eslint/utils'); const createRule = require('../utils/createRule'); -// Nasty syntax required for type imports until https://github.com/microsoft/TypeScript/issues/22160 is implemented. -// For some reason just importing TSESTree and accessing properties off that doesn't work. /** - * @typedef {import("@typescript-eslint/utils").TSESTree.ExportNamedDeclaration} ExportNamedDeclaration - * @typedef {import("@typescript-eslint/utils").TSESTree.ExportSpecifier} ExportSpecifier - * @typedef {import("@typescript-eslint/utils").TSESTree.Identifier} Identifier - * @typedef {import("@typescript-eslint/utils").TSESTree.ImportDeclaration} ImportDeclaration - * @typedef {import("@typescript-eslint/utils").TSESTree.ImportSpecifier} ImportSpecifier - * + * @import { TSESTree } from '@typescript-eslint/utils'; */ + +/** * @typedef {{ * path?: string; * pathRegex?: string; @@ -104,9 +99,9 @@ module.exports = createRule({ } /** - * @param {ImportDeclaration | ExportNamedDeclaration} importOrExport the whole import/export node + * @param {TSESTree.ImportDeclaration | TSESTree.ExportNamedDeclaration} importOrExport the whole import/export node * @param {string} importPath path importing/exporting from - * @param {Identifier[]} identifiers imported/exported identifiers + * @param {TSESTree.Identifier[]} identifiers imported/exported identifiers */ function checkImportOrExport(importOrExport, importPath, identifiers) { for (const rule of options) { @@ -152,7 +147,7 @@ module.exports = createRule({ return; } - const specifiers = /** @type {ImportSpecifier[]} */ ( + const specifiers = /** @type {TSESTree.ImportSpecifier[]} */ ( imprt.specifiers.filter( // Filter out default imports and namespace (star) imports spec => spec.type === AST_NODE_TYPES.ImportSpecifier, diff --git a/packages/eslint-plugin/src/rules/ban-instanceof-html-element/index.js b/packages/eslint-plugin/src/rules/ban-instanceof-html-element/index.js index ca22c6f9cda71..aedade9629173 100644 --- a/packages/eslint-plugin/src/rules/ban-instanceof-html-element/index.js +++ b/packages/eslint-plugin/src/rules/ban-instanceof-html-element/index.js @@ -3,7 +3,7 @@ const { AST_NODE_TYPES } = require('@typescript-eslint/utils'); const createRule = require('../../utils/createRule'); /** - * @typedef {import('./types').HTMLElementConstructorName} HTMLElementConstructorName + * @import { HTMLElementConstructorName } from './types'; */ module.exports = createRule({ diff --git a/packages/eslint-plugin/src/rules/deprecated-keyboard-event-props.js b/packages/eslint-plugin/src/rules/deprecated-keyboard-event-props.js index 30fa88473a873..787a3d2930650 100644 --- a/packages/eslint-plugin/src/rules/deprecated-keyboard-event-props.js +++ b/packages/eslint-plugin/src/rules/deprecated-keyboard-event-props.js @@ -3,14 +3,15 @@ const createRule = require('../utils/createRule'); const { ESLintUtils } = require('@typescript-eslint/utils'); /** - * @typedef { import('@typescript-eslint/utils').TSESLint.RuleMetaDataDocs} RuleMetaDataDocs + * @import { TSESLint } from "@typescript-eslint/utils" + * @import { TypeChecker } from "typescript" */ module.exports = createRule({ name: 'deprecated-keyboard-event-props', meta: { type: 'problem', - docs: /** @type {RuleMetaDataDocs} */ ({ + docs: /** @type {TSESLint.RuleMetaDataDocs} */ ({ description: 'Forbid use of deprecated KeyboardEvent props "which" and "keyCode".', requiresTypeChecking: true, }), @@ -25,7 +26,7 @@ module.exports = createRule({ const ts = require('typescript'); const { program, esTreeNodeToTSNodeMap } = ESLintUtils.getParserServices(context); - /** @type {import("typescript").TypeChecker | undefined} */ + /** @type {TypeChecker | undefined} */ let typeChecker; return { diff --git a/packages/eslint-plugin/src/rules/no-context-default-value/index.js b/packages/eslint-plugin/src/rules/no-context-default-value/index.js index 77ddfa17e7f97..aec94028ff35e 100644 --- a/packages/eslint-plugin/src/rules/no-context-default-value/index.js +++ b/packages/eslint-plugin/src/rules/no-context-default-value/index.js @@ -2,6 +2,8 @@ const { AST_NODE_TYPES } = require('@typescript-eslint/utils'); const createRule = require('../../utils/createRule'); +/** @import { TSESTree } from "@typescript-eslint/utils" */ + /** * * @typedef {{ @@ -43,7 +45,7 @@ module.exports = createRule({ const createContextParentIdentifiers = []; /** - * @param {import("@typescript-eslint/utils").TSESTree.Expression} callee + * @param { TSESTree.Expression } callee */ function isCalleeCreateContext(callee) { if ( @@ -97,8 +99,8 @@ module.exports = createRule({ }); /** - * @param {import("@typescript-eslint/utils").TSESTree.CallExpressionArgument} expression - * @returns {expression is import("@typescript-eslint/utils").TSESTree.Identifier} + * @param { TSESTree.CallExpressionArgument } expression + * @returns { expression is TSESTree.Identifier } */ function isArgumentNotUndefined(expression) { return expression.type !== AST_NODE_TYPES.Identifier || expression.name !== 'undefined'; diff --git a/packages/eslint-plugin/src/rules/no-restricted-imports/index.js b/packages/eslint-plugin/src/rules/no-restricted-imports/index.js index b1b03711f86ae..4a60b504a58ec 100644 --- a/packages/eslint-plugin/src/rules/no-restricted-imports/index.js +++ b/packages/eslint-plugin/src/rules/no-restricted-imports/index.js @@ -3,11 +3,10 @@ const { AST_NODE_TYPES } = require('@typescript-eslint/utils'); const createRule = require('../../utils/createRule'); /** - * @typedef {import("@typescript-eslint/utils").TSESTree.ImportClause} ImportClause - * @typedef {import("@typescript-eslint/utils").TSESTree.ImportDeclaration} ImportDeclaration + * @import { TSESTree } from "@typescript-eslint/utils" * * Lookup for insertion point for new imports when moving a restricted import to a preferred import. - * @typedef {{[preferredPkgName: string] : ImportDeclaration}} FixMap + * @typedef {{[preferredPkgName: string] : TSESTree.ImportDeclaration}} FixMap * * @typedef {{ * forbidden: string[], @@ -132,9 +131,11 @@ module.exports = createRule({ function getUpdatedImportStatement(fixMap, preferredImportForCurrentPkg) { const isTypeImport = imprt.importKind === 'type'; const currentSpecifiers = fixMap[preferredImportForCurrentPkg].specifiers.map( - (/** @type {ImportClause} */ specifier) => specifier.local.name, + (/** @type {TSESTree.ImportClause} */ specifier) => specifier.local.name, + ); + const specifiersToAdd = imprt.specifiers.map( + (/** @type {TSESTree.ImportClause} */ specifier) => specifier.local.name, ); - const specifiersToAdd = imprt.specifiers.map((/** @type {ImportClause} */ specifier) => specifier.local.name); const combinedSpecifiers = currentSpecifiers.concat(specifiersToAdd).join(', '); return `import${ diff --git a/packages/eslint-plugin/src/rules/no-visibility-modifiers.js b/packages/eslint-plugin/src/rules/no-visibility-modifiers.js index 04408e27c549b..d5d9c32ec710d 100644 --- a/packages/eslint-plugin/src/rules/no-visibility-modifiers.js +++ b/packages/eslint-plugin/src/rules/no-visibility-modifiers.js @@ -12,30 +12,14 @@ const MemberNameType = { }; /** - * @typedef {import('@typescript-eslint/utils').TSESTree.MethodDefinition} MethodDefinition - * @typedef {import('@typescript-eslint/utils').TSESTree.PropertyDefinition} PropertyDefinition - * @typedef {import('@typescript-eslint/utils').TSESTree.Property} Property - * @typedef {import('@typescript-eslint/utils').TSESTree.TSAbstractMethodDefinition} TSAbstractMethodDefinition - * @typedef {import('@typescript-eslint/utils').TSESTree.TSAbstractPropertyDefinition} TSAbstractPropertyDefinition - * @typedef {import('@typescript-eslint/utils').TSESTree.TSMethodSignature} TSMethodSignature - * @typedef {import('@typescript-eslint/utils').TSESTree.TSPropertySignature} TSProperySignature - * @typedef {import('@typescript-eslint/utils').TSESLint.SourceCode} SourceCode - */ - -// Nasty syntax required for type imports until https://github.com/microsoft/TypeScript/issues/22160 is implemented. -// For some reason just importing TSESTree and accessing properties off that doesn't work. -/** - * @typedef {import("@typescript-eslint/utils").TSESTree.PropertyDefinition} ClassProperty - * @typedef {import("@typescript-eslint/utils").TSESTree.Identifier} Identifier - * @typedef {import("@typescript-eslint/utils").TSESTree.Node} Node - * @typedef {import("@typescript-eslint/utils").TSESTree.TSParameterProperty} ParameterProperty + * @import { TSESLint, TSESTree } from "@typescript-eslint/utils" */ /** * Gets a string name representation of the name of the given MethodDefinition * or PropertyDefinition node, with handling for computed property names. - * @param {MethodDefinition | PropertyDefinition | Property | TSAbstractMethodDefinition | TSAbstractPropertyDefinition | TSMethodSignature | TSProperySignature} member The node to get the name of. - * @param {SourceCode} sourceCode The source code object. + * @param {TSESTree.MethodDefinition | TSESTree.PropertyDefinition | TSESTree.Property | TSESTree.TSAbstractMethodDefinition | TSESTree.TSAbstractPropertyDefinition | TSESTree.TSMethodSignature | TSESTree.TSPropertySignature} member The node to get the name of. + * @param {TSESLint.SourceCode} sourceCode The source code object. * @returns {{ type: number; name: string }} The name of the member. */ @@ -92,7 +76,7 @@ module.exports = createRule({ /** * Generates the report for rule violations * @param {string} nodeType - * @param {Node} node + * @param {TSESTree.Node} node * @param {{ type: number; name: string } | string} nodeName */ function reportIssue(nodeType, node, nodeName) { @@ -113,7 +97,7 @@ module.exports = createRule({ /** * Checks if a method declaration has an accessibility modifier. - * @param {MethodDefinition} methodDefinition The node representing a MethodDefinition. + * @param {TSESTree.MethodDefinition} methodDefinition The node representing a MethodDefinition. */ function checkMethodAccessibilityModifier(methodDefinition) { let nodeType = 'method definition'; @@ -133,7 +117,7 @@ module.exports = createRule({ /** * Checks if property has an accessibility modifier. - * @param {ClassProperty} classProperty The node representing a ClassProperty. + * @param {TSESTree.PropertyDefinition} classProperty The node representing a ClassProperty. */ function checkPropertyAccessibilityModifier(classProperty) { const nodeType = 'class property'; @@ -149,7 +133,7 @@ module.exports = createRule({ /** * Checks that the parameter property has the desired accessibility modifiers set. - * @param {ParameterProperty} node The node representing a Parameter Property + * @param {TSESTree.ParameterProperty} node The node representing a Parameter Property */ function checkParameterPropertyAccessibilityModifier(node) { const nodeType = 'parameter property'; @@ -167,7 +151,7 @@ module.exports = createRule({ node.parameter.type === AST_NODE_TYPES.Identifier ? node.parameter.name : // has to be an Identifier or TSC will throw an error - /** @type {Identifier} */ (node.parameter.left).name; + /** @type {TSESTree.Identifier} */ (node.parameter.left).name; if (node.accessibility) { reportIssue(nodeType, node, nodeName); diff --git a/packages/eslint-plugin/src/utils/configHelpers.js b/packages/eslint-plugin/src/utils/configHelpers.js index 209d408179af1..ba822123178ca 100644 --- a/packages/eslint-plugin/src/utils/configHelpers.js +++ b/packages/eslint-plugin/src/utils/configHelpers.js @@ -12,7 +12,6 @@ const { readProjectConfiguration } = require('@nx/devkit'); /** * @typedef {{root: string, name: string}} Options * @typedef {{name: string, version: string, dependencies: {[key: string]: string}}} PackageJson - * @typedef {import("@nx/devkit").WorkspaceJsonConfiguration} WorkspaceJsonConfiguration */ // FIXME: this is not ok (to depend on nx packages within this plugin - redo) diff --git a/packages/eslint-plugin/src/utils/type-services.js b/packages/eslint-plugin/src/utils/type-services.js index 27593d6024935..eaa3e3d40d733 100644 --- a/packages/eslint-plugin/src/utils/type-services.js +++ b/packages/eslint-plugin/src/utils/type-services.js @@ -1,9 +1,11 @@ const { ESLintUtils } = require('@typescript-eslint/utils'); +/** @import {TSESLint} from '@typescript-eslint/utils' */ + /** * @template {string} TMessageIds * @template {unknown[]} TOptions - * @param {import('@typescript-eslint/utils').TSESLint.RuleContext>} context + * @param {TSESLint.RuleContext>} context * @returns */ function getTypeServices(context) { diff --git a/scripts/babel/src/index.js b/scripts/babel/src/index.js index 79cb6a797daae..c16b617f7a826 100644 --- a/scripts/babel/src/index.js +++ b/scripts/babel/src/index.js @@ -2,7 +2,9 @@ * This files is used solely for react-northstar projects. Please don't any new logic here */ -/** @typedef {import('@babel/core').TransformOptions['caller']} Caller */ +/** @import {TransformOptions, ConfigAPI} from '@babel/core'; + */ +/** @typedef {TransformOptions['caller']} Caller */ const isNodeCaller = (/** @type {Caller}*/ caller) => { return Boolean(caller && (caller.name === '@babel/register' || caller.name === 'babel-jest')); @@ -15,7 +17,7 @@ const supportsESM = (/** @type {Caller}*/ caller) => { return !!((caller && caller.name === 'babel-loader') || caller.useESModules); }; -module.exports = (/** @type {import('@babel/core').ConfigAPI} */ api) => { +module.exports = (/** @type {ConfigAPI} */ api) => { const isDistBundle = api.caller(isDistCaller); const isNode = api.caller(isNodeCaller); const useESModules = !isNode && api.caller(supportsESM); diff --git a/scripts/monorepo/src/getDependencies.js b/scripts/monorepo/src/getDependencies.js index 3c93bd5ae61d3..0c04f0f622917 100644 --- a/scripts/monorepo/src/getDependencies.js +++ b/scripts/monorepo/src/getDependencies.js @@ -2,6 +2,10 @@ const fs = require('node:fs'); const { createProjectGraphAsync, joinPathFragments, workspaceRoot } = require('@nx/devkit'); +/** @import { PackageJson } from './types'; + * @import { ProjectGraph } from '@nx/devkit'; + */ + /** * @typedef {{ name: string, @@ -10,7 +14,7 @@ const { createProjectGraphAsync, joinPathFragments, workspaceRoot } = require('@ }} Dependency */ -/** @typedef {import('./types').PackageJson & {absoluteRootPath:string}} PackageJsonInfoData */ +/** @typedef {PackageJson & {absoluteRootPath:string}} PackageJsonInfoData */ /** * @type {Record} @@ -20,7 +24,7 @@ const packageJsonInfo = {}; /** * * @param {string} project - * @param {import('@nx/devkit').ProjectGraph} projectGraph + * @param {ProjectGraph} projectGraph */ function getProjectPackageJsonInfo(project, projectGraph) { const normalizedProjectName = getNormalizedName(project); @@ -48,7 +52,7 @@ function getProjectPackageJsonInfo(project, projectGraph) { /** * Returns local dependencies of provided project. Local means dependency from within workspace * @param {string} project - * @param {import('@nx/devkit').ProjectGraph} projectGraph + * @param {ProjectGraph} projectGraph */ function getLocalDeps(project, projectGraph) { const deps = projectGraph.dependencies[project]; @@ -74,7 +78,7 @@ function getLocalDeps(project, projectGraph) { /** * * @param {string} pkgName - * @param {import('./types').PackageJson} json + * @param {PackageJson} json * @returns */ function getDepType(pkgName, json) { @@ -95,7 +99,7 @@ function getDepType(pkgName, json) { /** * * @param {string} project - * @param {import('@nx/devkit').ProjectGraph} projectGraph + * @param {ProjectGraph} projectGraph * @param {*} options * @param {Dependency[]} _acc * @param {boolean} _areTopLevelDeps diff --git a/scripts/storybook/src/utils.js b/scripts/storybook/src/utils.js index 45d21e142569b..74374a39552be 100644 --- a/scripts/storybook/src/utils.js +++ b/scripts/storybook/src/utils.js @@ -7,6 +7,11 @@ const { FsTree } = require('nx/src/generators/tree'); const semver = require('semver'); const { TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin'); +/** + * @import { Configuration, RuleSetRule } from 'webpack'; + * @import { TransformOptions } from '@babel/core'; + * */ + const loadWorkspaceAddonDefaultOptions = { workspaceRoot }; /** * Registers workspace custom storybook addon to storybook with build-less setup during development. @@ -309,7 +314,7 @@ function getPackageStoriesGlob(options) { * register TsconfigPathsPlugin to webpack config * @param {Object} options * @param {string} options.configFile - absolute path to tsconfig that contains path aliases - * @param {import('webpack').Configuration} options.config - webpack config + * @param {Configuration} options.config - webpack config * @returns */ function registerTsPaths(options) { @@ -333,8 +338,8 @@ function registerTsPaths(options) { * * register custom Webpack Rules to webpack config * @param {Object} options - * @param {import('webpack').RuleSetRule[]} options.rules - webpack rules - * @param {import('webpack').Configuration} options.config - webpack config + * @param {RuleSetRule[]} options.rules - webpack rules + * @param {Configuration} options.config - webpack config * @returns */ function registerRules(options) { @@ -347,7 +352,7 @@ function registerRules(options) { } /** - * @typedef {import('@babel/core').TransformOptions & Partial<{customize: string | null}>} BabelLoaderOptions + * @typedef {TransformOptions & Partial<{customize: string | null}>} BabelLoaderOptions */ /** @@ -385,24 +390,24 @@ function processBabelLoaderOptions(loaderConfig) { * - `node_modules/babel-loader/lib/index.js` as `loader` within module.rules * * @param {Object} options - * @param {import('webpack').Configuration} options.config - webpack config + * @param {Configuration} options.config - webpack config */ function overrideDefaultBabelLoader(options) { const { config } = options; config.module = config.module ?? {}; config.module.rules = config.module.rules ?? []; - const loader = getBabelLoader(/** @type {import('webpack').RuleSetRule[]}*/ (config.module.rules)); + const loader = getBabelLoader(/** @type {RuleSetRule[]}*/ (config.module.rules)); processBabelLoaderOptions(loader.options); - function getBabelLoader(/** @type {import('webpack').RuleSetRule[]} */ rules) { + function getBabelLoader(/** @type {RuleSetRule[]} */ rules) { // eslint-disable-next-line no-shadow const ruleIdx = rules.findIndex(rule => { return String(rule.test) === '/\\.(mjs|tsx?|jsx?)$/'; }); - const rule = /** @type {import("webpack").RuleSetRule}*/ (rules[ruleIdx]); + const rule = /** @type {RuleSetRule}*/ (rules[ruleIdx]); if (!Array.isArray(rule.use)) { throw new Error('storybook webpack rules changed'); diff --git a/scripts/triage-bot/src/triage-bot.js b/scripts/triage-bot/src/triage-bot.js index bed30f62a536e..1f6c87ba0196c 100644 --- a/scripts/triage-bot/src/triage-bot.js +++ b/scripts/triage-bot/src/triage-bot.js @@ -1,4 +1,4 @@ -/** @typedef {import('./types').Api} Api */ +/** @import { Api } from "./types"; */ /** * diff --git a/scripts/webpack/src/webpack-resources.js b/scripts/webpack/src/webpack-resources.js index f166764b04af1..c73e01ef823e1 100644 --- a/scripts/webpack/src/webpack-resources.js +++ b/scripts/webpack/src/webpack-resources.js @@ -1,19 +1,21 @@ +/** @import { Configuration, WebpackPluginInstance, ModuleOptions } from "webpack" */ + /** - * @typedef {import("webpack").Configuration} WebpackConfig - * @typedef {WebpackConfig & { devServer?: object }} WebpackServeConfig - * @typedef {import("webpack").ModuleOptions} WebpackModule - * @typedef {import("webpack").Configuration['output']} WebpackOutput + * @typedef {Configuration & { devServer?: object }} WebpackServeConfig + * @typedef {Configuration['output']} WebpackOutput */ -const webpack = require('webpack'); -const path = require('path'); const fs = require('fs'); +const path = require('path'); + const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); +const webpack = require('webpack'); + // @ts-ignore - accessing package.json is a private API access, thus ignoring TS here const webpackVersion = /** @type {string} */ (require('webpack/package.json').version); - const { merge } = require('@fluentui/scripts-utils'); const { getDefaultEnvironmentVars, findGitRoot } = require('@fluentui/scripts-monorepo'); + const { getResolveAlias } = require('./getResolveAlias'); console.log(`Webpack version: ${webpackVersion}`); @@ -47,16 +49,16 @@ const api = { * @param {string} bundleName - Name for the bundle file. Usually either the unscoped name, or * the scoped name with a - instead of / between the parts. * @param {boolean} isProduction - whether it's a production build. - * @param {Partial} customConfig - partial custom webpack config, merged into each full config object. + * @param {Partial} customConfig - partial custom webpack config, merged into each full config object. * @param {boolean} [onlyProduction] - whether to only generate the production config. * @param {boolean} [excludeSourceMaps] - whether to skip generating source maps. * @param {boolean} [profile] - whether to profile the bundle using webpack-bundle-analyzer. - * @returns {WebpackConfig[]} array of configs. + * @returns {Configuration[]} array of configs. */ createConfig(bundleName, isProduction, customConfig, onlyProduction, excludeSourceMaps, profile) { const packageName = path.basename(process.cwd()); - /** @type {WebpackModule} */ + /** @type {ModuleOptions} */ const module = { noParse: [/autoit.js/], rules: excludeSourceMaps @@ -137,8 +139,8 @@ const api = { * @param {string} [options.entry] - custom entry if not `./lib/index.js` * @param {boolean} [options.isProduction] - whether it's a production build. * @param {boolean} [options.onlyProduction] - whether to generate the production config. - * @param {Partial} [options.customConfig] - partial custom webpack config, merged into each full config object - * @returns {WebpackConfig[]} + * @param {Partial} [options.customConfig] - partial custom webpack config, merged into each full config object + * @returns {Configuration[]} */ createBundleConfig(options) { const { @@ -325,7 +327,7 @@ module.exports = api; */ function getPlugins(bundleName, isProduction, profile) { const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; - /** @type {webpack.WebpackPluginInstance[]} */ + /** @type {WebpackPluginInstance[]} */ const plugins = [new webpack.DefinePlugin(getDefaultEnvironmentVars(isProduction))]; if (isProduction && profile) {