@origin-1/eslint-config 0.2.0 → 0.4.0

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/index.js CHANGED
@@ -1,3 +1,22 @@
1
- 'use strict';
2
-
3
- module.exports = require('./lib/create-config');
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ const patch_tslib_js_1 = __importDefault(require("./patch-tslib.js"));
21
+ (0, patch_tslib_js_1.default)(require);
22
+ __exportStar(require("./lib/create-config.js"), exports);
@@ -2,6 +2,7 @@ import type { JSVersion } from './rules.js';
2
2
  import type { Linter } from 'eslint';
3
3
  export interface ConfigData extends Linter.HasRules {
4
4
  env?: Record<string, boolean> | undefined;
5
+ extends?: string | string[] | undefined;
5
6
  globals?: Record<string, boolean | 'readonly' | 'readable' | 'writable' | 'writeable'> | undefined;
6
7
  jsVersion?: JSVersion | undefined;
7
8
  parserOptions?: Linter.ParserOptions | undefined;
@@ -14,9 +14,11 @@ function createBaseConfig(configData) {
14
14
  const { env, parser, parserOptions, plugins: overridePlugins, rules: overrideRules } = createBaseOverride(configData);
15
15
  plugins.push(...overridePlugins);
16
16
  Object.assign(rules, overrideRules);
17
+ const { extends: extends_, globals } = configData;
17
18
  const baseConfig = {
18
19
  env,
19
- globals: configData.globals,
20
+ extends: extends_,
21
+ globals,
20
22
  parser,
21
23
  parserOptions,
22
24
  plugins,
@@ -145,8 +147,8 @@ function createConfig(...configDataList) {
145
147
  exports.createConfig = createConfig;
146
148
  function createOverride(configData) {
147
149
  const baseOverride = createBaseOverride(configData);
148
- const { excludedFiles, files, globals } = configData;
149
- const override = { ...baseOverride, excludedFiles, files, globals };
150
+ const { excludedFiles, extends: extends_, files, globals } = configData;
151
+ const override = { ...baseOverride, excludedFiles, extends: extends_, files, globals };
150
152
  return override;
151
153
  }
152
154
  function findRuleEntry(versionedList, jsVersion, tsVersion) {
package/lib/rules.js CHANGED
@@ -25,7 +25,6 @@ function jsts(jsEntry, tsEntry) {
25
25
  }
26
26
  exports.RULES = {
27
27
  [exports.UNIQUE]: {
28
- // Problem
29
28
  'array-callback-return': 'off',
30
29
  'constructor-super': 'error',
31
30
  'for-direction': 'error',
@@ -45,7 +44,6 @@ exports.RULES = {
45
44
  'no-dupe-else-if': 'error',
46
45
  'no-dupe-keys': 'error',
47
46
  'no-duplicate-case': 'error',
48
- // TypeScript has type only imports.
49
47
  'no-duplicate-imports': jsts('error', 'off'),
50
48
  'no-empty-character-class': 'error',
51
49
  'no-empty-pattern': 'error',
@@ -80,7 +78,6 @@ exports.RULES = {
80
78
  'require-atomic-updates': 'off',
81
79
  'use-isnan': ['error', { enforceForSwitchCase: true }],
82
80
  'valid-typeof': 'error',
83
- // Suggestion
84
81
  'accessor-pairs': ['error', { enforceForClassMembers: true }],
85
82
  'arrow-body-style': 'error',
86
83
  'block-scoped-var': 'off',
@@ -187,8 +184,6 @@ exports.RULES = {
187
184
  'prefer-arrow-callback': 'error',
188
185
  'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
189
186
  'prefer-destructuring': 'error',
190
- // Do not prefer the exponentiation operator in TypeScript, because that would result in
191
- // getting the value of Math.pow upon every evaluation in ES5 transpiled code.
192
187
  'prefer-exponentiation-operator': jsts('error', 'off'),
193
188
  'prefer-named-capture-group': 'off',
194
189
  'prefer-numeric-literals': 'error',
@@ -206,12 +201,11 @@ exports.RULES = {
206
201
  'sort-imports': ['error', { ignoreDeclarationSort: true }],
207
202
  'sort-keys': 'off',
208
203
  'sort-vars': 'off',
209
- 'spaced-comment': 'error',
204
+ 'spaced-comment': ['error', 'always', { exceptions: ['/'] }],
210
205
  'strict': jsts(['error', 'global'], 'off'),
211
206
  'symbol-description': 'off',
212
207
  'vars-on-top': 'off',
213
208
  'yoda': 'error',
214
- // Layout
215
209
  'array-bracket-newline': ['error', 'consistent'],
216
210
  'array-bracket-spacing': 'error',
217
211
  'array-element-newline': 'off',
@@ -230,7 +224,6 @@ exports.RULES = {
230
224
  'key-spacing': ['error', { mode: 'minimum' }],
231
225
  'line-comment-position': 'off',
232
226
  'linebreak-style': 'error',
233
- // In TypeScript files, lines-around-comment doesn't work well at the start of a block.
234
227
  'lines-around-comment': jsts(['error', { allowBlockStart: true, allowObjectStart: true }], 'off'),
235
228
  'max-len': ['error', { code: 100 }],
236
229
  'max-statements-per-line': 'error',
@@ -262,12 +255,10 @@ exports.RULES = {
262
255
  'yield-star-spacing': ['error', 'both'],
263
256
  },
264
257
  [exports.HYBRID]: {
265
- // Problem
266
258
  'no-dupe-class-members': 'error',
267
259
  'no-loss-of-precision': 'error',
268
260
  'no-unused-vars': jsts(beforeOrElse(2019, ['error', { ignoreRestSiblings: true, vars: 'local' }], ['error', { caughtErrors: 'all', ignoreRestSiblings: true, vars: 'local' }]), ['error', { caughtErrors: 'all', ignoreRestSiblings: true, vars: 'local' }]),
269
261
  'no-use-before-define': 'off',
270
- // Suggestion
271
262
  'default-param-last': 'off',
272
263
  'dot-notation': 'error',
273
264
  'init-declarations': 'off',
@@ -278,7 +269,6 @@ exports.RULES = {
278
269
  'no-invalid-this': 'off',
279
270
  'no-loop-func': 'error',
280
271
  'no-magic-numbers': 'off',
281
- // Redeclarations are acceptable in TypeScript.
282
272
  'no-redeclare': jsts(['error', { builtinGlobals: true }], 'off'),
283
273
  'no-restricted-imports': 'off',
284
274
  'no-shadow': 'off',
@@ -286,12 +276,10 @@ exports.RULES = {
286
276
  'no-unused-expressions': 'error',
287
277
  'no-useless-constructor': 'error',
288
278
  'require-await': 'error',
289
- // Layout
290
279
  'brace-style': ['error', 'allman'],
291
280
  'comma-dangle': ['error', 'always-multiline'],
292
281
  'comma-spacing': 'error',
293
282
  'func-call-spacing': 'off',
294
- // typescript-eslint rule is flawed.
295
283
  'indent': jsts([
296
284
  'error',
297
285
  4,
@@ -332,12 +320,10 @@ exports.RULES = {
332
320
  'semi': 'error',
333
321
  'space-before-blocks': 'error',
334
322
  'space-before-function-paren': 'off',
335
- // typescript-eslint rule does not handle well colons (":") in mapped types.
336
323
  'space-infix-ops': jsts('error', 'off'),
337
324
  },
338
325
  '@typescript-eslint/eslint-plugin': {
339
326
  [exports.FOR_LANG]: 'ts',
340
- // Problem
341
327
  'await-thenable': 'error',
342
328
  'ban-ts-comment': 'off',
343
329
  'class-literal-property-style': ['error', 'getters'],
@@ -371,7 +357,6 @@ exports.RULES = {
371
357
  'restrict-template-expressions': 'off',
372
358
  'return-await': 'error',
373
359
  'unbound-method': 'off',
374
- // Suggestion
375
360
  'adjacent-overload-signatures': 'error',
376
361
  'array-type': 'error',
377
362
  'ban-tslint-comment': 'error',
@@ -408,7 +393,6 @@ exports.RULES = {
408
393
  'prefer-as-const': 'error',
409
394
  'prefer-enum-initializers': 'off',
410
395
  'prefer-for-of': 'error',
411
- // https://github.com/typescript-eslint/typescript-eslint/issues/454
412
396
  'prefer-function-type': 'off',
413
397
  'prefer-includes': 'error',
414
398
  'prefer-literal-enum-member': 'off',
@@ -427,22 +411,19 @@ exports.RULES = {
427
411
  'triple-slash-reference': ['error', { lib: 'never' }],
428
412
  'typedef': 'error',
429
413
  'unified-signatures': 'error',
430
- // Layout
431
414
  'type-annotation-spacing': 'error',
432
415
  },
433
416
  '@fasttime/eslint-plugin': {
434
- // Layout
435
417
  'nice-space-before-function-paren': 'error',
436
418
  'no-spaces-in-call-expression': 'error',
437
419
  },
438
420
  'eslint-plugin-n': {
439
- // Problem
440
421
  'no-callback-literal': 'off',
441
422
  'no-deprecated-api': 'error',
442
423
  'no-exports-assign': 'error',
443
424
  'no-extraneous-import': jsts('error', 'off'),
444
425
  'no-extraneous-require': 'error',
445
- 'no-missing-import': 'error',
426
+ 'no-missing-import': jsts('error', 'off'),
446
427
  'no-missing-require': 'error',
447
428
  'no-unpublished-bin': 'error',
448
429
  'no-unpublished-import': 'error',
@@ -452,7 +433,6 @@ exports.RULES = {
452
433
  'no-unsupported-features/node-builtins': 'off',
453
434
  'process-exit-as-throw': 'error',
454
435
  'shebang': 'off',
455
- // Suggestion
456
436
  'callback-return': 'off',
457
437
  'exports-style': 'off',
458
438
  'file-extension-in-import': 'off',
package/no-parser.js CHANGED
@@ -1,7 +1,7 @@
1
- 'use strict';
2
-
3
- module.exports.parse =
4
- () =>
5
- {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parse = void 0;
4
+ function parse() {
6
5
  throw Error('missing configuration for this file');
7
- };
6
+ }
7
+ exports.parse = parse;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@origin-1/eslint-config",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "ESLint configuration generator with origin-1 presets",
5
5
  "homepage": "https://github.com/origin-1/eslint-config#readme",
6
6
  "license": "ISC",
@@ -23,6 +23,7 @@
23
23
  "exports": {
24
24
  ".": "./index.js",
25
25
  "./no-parser": "./no-parser.js",
26
- "./package.json": "./package.json"
26
+ "./package.json": "./package.json",
27
+ "./patch-tslib": "./patch-tslib.js"
27
28
  }
28
29
  }
package/patch-tslib.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_module_1 = require("node:module");
4
+ function patchTslib(require) {
5
+ let tsutilsPath;
6
+ const { resolve } = require;
7
+ try {
8
+ tsutilsPath = resolve('tsutils');
9
+ }
10
+ catch {
11
+ return;
12
+ }
13
+ const tsutilsRequire = (0, node_module_1.createRequire)(tsutilsPath);
14
+ const originalGlobal = globalThis.global;
15
+ globalThis.global = {};
16
+ try {
17
+ tsutilsRequire('tslib');
18
+ }
19
+ finally {
20
+ globalThis.global = originalGlobal;
21
+ }
22
+ }
23
+ exports.default = patchTslib;