@origin-1/eslint-config 0.2.2 → 0.4.1

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @origin-1/eslint-config · [![npm version][npm badge]][npm url]
2
2
 
3
- ESLint configuration generator with [origin-1](https://github.com/origin-1) presets.
3
+ [ESLint](https://eslint.org/) configuration generator with [Origin₁](https://github.com/origin-1) presets
4
4
 
5
5
  [npm badge]:
6
6
  https://badge.fury.io/js/@origin-1%2Feslint-config.svg
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,8 +25,6 @@ function jsts(jsEntry, tsEntry) {
25
25
  }
26
26
  exports.RULES = {
27
27
  [exports.UNIQUE]: {
28
- ////////////////////////////////////////////
29
- // Problem
30
28
  'array-callback-return': 'off',
31
29
  'constructor-super': 'error',
32
30
  'for-direction': 'error',
@@ -46,7 +44,6 @@ exports.RULES = {
46
44
  'no-dupe-else-if': 'error',
47
45
  'no-dupe-keys': 'error',
48
46
  'no-duplicate-case': 'error',
49
- // TypeScript has type only imports.
50
47
  'no-duplicate-imports': jsts('error', 'off'),
51
48
  'no-empty-character-class': 'error',
52
49
  'no-empty-pattern': 'error',
@@ -81,8 +78,6 @@ exports.RULES = {
81
78
  'require-atomic-updates': 'off',
82
79
  'use-isnan': ['error', { enforceForSwitchCase: true }],
83
80
  'valid-typeof': 'error',
84
- ////////////////////////////////////////////
85
- // Suggestion
86
81
  'accessor-pairs': ['error', { enforceForClassMembers: true }],
87
82
  'arrow-body-style': 'error',
88
83
  'block-scoped-var': 'off',
@@ -189,8 +184,6 @@ exports.RULES = {
189
184
  'prefer-arrow-callback': 'error',
190
185
  'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
191
186
  'prefer-destructuring': 'error',
192
- // Do not prefer the exponentiation operator in TypeScript, because that would result in
193
- // getting the value of Math.pow upon every evaluation in ES5 transpiled code.
194
187
  'prefer-exponentiation-operator': jsts('error', 'off'),
195
188
  'prefer-named-capture-group': 'off',
196
189
  'prefer-numeric-literals': 'error',
@@ -213,8 +206,6 @@ exports.RULES = {
213
206
  'symbol-description': 'off',
214
207
  'vars-on-top': 'off',
215
208
  'yoda': 'error',
216
- ////////////////////////////////////////////
217
- // Layout
218
209
  'array-bracket-newline': ['error', 'consistent'],
219
210
  'array-bracket-spacing': 'error',
220
211
  'array-element-newline': 'off',
@@ -233,7 +224,6 @@ exports.RULES = {
233
224
  'key-spacing': ['error', { mode: 'minimum' }],
234
225
  'line-comment-position': 'off',
235
226
  'linebreak-style': 'error',
236
- // In TypeScript files, lines-around-comment doesn't work well at the start of a block.
237
227
  'lines-around-comment': jsts(['error', { allowBlockStart: true, allowObjectStart: true }], 'off'),
238
228
  'max-len': ['error', { code: 100 }],
239
229
  'max-statements-per-line': 'error',
@@ -265,14 +255,10 @@ exports.RULES = {
265
255
  'yield-star-spacing': ['error', 'both'],
266
256
  },
267
257
  [exports.HYBRID]: {
268
- ////////////////////////////////////////////
269
- // Problem
270
258
  'no-dupe-class-members': 'error',
271
259
  'no-loss-of-precision': 'error',
272
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' }]),
273
261
  'no-use-before-define': 'off',
274
- ////////////////////////////////////////////
275
- // Suggestion
276
262
  'default-param-last': 'off',
277
263
  'dot-notation': 'error',
278
264
  'init-declarations': 'off',
@@ -283,7 +269,6 @@ exports.RULES = {
283
269
  'no-invalid-this': 'off',
284
270
  'no-loop-func': 'error',
285
271
  'no-magic-numbers': 'off',
286
- // Redeclarations are acceptable in TypeScript.
287
272
  'no-redeclare': jsts(['error', { builtinGlobals: true }], 'off'),
288
273
  'no-restricted-imports': 'off',
289
274
  'no-shadow': 'off',
@@ -291,13 +276,10 @@ exports.RULES = {
291
276
  'no-unused-expressions': 'error',
292
277
  'no-useless-constructor': 'error',
293
278
  'require-await': 'error',
294
- ////////////////////////////////////////////
295
- // Layout
296
279
  'brace-style': ['error', 'allman'],
297
280
  'comma-dangle': ['error', 'always-multiline'],
298
281
  'comma-spacing': 'error',
299
282
  'func-call-spacing': 'off',
300
- // typescript-eslint rule is flawed.
301
283
  'indent': jsts([
302
284
  'error',
303
285
  4,
@@ -338,13 +320,10 @@ exports.RULES = {
338
320
  'semi': 'error',
339
321
  'space-before-blocks': 'error',
340
322
  'space-before-function-paren': 'off',
341
- // typescript-eslint rule does not handle well colons (":") in mapped types.
342
323
  'space-infix-ops': jsts('error', 'off'),
343
324
  },
344
325
  '@typescript-eslint/eslint-plugin': {
345
326
  [exports.FOR_LANG]: 'ts',
346
- ////////////////////////////////////////////
347
- // Problem
348
327
  'await-thenable': 'error',
349
328
  'ban-ts-comment': 'off',
350
329
  'class-literal-property-style': ['error', 'getters'],
@@ -378,8 +357,6 @@ exports.RULES = {
378
357
  'restrict-template-expressions': 'off',
379
358
  'return-await': 'error',
380
359
  'unbound-method': 'off',
381
- ////////////////////////////////////////////
382
- // Suggestion
383
360
  'adjacent-overload-signatures': 'error',
384
361
  'array-type': 'error',
385
362
  'ban-tslint-comment': 'error',
@@ -416,7 +393,6 @@ exports.RULES = {
416
393
  'prefer-as-const': 'error',
417
394
  'prefer-enum-initializers': 'off',
418
395
  'prefer-for-of': 'error',
419
- // https://github.com/typescript-eslint/typescript-eslint/issues/454
420
396
  'prefer-function-type': 'off',
421
397
  'prefer-includes': 'error',
422
398
  'prefer-literal-enum-member': 'off',
@@ -435,26 +411,18 @@ exports.RULES = {
435
411
  'triple-slash-reference': ['error', { lib: 'never' }],
436
412
  'typedef': 'error',
437
413
  'unified-signatures': 'error',
438
- ////////////////////////////////////////////
439
- // Layout
440
414
  'type-annotation-spacing': 'error',
441
415
  },
442
- '@fasttime/eslint-plugin': {
443
- ////////////////////////////////////////////
444
- // Layout
416
+ '@origin-1/eslint-plugin': {
445
417
  'nice-space-before-function-paren': 'error',
446
418
  'no-spaces-in-call-expression': 'error',
447
419
  },
448
420
  'eslint-plugin-n': {
449
- ////////////////////////////////////////////
450
- // Problem
451
421
  'no-callback-literal': 'off',
452
422
  'no-deprecated-api': 'error',
453
423
  'no-exports-assign': 'error',
454
- // Does not handle type declaration imports.
455
424
  'no-extraneous-import': jsts('error', 'off'),
456
425
  'no-extraneous-require': 'error',
457
- // Does not handle type declaration imports.
458
426
  'no-missing-import': jsts('error', 'off'),
459
427
  'no-missing-require': 'error',
460
428
  'no-unpublished-bin': 'error',
@@ -465,8 +433,6 @@ exports.RULES = {
465
433
  'no-unsupported-features/node-builtins': 'off',
466
434
  'process-exit-as-throw': 'error',
467
435
  'shebang': 'off',
468
- ////////////////////////////////////////////
469
- // Suggestion
470
436
  'callback-return': 'off',
471
437
  'exports-style': 'off',
472
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,7 +1,7 @@
1
1
  {
2
2
  "name": "@origin-1/eslint-config",
3
- "version": "0.2.2",
4
- "description": "ESLint configuration generator with origin-1 presets",
3
+ "version": "0.4.1",
4
+ "description": "ESLint configuration generator with Origin₁ presets",
5
5
  "homepage": "https://github.com/origin-1/eslint-config#readme",
6
6
  "license": "ISC",
7
7
  "author": "Francesco Trotta <ft@fasttime.org> (https://github.com/fasttime)",
@@ -11,18 +11,19 @@
11
11
  "semver": "7"
12
12
  },
13
13
  "peerDependencies": {
14
- "@fasttime/eslint-plugin": "0.6",
14
+ "@origin-1/eslint-plugin": "0.7",
15
15
  "@typescript-eslint/eslint-plugin": "5",
16
16
  "@typescript-eslint/parser": "5",
17
17
  "eslint": "^8.14.0",
18
18
  "eslint-plugin-n": "15"
19
19
  },
20
20
  "engines": {
21
- "node": ">=18"
21
+ "node": "18 >=18.1"
22
22
  },
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;