weboptimizer 2.0.1491 → 2.0.1492

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/browser.js CHANGED
@@ -91,9 +91,9 @@ if (typeof TARGET_TECHNOLOGY === 'undefined' || TARGET_TECHNOLOGY === 'node')
91
91
  browser.initialized = true;
92
92
  browser.instance = new browser.DOM(template, {
93
93
  beforeParse: function beforeParse(window) {
94
- var _global$window;
94
+ var _ref2;
95
95
  // We want to use it in a polymorphic way.
96
- browser.window = (_global$window = global.window) !== null && _global$window !== void 0 ? _global$window : window;
96
+ browser.window = (_ref2 = global.window) !== null && _ref2 !== void 0 ? _ref2 : window;
97
97
  window.document.addEventListener('DOMContentLoaded', function () {
98
98
  /*
99
99
  Move template results into global
@@ -186,7 +186,9 @@ if (typeof TARGET_TECHNOLOGY === 'undefined' || TARGET_TECHNOLOGY === 'node')
186
186
  return _context.stop();
187
187
  }
188
188
  }, _callee);
189
- }))()["catch"](console.error);else {
189
+ }))()["catch"](function (error) {
190
+ console.error(error);
191
+ });else {
190
192
  browser.initialized = true;
191
193
  browser.window = window;
192
194
  window.document.addEventListener('DOMContentLoaded', function () {
@@ -218,7 +220,7 @@ if (typeof TARGET_TECHNOLOGY === 'undefined' || TARGET_TECHNOLOGY === 'node')
218
220
  * @returns Determined environment.
219
221
  */
220
222
  var getInitializedBrowser = exports.getInitializedBrowser = /*#__PURE__*/function () {
221
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
223
+ var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
222
224
  var replaceWindow,
223
225
  resolvePromise,
224
226
  promise,
@@ -248,7 +250,7 @@ var getInitializedBrowser = exports.getInitializedBrowser = /*#__PURE__*/functio
248
250
  }, _callee2);
249
251
  }));
250
252
  return function getInitializedBrowser() {
251
- return _ref2.apply(this, arguments);
253
+ return _ref3.apply(this, arguments);
252
254
  };
253
255
  }();
254
256
  var _default = exports["default"] = getInitializedBrowser;
package/configurator.js CHANGED
@@ -28,7 +28,7 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
28
28
  var _clientnode = require("clientnode");
29
29
  var _fs = _interopRequireWildcard(require("fs"));
30
30
  var _path2 = _interopRequireWildcard(require("path"));
31
- var _helper = _interopRequireDefault(require("./helper"));
31
+ var _helper = require("./helper");
32
32
  var _package = _interopRequireWildcard(require("./package.json"));
33
33
  var _type4 = require("./type");
