@bedrockio/eslint-plugin 1.5.2 → 1.5.3

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.
@@ -4,8 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _typescriptEslint = _interopRequireDefault(require("typescript-eslint"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
8
+ let ts;
9
+ let importError;
10
+ try {
11
+ ts = (await Promise.resolve().then(() => _interopRequireWildcard(require('typescript-eslint')))).default;
12
+ } catch (err) {
13
+ importError = err;
14
+ }
9
15
  var _default = exports.default = {
10
16
  name: 'typescript',
11
17
  files: ['**/*.{ts,tsx}'],
@@ -13,18 +19,25 @@ var _default = exports.default = {
13
19
  languageOptions: {
14
20
  ecmaVersion: 'latest',
15
21
  sourceType: 'module',
16
- parser: _typescriptEslint.default.parser
22
+ parser: ts?.parser
17
23
  },
18
- plugins: {
19
- '@typescript-eslint': _typescriptEslint.default.plugin
24
+ // Throw error if import failed only if
25
+ // plugin is actually being used.
26
+ get plugins() {
27
+ if (importError) {
28
+ throw importError;
29
+ }
30
+ return {
31
+ '@typescript-eslint': ts.plugin
32
+ };
20
33
  },
21
34
  rules: {
22
35
  // Pull in `eslint-recommended` adjustments from typescript-eslint.
23
36
  // This disables core ESLint rules that conflict with TypeScript (e.g. no-undef).
24
- ..._typescriptEslint.default.plugin.configs['eslint-recommended'].overrides[0].rules,
37
+ ...ts?.plugin.configs['eslint-recommended'].overrides[0].rules,
25
38
  // Pull in the TypeScript recommended rules themselves.
26
39
  // Avoid the flat config version as it's an array.
27
- ..._typescriptEslint.default.plugin.configs.recommended.rules,
40
+ ...ts?.plugin.configs.recommended.rules,
28
41
  '@typescript-eslint/no-unused-vars': 'warn',
29
42
  '@typescript-eslint/no-explicit-any': 'off',
30
43
  // The above configs try to slip this rule in there despite it
@@ -1,4 +1,10 @@
1
- import ts from 'typescript-eslint';
1
+ let ts;
2
+ let importError;
3
+ try {
4
+ ts = (await import('typescript-eslint')).default;
5
+ } catch (err) {
6
+ importError = err;
7
+ }
2
8
  export default {
3
9
  name: 'typescript',
4
10
  files: ['**/*.{ts,tsx}'],
@@ -6,18 +12,25 @@ export default {
6
12
  languageOptions: {
7
13
  ecmaVersion: 'latest',
8
14
  sourceType: 'module',
9
- parser: ts.parser
15
+ parser: ts?.parser
10
16
  },
11
- plugins: {
12
- '@typescript-eslint': ts.plugin
17
+ // Throw error if import failed only if
18
+ // plugin is actually being used.
19
+ get plugins() {
20
+ if (importError) {
21
+ throw importError;
22
+ }
23
+ return {
24
+ '@typescript-eslint': ts.plugin
25
+ };
13
26
  },
14
27
  rules: {
15
28
  // Pull in `eslint-recommended` adjustments from typescript-eslint.
16
29
  // This disables core ESLint rules that conflict with TypeScript (e.g. no-undef).
17
- ...ts.plugin.configs['eslint-recommended'].overrides[0].rules,
30
+ ...ts?.plugin.configs['eslint-recommended'].overrides[0].rules,
18
31
  // Pull in the TypeScript recommended rules themselves.
19
32
  // Avoid the flat config version as it's an array.
20
- ...ts.plugin.configs.recommended.rules,
33
+ ...ts?.plugin.configs.recommended.rules,
21
34
  '@typescript-eslint/no-unused-vars': 'warn',
22
35
  '@typescript-eslint/no-explicit-any': 'off',
23
36
  // The above configs try to slip this rule in there despite it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/eslint-plugin",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "description": "Common ESLint plugin for Bedrock projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/typescript.js CHANGED
@@ -1,4 +1,11 @@
1
- import ts from 'typescript-eslint';
1
+ let ts;
2
+ let importError;
3
+
4
+ try {
5
+ ts = (await import('typescript-eslint')).default;
6
+ } catch (err) {
7
+ importError = err;
8
+ }
2
9
 
3
10
  export default {
4
11
  name: 'typescript',
@@ -7,19 +14,28 @@ export default {
7
14
  languageOptions: {
8
15
  ecmaVersion: 'latest',
9
16
  sourceType: 'module',
10
- parser: ts.parser,
17
+ parser: ts?.parser,
11
18
  },
12
- plugins: {
13
- '@typescript-eslint': ts.plugin,
19
+
20
+ // Throw error if import failed only if
21
+ // plugin is actually being used.
22
+ get plugins() {
23
+ if (importError) {
24
+ throw importError;
25
+ }
26
+ return {
27
+ '@typescript-eslint': ts.plugin,
28
+ };
14
29
  },
30
+
15
31
  rules: {
16
32
  // Pull in `eslint-recommended` adjustments from typescript-eslint.
17
33
  // This disables core ESLint rules that conflict with TypeScript (e.g. no-undef).
18
- ...ts.plugin.configs['eslint-recommended'].overrides[0].rules,
34
+ ...ts?.plugin.configs['eslint-recommended'].overrides[0].rules,
19
35
 
20
36
  // Pull in the TypeScript recommended rules themselves.
21
37
  // Avoid the flat config version as it's an array.
22
- ...ts.plugin.configs.recommended.rules,
38
+ ...ts?.plugin.configs.recommended.rules,
23
39
  '@typescript-eslint/no-unused-vars': 'warn',
24
40
  '@typescript-eslint/no-explicit-any': 'off',
25
41