@origin-1/eslint-config 0.3.2 → 0.5.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/README.md +1 -1
- package/index.d.ts +1 -1
- package/index.js +6 -1
- package/lib/create-config.d.ts +2 -2
- package/lib/create-config.js +4 -15
- package/lib/normalize-version.d.ts +6 -0
- package/lib/normalize-version.js +27 -0
- package/lib/rules.js +4 -4
- package/package.json +6 -5
- package/patch-tslib.js +23 -0
- package/lib/patch-tslib.js +0 -13
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 [
|
|
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.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -13,6 +13,11 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
16
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
require("./
|
|
20
|
+
const patch_tslib_js_1 = __importDefault(require("./patch-tslib.js"));
|
|
21
|
+
(0, patch_tslib_js_1.default)(require);
|
|
18
22
|
__exportStar(require("./lib/create-config.js"), exports);
|
|
23
|
+
__exportStar(require("./lib/normalize-version.js"), exports);
|
package/lib/create-config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JSVersion } from './
|
|
1
|
+
import type { JSVersion, TSVersion } from './normalize-version.js';
|
|
2
2
|
import type { Linter } from 'eslint';
|
|
3
3
|
export interface ConfigData extends Linter.HasRules {
|
|
4
4
|
env?: Record<string, boolean> | undefined;
|
|
@@ -7,7 +7,7 @@ export interface ConfigData extends Linter.HasRules {
|
|
|
7
7
|
jsVersion?: JSVersion | undefined;
|
|
8
8
|
parserOptions?: Linter.ParserOptions | undefined;
|
|
9
9
|
plugins?: string[] | undefined;
|
|
10
|
-
tsVersion?:
|
|
10
|
+
tsVersion?: TSVersion | undefined;
|
|
11
11
|
}
|
|
12
12
|
export interface ConfigDataWithFiles extends ConfigData {
|
|
13
13
|
excludedFiles?: string | string[] | undefined;
|
package/lib/create-config.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createConfig = exports.createBaseConfig = void 0;
|
|
7
|
+
const normalize_version_js_1 = require("./normalize-version.js");
|
|
7
8
|
const rules_js_1 = require("./rules.js");
|
|
8
9
|
const semver_1 = __importDefault(require("semver"));
|
|
9
10
|
function cloneRuleEntry(ruleEntry) {
|
|
@@ -34,12 +35,12 @@ function createBaseOverride(configData) {
|
|
|
34
35
|
let ecmaVersion;
|
|
35
36
|
let envKey;
|
|
36
37
|
let parser;
|
|
37
|
-
const jsVersion =
|
|
38
|
+
const jsVersion = (0, normalize_version_js_1.normalizeJSVersion)(configData.jsVersion);
|
|
38
39
|
if (jsVersion === 2015)
|
|
39
40
|
envKey = 'es6';
|
|
40
41
|
else if (jsVersion > 2015)
|
|
41
42
|
envKey = `es${jsVersion}`;
|
|
42
|
-
const tsVersion =
|
|
43
|
+
const tsVersion = (0, normalize_version_js_1.normalizeTSVersion)(configData.tsVersion);
|
|
43
44
|
if (lang === 'ts') {
|
|
44
45
|
ecmaVersion = 'latest';
|
|
45
46
|
parser = '@typescript-eslint/parser';
|
|
@@ -134,6 +135,7 @@ function createCommonEntries() {
|
|
|
134
135
|
function createConfig(...configDataList) {
|
|
135
136
|
const { plugins, rules } = createCommonEntries();
|
|
136
137
|
const overrides = configDataList.map(createOverride);
|
|
138
|
+
overrides.unshift({ files: ['*.js', '*.cjs', '*.mjs', '*.ts', '*.cts', '*.mts'] });
|
|
137
139
|
const config = {
|
|
138
140
|
overrides,
|
|
139
141
|
parser: '@origin-1/eslint-config/no-parser',
|
|
@@ -169,22 +171,9 @@ function findRuleEntry(versionedList, jsVersion, tsVersion) {
|
|
|
169
171
|
}
|
|
170
172
|
}
|
|
171
173
|
}
|
|
172
|
-
function getJSVersion(configData) {
|
|
173
|
-
const { jsVersion } = configData;
|
|
174
|
-
return Number.isInteger(jsVersion) ? jsVersion : 5;
|
|
175
|
-
}
|
|
176
174
|
function getLanguage(configData) {
|
|
177
175
|
return configData.tsVersion == null ? 'js' : 'ts';
|
|
178
176
|
}
|
|
179
|
-
function getTSVersion(configData) {
|
|
180
|
-
const { tsVersion } = configData;
|
|
181
|
-
if (tsVersion != null) {
|
|
182
|
-
const cleanVersion = semver_1.default.clean(tsVersion);
|
|
183
|
-
if (cleanVersion != null)
|
|
184
|
-
return cleanVersion;
|
|
185
|
-
}
|
|
186
|
-
return 'latest';
|
|
187
|
-
}
|
|
188
177
|
function isJSTSEntry(ruleSettings) {
|
|
189
178
|
return typeof ruleSettings === 'object' && 'js' in ruleSettings && 'ts' in ruleSettings;
|
|
190
179
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const JS_VERSION_SET: Set<5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022>;
|
|
2
|
+
export declare type JSVersion = typeof JS_VERSION_SET extends Set<infer T> ? T : never;
|
|
3
|
+
export declare type TSVersion = 'latest' | `${number}.${number}.${number}` | `${number}.${number}.${number}-${string}`;
|
|
4
|
+
export declare function normalizeJSVersion(jsVersion?: JSVersion): JSVersion;
|
|
5
|
+
export declare function normalizeTSVersion(tsVersion?: TSVersion): TSVersion;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.normalizeTSVersion = exports.normalizeJSVersion = void 0;
|
|
7
|
+
const node_util_1 = require("node:util");
|
|
8
|
+
const semver_1 = __importDefault(require("semver"));
|
|
9
|
+
const JS_VERSION_SET = new Set([5, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022]);
|
|
10
|
+
function normalizeJSVersion(jsVersion = 5) {
|
|
11
|
+
if (JS_VERSION_SET.has(jsVersion))
|
|
12
|
+
return jsVersion;
|
|
13
|
+
const validValuesList = new Intl.ListFormat('en').format([...JS_VERSION_SET].map(String));
|
|
14
|
+
const message = `jsVersion ${(0, node_util_1.inspect)(jsVersion)} is not supported. Valid values are ${validValuesList}`;
|
|
15
|
+
throw TypeError(message);
|
|
16
|
+
}
|
|
17
|
+
exports.normalizeJSVersion = normalizeJSVersion;
|
|
18
|
+
function normalizeTSVersion(tsVersion = 'latest') {
|
|
19
|
+
if (tsVersion === 'latest')
|
|
20
|
+
return tsVersion;
|
|
21
|
+
const normalTSVersion = semver_1.default.clean(tsVersion);
|
|
22
|
+
if (normalTSVersion != null)
|
|
23
|
+
return normalTSVersion;
|
|
24
|
+
const message = `tsVersion ${(0, node_util_1.inspect)(tsVersion)} is not supported`;
|
|
25
|
+
throw TypeError(message);
|
|
26
|
+
}
|
|
27
|
+
exports.normalizeTSVersion = normalizeTSVersion;
|
package/lib/rules.js
CHANGED
|
@@ -173,7 +173,7 @@ exports.RULES = {
|
|
|
173
173
|
'no-useless-escape': 'error',
|
|
174
174
|
'no-useless-rename': 'error',
|
|
175
175
|
'no-useless-return': 'error',
|
|
176
|
-
'no-var': 'error',
|
|
176
|
+
'no-var': jsts(beforeOrElse(2015, 'off', 'error'), 'error'),
|
|
177
177
|
'no-void': 'off',
|
|
178
178
|
'no-warning-comments': 'off',
|
|
179
179
|
'no-with': 'error',
|
|
@@ -413,7 +413,7 @@ exports.RULES = {
|
|
|
413
413
|
'unified-signatures': 'error',
|
|
414
414
|
'type-annotation-spacing': 'error',
|
|
415
415
|
},
|
|
416
|
-
'@
|
|
416
|
+
'@origin-1/eslint-plugin': {
|
|
417
417
|
'nice-space-before-function-paren': 'error',
|
|
418
418
|
'no-spaces-in-call-expression': 'error',
|
|
419
419
|
},
|
|
@@ -423,8 +423,8 @@ exports.RULES = {
|
|
|
423
423
|
'no-exports-assign': 'error',
|
|
424
424
|
'no-extraneous-import': jsts('error', 'off'),
|
|
425
425
|
'no-extraneous-require': 'error',
|
|
426
|
-
'no-missing-import':
|
|
427
|
-
'no-missing-require': '
|
|
426
|
+
'no-missing-import': 'off',
|
|
427
|
+
'no-missing-require': 'off',
|
|
428
428
|
'no-unpublished-bin': 'error',
|
|
429
429
|
'no-unpublished-import': 'error',
|
|
430
430
|
'no-unpublished-require': 'error',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@origin-1/eslint-config",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "ESLint configuration generator with
|
|
3
|
+
"version": "0.5.0",
|
|
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
|
-
"@
|
|
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;
|
package/lib/patch-tslib.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const node_module_1 = require("node:module");
|
|
4
|
-
const tsutilsPath = require.resolve('tsutils');
|
|
5
|
-
const tsutilsRequire = (0, node_module_1.createRequire)(tsutilsPath);
|
|
6
|
-
const originalGlobal = globalThis.global;
|
|
7
|
-
globalThis.global = {};
|
|
8
|
-
try {
|
|
9
|
-
tsutilsRequire('tslib');
|
|
10
|
-
}
|
|
11
|
-
finally {
|
|
12
|
-
globalThis.global = originalGlobal;
|
|
13
|
-
}
|