34
34
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -55,7 +55,7 @@ var load = exports.load = function load(context) {
55
55
  var commandLineArguments = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : process.argv;
56
56
  var webOptimizerPath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : __dirname;
57
57
  var environment = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : eval('process.env');
58
- return function (_specificConfiguratio, _specificConfiguratio2, _specificConfiguratio3) {
58
+ return function (_specificConfiguratio, _specificConfiguratio2) {
59
59
  // region determine application context location
60
60
  if (context) _package.configuration["default"].path.context = context;else {
61
61
  /*
@@ -65,7 +65,7 @@ var load = exports.load = function load(context) {
65
65
  directory and this library is located as a nested dependency.
66
66
  */
67
67
  _package.configuration["default"].path.context = webOptimizerPath;
68
- while (true) {
68
+ for (var level = 0; level < _clientnode.MAXIMAL_NUMBER_OF_ITERATIONS.value; level++) {
69
69
  _package.configuration["default"].path.context = (0, _path2.resolve)(_package.configuration["default"].path.context, '../../');
70
70
  if ((0, _path2.basename)((0, _path2.dirname)(_package.configuration["default"].path.context)) !== 'node_modules') break;
71
71
  }
@@ -93,6 +93,7 @@ var load = exports.load = function load(context) {
93
93
  // region load application specific configuration
94
94
  var specificConfiguration = {};
95
95
  try {
96
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
96
97
  specificConfiguration = (0, _clientnode.currentRequire)((0, _path2.join)(_package.configuration["default"].path.context, 'package'));
97
98
  } catch (_unused2) {
98
99
  _package.configuration["default"].path.context = currentWorkingDirectory;
@@ -119,14 +120,14 @@ var load = exports.load = function load(context) {
119
120
  if (debug) configuration = (0, _clientnode.extend)(true, (0, _clientnode.modifyObject)(_package.configuration["default"], _package.configuration.debug), _package.configuration.debug);else configuration = _package.configuration["default"];
120
121
  configuration.debug = debug;
121
122
  if ((0, _typeof2["default"])(configuration.library) === 'object') (0, _clientnode.extend)(true, (0, _clientnode.modifyObject)(libraryConfiguration, configuration.library), configuration.library);
122
- if (configuration.library && ((_specificConfiguratio3 = specificConfiguration) === null || _specificConfiguratio3 === void 0 ? void 0 : _specificConfiguratio3.library) !== false) configuration = (0, _clientnode.extend)(true, (0, _clientnode.modifyObject)(configuration, libraryConfiguration), libraryConfiguration);
123
+ if (configuration.library && specificConfiguration.library !== false) configuration = (0, _clientnode.extend)(true, (0, _clientnode.modifyObject)(configuration, libraryConfiguration), libraryConfiguration);
123
124
  // endregion
124
125
  // region merging and evaluating task specific and dynamic configurations
125
126
  /// region load additional dynamically given configuration
126
127
  var count = 0;
127
128
  var filePath = null;
128
- while (true) {
129
- var newFilePath = "".concat(configuration.path.context, ".dynamicConfiguration-").concat(count, ".json");
129
+ for (var index = 0; index < _clientnode.MAXIMAL_NUMBER_OF_ITERATIONS.value; index++) {
130
+ var newFilePath = "".concat(configuration.path.context, ".dynamicConfiguration-") + "".concat(String(count), ".json");
130
131
  if (!(0, _clientnode.isFileSync)(newFilePath)) break;
131
132
  filePath = newFilePath;
132
133
  count += 1;
@@ -239,7 +240,6 @@ var load = exports.load = function load(context) {
239
240
  var resolvedConfiguration = (0, _clientnode.evaluateDynamicData)(configuration, _objectSpread(_objectSpread({}, _clientnode.UTILITY_SCOPE), {}, {
240
241
  currentPath: currentWorkingDirectory,
241
242
  fs: _fs["default"],
242
- Helper: _helper["default"],
243
243
  packageConfiguration: _package["default"],
244
244
  optionalRequire: _clientnode.optionalRequire,
245
245
  path: _path2["default"],
@@ -266,10 +266,10 @@ var load = exports.load = function load(context) {
266
266
  }
267
267
  // endregion
268
268
  // region resolve module location and which asset types are needed
269
- resolvedConfiguration.module.locations = _helper["default"].determineModuleLocations(resolvedConfiguration.injection.entry.normalized, resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, {
269
+ resolvedConfiguration.module.locations = (0, _helper.determineModuleLocations)(resolvedConfiguration.injection.entry.normalized, resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, {
270
270
  file: resolvedConfiguration.extensions.file.internal
271
271
  }, resolvedConfiguration.path.context, resolvedConfiguration.path.source.asset.base);
272
- resolvedConfiguration.injection = _helper["default"].resolveAutoInjection(resolvedConfiguration.injection, _helper["default"].resolveBuildConfigurationFilePaths(resolvedConfiguration.buildContext.types, resolvedConfiguration.path.source.asset.base, _helper["default"].normalizePaths(resolvedConfiguration.path.ignore.concat(resolvedConfiguration.module.directoryNames, resolvedConfiguration.loader.directoryNames).map(function (filePath) {
272
+ resolvedConfiguration.injection = (0, _helper.resolveAutoInjection)(resolvedConfiguration.injection, (0, _helper.resolveBuildConfigurationFilePaths)(resolvedConfiguration.buildContext.types, resolvedConfiguration.path.source.asset.base, (0, _helper.normalizePaths)(resolvedConfiguration.path.ignore.concat(resolvedConfiguration.module.directoryNames, resolvedConfiguration.loader.directoryNames).map(function (filePath) {
273
273
  return (0, _path2.resolve)(resolvedConfiguration.path.context, filePath);
274
274
  }).filter(function (filePath) {
275
275
  return !resolvedConfiguration.path.context.startsWith(filePath);
@@ -277,7 +277,7 @@ var load = exports.load = function load(context) {
277
277
  var givenInjection = resolvedConfiguration.injection.entry;
278
278
  resolvedConfiguration.injection.entry = {
279
279
  given: givenInjection,
280
- normalized: _helper["default"].resolveModulesInFolders(_helper["default"].normalizeGivenInjection(givenInjection), resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, resolvedConfiguration.path.context, resolvedConfiguration.path.source.asset.base, resolvedConfiguration.path.ignore.concat(resolvedConfiguration.module.directoryNames, resolvedConfiguration.loader.directoryNames).map(function (filePath) {
280
+ normalized: (0, _helper.resolveModulesInFolders)((0, _helper.normalizeGivenInjection)(givenInjection), resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, resolvedConfiguration.path.context, resolvedConfiguration.path.source.asset.base, resolvedConfiguration.path.ignore.concat(resolvedConfiguration.module.directoryNames, resolvedConfiguration.loader.directoryNames).map(function (filePath) {
281
281
  return (0, _path2.resolve)(resolvedConfiguration.path.context, filePath);
282
282
  }).filter(function (filePath) {
283
283
  return !resolvedConfiguration.path.context.startsWith(filePath);
@@ -295,7 +295,7 @@ var load = exports.load = function load(context) {
295
295
  try {
296
296
  for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
297
297
  var moduleID = _step4.value;
298
- var _filePath = _helper["default"].determineModuleFilePath(moduleID, resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, {
298
+ var _filePath = (0, _helper.determineModuleFilePath)(moduleID, resolvedConfiguration.module.aliases, resolvedConfiguration.module.replacements.normal, {
299
299
  file: resolvedConfiguration.extensions.file.internal
300
300
  }, resolvedConfiguration.path.context,
301
301
  /*
@@ -305,7 +305,7 @@ var load = exports.load = function load(context) {
305
305
  */
306
306
  '', resolvedConfiguration.path.ignore, resolvedConfiguration.module.directoryNames, resolvedConfiguration["package"].main.fileNames, resolvedConfiguration["package"].main.propertyNames, resolvedConfiguration["package"].aliasPropertyNames, resolvedConfiguration.encoding);
307
307
  var _type2 = null;
308
- if (_filePath) _type2 = _helper["default"].determineAssetType(_filePath, resolvedConfiguration.buildContext.types, resolvedConfiguration.path);else throw new Error("Given request \"".concat(moduleID, "\" couldn't be resolved."));
308
+ if (_filePath) _type2 = (0, _helper.determineAssetType)(_filePath, resolvedConfiguration.buildContext.types, resolvedConfiguration.path);else throw new Error("Given request \"".concat(moduleID, "\" couldn't be resolved."));
309
309
  if (_type2) resolvedConfiguration.needed[_type2] = true;
310
310
  }
311
311
  } catch (err) {
package/declarations.d.ts CHANGED
@@ -3,11 +3,11 @@
3
3
  NOTE: We have to avoid importing this from "clientnode/type" to avoid a
4
4
  dependency cycle.
5
5
  */
6
- type Mapping<T = string> = {[key:string]:T}
6
+ type Mapping<T = string> = Record<string, T>
7
7
 
8
8
  interface PostcssTransformer {
9
- postcssPlugin: string
10
- postcssVersion: string
9
+ postcssPlugin:string
10
+ postcssVersion:string
11
11
 
12
12
  (root:object, result:object):Promise<void>|void
13
13
  }
@@ -74,7 +74,3 @@ declare module '*.module.styl' {
74
74
  const classes:Mapping
75
75
  export default classes
76
76
  }
77
- // region vim modline
78
- // vim: set tabstop=4 shiftwidth=4 expandtab:
79
- // vim: foldmethod=marker foldmarker=region,endregion:
80
- // endregion
package/ejsLoader.d.ts CHANGED
@@ -21,7 +21,7 @@ export type LoaderConfiguration = Mapping<unknown> & {
21
21
  extensions: Extensions;
22
22
  locals?: Mapping<unknown>;
23
23
  module: {
24
- aliases: Mapping<string>;
24
+ aliases: Mapping;
25
25
  replacements: Replacements;
26
26
  };
27
27
  };
package/ejsLoader.js CHANGED
@@ -32,7 +32,7 @@ var _fs = require("fs");
32
32
  var _htmlMinifier = require("html-minifier");
33
33
  var _path = require("path");
34
34
  var _configurator = _interopRequireDefault(require("./configurator"));
35
- var _helper = _interopRequireDefault(require("./helper"));
35
+ var _helper = require("./helper");
36
36
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
37
37
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
38
38
  // endregion
@@ -46,8 +46,8 @@ var configuration = (0, _configurator["default"])();
46
46
  * @returns Transformed string.
47
47
  */
48
48
  var loader = exports.loader = function loader(source) {
49
- var _ref,
50
- _this = this;
49
+ var _this = this,
50
+ _givenOptions$compile;
51
51
  var givenOptions = (0, _clientnode.convertSubstringInPlainObject)((0, _clientnode.extend)(true, {
52
52
  compiler: {},
53
53
  compileSteps: 2,
@@ -67,8 +67,8 @@ var loader = exports.loader = function loader(source) {
67
67
  aliases: {},
68
68
  replacements: {}
69
69
  }
70
- }, 'getOptions' in this && this.getOptions() ? this.getOptions() : (_ref = this.query) !== null && _ref !== void 0 ? _ref : {}), /#%%%#/g, '!');
71
- var compile = function compile(template) {
70
+ }, this.getOptions()), /#%%%#/g, '!');
71
+ var _compile = function compile(template) {
72
72
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : givenOptions.compiler;
73
73
  var compileSteps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 2;
74
74
  return function () {
@@ -78,12 +78,13 @@ var loader = exports.loader = function loader(source) {
78
78
  }, options);
79
79
  var givenLocals = [].concat(locals);
80
80
  var require = function require(request) {
81
+ var _options, _givenOptions$module, _givenOptions$module2, _givenOptions$extensi;
81
82
  var nestedLocals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
82
83
  var template = request.replace(/^(.+)\?[^?]+$/, '$1');
83
84
  var queryMatch = /^[^?]+\?(.+)$/.exec(request);
84
85
  if (queryMatch) {
85
86
  var evaluated = (0, _clientnode.evaluate)(queryMatch[1], {
86
- compile: compile,
87
+ compile: _compile,
87
88
  locals: locals,
88
89
  request: request,
89
90
  source: source,
@@ -95,10 +96,10 @@ var loader = exports.loader = function loader(source) {
95
96
  delete nestedOptions.client;
96
97
  nestedOptions = (0, _clientnode.extend)(true, {
97
98
  encoding: configuration.encoding
98
- }, nestedOptions, nestedLocals.options || {}, options);
99
- if (nestedOptions.isString) return compile(template, nestedOptions)(nestedLocals);
100
- var templateFilePath = _helper["default"].determineModuleFilePath(template, givenOptions.module.aliases, givenOptions.module.replacements, {
101
- file: givenOptions.extensions.file.internal
99
+ }, nestedOptions, nestedLocals.options || {}, (_options = options) !== null && _options !== void 0 ? _options : {});
100
+ if (nestedOptions.isString) return _compile(template, nestedOptions)(nestedLocals);
101
+ var templateFilePath = (0, _helper.determineModuleFilePath)(template, (_givenOptions$module = givenOptions.module) === null || _givenOptions$module === void 0 ? void 0 : _givenOptions$module.aliases, (_givenOptions$module2 = givenOptions.module) === null || _givenOptions$module2 === void 0 ? void 0 : _givenOptions$module2.replacements, {
102
+ file: ((_givenOptions$extensi = givenOptions.extensions) === null || _givenOptions$extensi === void 0 ? void 0 : _givenOptions$extensi.file.internal) || []
102
103
  }, givenOptions.context, configuration.path.source.asset.base, configuration.path.ignore, configuration.module.directoryNames, configuration["package"].main.fileNames, configuration["package"].main.propertyNames, configuration["package"].aliasPropertyNames, configuration.encoding);
103
104
  if (templateFilePath) {
104
105
  if ('addDependency' in _this) _this.addDependency(templateFilePath);
@@ -107,7 +108,7 @@ var loader = exports.loader = function loader(source) {
107
108
  file doesn't seem to be an ejs template we simply load
108
109
  included file content.
109
110
  */
110
- if (queryMatch || templateFilePath.endsWith('.ejs')) return compile(templateFilePath, nestedOptions)(nestedLocals);
111
+ if (queryMatch || templateFilePath.endsWith('.ejs')) return _compile(templateFilePath, nestedOptions)(nestedLocals);
111
112
  return (0, _fs.readFileSync)(templateFilePath, {
112
113
  encoding: nestedOptions.encoding
113
114
  });
@@ -137,15 +138,15 @@ var loader = exports.loader = function loader(source) {
137
138
  */
138
139
  trimCustomFragments: true,
139
140
  useShortDoctype: true
140
- }, givenOptions.compress.html || {})) : content;
141
+ }, givenOptions.compress.html)) : content;
141
142
  };
142
143
  var result = template;
143
144
  var isString = Boolean(options.isString);
144
145
  delete options.isString;
145
146
  var stepLocals;
146
- var scope;
147
- var originalScopeNames;
148
- var scopeNames;
147
+ var scope = {};
148
+ var originalScopeNames = [];
149
+ var scopeNames = [];
149
150
  for (var step = 1; step <= compileSteps; step += 1) {
150
151
  // On every odd compile step we have to determine the environment.
151
152
  if (step % 2) {
@@ -155,7 +156,6 @@ var loader = exports.loader = function loader(source) {
155
156
  scope = {};
156
157
  if (step < 3 && 1 < compileSteps) scope = _objectSpread(_objectSpread({}, _clientnode.UTILITY_SCOPE), {}, {
157
158
  configuration: configuration,
158
- Helper: _helper["default"],
159
159
  include: require,
160
160
  require: require
161
161
  }, Array.isArray(stepLocals) ? {} : stepLocals);else if (!Array.isArray(stepLocals)) scope = stepLocals;
@@ -167,7 +167,7 @@ var loader = exports.loader = function loader(source) {
167
167
  }
168
168
  if (typeof result === 'string') {
169
169
  var filePath = isString ? options.filename : result;
170
- if (filePath && (0, _path.extname)(filePath) === '.js') result = (0, _clientnode.currentRequire)(filePath);else {
170
+ if (filePath && (0, _path.extname)(filePath) === '.js' && _clientnode.currentRequire) result = (0, _clientnode.currentRequire)(filePath);else {
171
171
  if (!isString) {
172
172
  var encoding = configuration.encoding;
173
173
  if (typeof options.encoding === 'string') encoding = options.encoding;
@@ -199,15 +199,16 @@ var loader = exports.loader = function loader(source) {
199
199
  }).concat(!options.strict && options._with ? [] : scope))));
200
200
  }
201
201
  if (compileSteps % 2) {
202
+ var _givenOptions$compres2, _givenOptions$compres3, _givenOptions$compres4, _givenOptions$compres5;
202
203
  var code = "module.exports = ".concat(result.toString());
203
204
  var processed = (0, _core.transformSync)(code, {
204
205
  ast: false,
205
206
  babelrc: false,
206
- comments: !givenOptions.compress.javaScript,
207
- compact: Boolean(givenOptions.compress.javaScript),
207
+ comments: !((_givenOptions$compres2 = givenOptions.compress) !== null && _givenOptions$compres2 !== void 0 && _givenOptions$compres2.javaScript),
208
+ compact: Boolean((_givenOptions$compres3 = givenOptions.compress) === null || _givenOptions$compres3 === void 0 ? void 0 : _givenOptions$compres3.javaScript),
208
209
  filename: options.filename || 'unknown',
209
- minified: Boolean(givenOptions.compress.javaScript),
210
- presets: givenOptions.compress.javaScript ? [[_babelPresetMinify["default"], givenOptions.compress.javaScript]] : [],
210
+ minified: Boolean((_givenOptions$compres4 = givenOptions.compress) === null || _givenOptions$compres4 === void 0 ? void 0 : _givenOptions$compres4.javaScript),
211
+ presets: (_givenOptions$compres5 = givenOptions.compress) !== null && _givenOptions$compres5 !== void 0 && _givenOptions$compres5.javaScript ? [[_babelPresetMinify["default"], givenOptions.compress.javaScript]] : [],
211
212
  sourceMaps: false,
212
213
  sourceType: 'script'
213
214
  });
@@ -221,8 +222,8 @@ var loader = exports.loader = function loader(source) {
221
222
  return '';
222
223
  };
223
224
  };
224
- return compile(source, _objectSpread(_objectSpread({}, givenOptions.compiler), {}, {
225
- client: Boolean(givenOptions.compileSteps % 2),
225
+ return _compile(source, _objectSpread(_objectSpread({}, givenOptions.compiler), {}, {
226
+ client: Boolean(((_givenOptions$compile = givenOptions.compileSteps) !== null && _givenOptions$compile !== void 0 ? _givenOptions$compile : 2) % 2),
226
227
  compileDebug: givenOptions.debug,
227
228
  debug: givenOptions.debug,
228
229
  filename: this.resourcePath || 'unknown',
@@ -4,5 +4,5 @@
4
4
  * @returns A promise holding a boolean which indicates directory existence.
5
5
  */
6
6
  export declare const isFile: (filePath: string) => Promise<boolean>;
7
- declare const _default: any[];
8
- export default _default;
7
+ export declare const config: import("@typescript-eslint/utils/dist/ts-eslint").FlatConfig.ConfigArray;
8
+ export default config;
package/eslint.config.mjs CHANGED
@@ -1,6 +1,7 @@
1
- import js from '@eslint/js';
2
- import typescriptPlugin from '@typescript-eslint/eslint-plugin';
1
+ import eslintjs from '@eslint/js';
2
+ import typescriptPlugin from '@stylistic/eslint-plugin-ts';
3
3
  import typescriptParser from '@typescript-eslint/parser';
4
+ import tseslint from 'typescript-eslint';
4
5
  import google from 'eslint-config-google';
5
6
  import jsdoc from 'eslint-plugin-jsdoc';
6
7
  import { readFile, stat } from 'fs/promises';
@@ -30,14 +31,15 @@ const googleRules = Object.keys(google.rules).filter(key => !unsuportedRules.inc
30
31
  }), {});
31
32
  const libraryIndicator = JSON.parse(await readFile(resolve(cwd(), './package.json'), {
32
33
  encoding: 'utf-8'
33
- })).default?.webOptimizer?.library;
34
+ })).webOptimizer?.library;
34
35
  const isLibrary = libraryIndicator ?? true;
35
36
  let tsConfigFilePath = '';
36
37
  for (const filePath of ['./tsconfig.json', './node_modules/weboptimizer/tsconfig.' + `${isLibrary ? 'library' : 'application'}.json`]) if (await isFile(filePath)) {
37
38
  tsConfigFilePath = filePath;
38
39
  break;
39
40
  }
40
- export default [js.configs.recommended, ...typescript.configs.recommended, jsdoc.configs['flat/recommended'], {
41
+ export const config = tseslint.config({
42
+ extends: [eslintjs.configs.recommended, ...typescript.configs.strictTypeChecked, ...tseslint.configs.strict, ...tseslint.configs.stylistic, jsdoc.configs['flat/recommended']],
41
43
  files: ['**/*.{ts,tsx,html}'],
42
44
  languageOptions: {
43
45
  ecmaVersion: 'latest',
@@ -56,23 +58,15 @@ export default [js.configs.recommended, ...typescript.configs.recommended, jsdoc
56
58
  },
57
59
  sourceType: 'module'
58
60
  },
59
- ignores: ['*.compiled.*', '*.js', '**/*.js', '**/.git/**/*', '**/.cache/**/*', '**/.config/**/*', '**/.npm/**/*', '**/log/**/*', '**/node_modules/**/*', '**/backup/**/*', '**/exclude/**/*', '**/plugins/**/*', '*.d.ts', '**/*.d.ts'],
60
61
  plugins: {
61
- jsdoc
62
+ jsdoc,
63
+ '@stylistic': typescriptPlugin
62
64
  },
63
65
  rules: {
64
66
  ...googleRules,
65
- ...typescriptPlugin.configs.recommended.rules,
66
- '@typescript-eslint/no-implied-eval': 'error',
67
- '@typescript-eslint/no-non-null-assertion': 'off',
68
- '@typescript-eslint/no-this-alias': ['error', {
69
- allowedNames: ['self']
70
- }],
71
- '@typescript-eslint/no-unused-vars': ['error', {
72
- argsIgnorePattern: '^_',
73
- varsIgnorePattern: '^_'
74
- }],
75
- '@typescript-eslint/type-annotation-spacing': ['error', {
67
+ '@/no-implied-eval': 'error',
68
+ '@stylistic/no-non-null-assertion': 'off',
69
+ '@stylistic/type-annotation-spacing': ['error', {
76
70
  after: false,
77
71
  before: false,
78
72
  overrides: {
@@ -82,6 +76,25 @@ export default [js.configs.recommended, ...typescript.configs.recommended, jsdoc
82
76
  }
83
77
  }
84
78
  }],
79
+ '@typescript-eslint/array-type': ['error', {
80
+ default: 'generic'
81
+ }],
82
+ '@typescript-eslint/no-dynamic-delete': 'off',
83
+ '@typescript-eslint/no-this-alias': ['error', {
84
+ allowedNames: ['self']
85
+ }],
86
+ '@typescript-eslint/no-unused-vars': ['error', {
87
+ vars: 'all',
88
+ varsIgnorePattern: '^_',
89
+ args: 'after-used',
90
+ caughtErrors: 'all',
91
+ caughtErrorsIgnorePattern: '^_',
92
+ ignoreRestSiblings: false,
93
+ reportUsedIgnorePattern: false
94
+ }],
95
+ // NOTE: Too strcit for now but could be actvated in future maybe.
96
+ '@typescript-eslint/no-unsafe-member-access': 'off',
97
+ '@typescript-eslint/no-unsafe-assignment': 'off',
85
98
  'jsdoc/check-param-names': 'error',
86
99
  'jsdoc/check-tag-names': 'error',
87
100
  'jsdoc/require-description-complete-sentence': 'error',
@@ -130,4 +143,12 @@ export default [js.configs.recommended, ...typescript.configs.recommended, jsdoc
130
143
  }],
131
144
  'space-infix-ops': 'off'
132
145
  }
133
- }];
146
+ },
147
+ // NOTE: Ignores has te be applied via a dedicated object to influence all
148
+ // given configuration objects.
149
+ {
150
+ ignores: ['*.compiled.*', '*.js', '**/*.js', '**/.git/**/*', '**/.cache/**/*', '**/.config/**/*', '**/.npm/**/*', '**/log/**/*', '**/node_modules/**/*', '**/backup/**/*', '**/exclude/**/*', '**/*.d.ts', '!**/declarations.d.ts'
151
+ // '** /plugins/** /*'
152
+ ]
153
+ });
154
+ export default config;