@origin-1/eslint-config 0.0.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/LICENSE +13 -0
- package/README.md +9 -0
- package/index.d.ts +1 -0
- package/index.js +3 -0
- package/lib/create-config.d.ts +16 -0
- package/lib/create-config.js +171 -0
- package/lib/rules.js +479 -0
- package/no-parser.js +7 -0
- package/package.json +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright Origin₁ (https://github.com/origin-1)
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
5
|
+
copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
10
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
12
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @origin-1/eslint-config · [![npm version][npm badge]][npm url]
|
|
2
|
+
|
|
3
|
+
ESLint configuration generator with [origin-1](https://github.com/origin-1) presets.
|
|
4
|
+
|
|
5
|
+
[npm badge]:
|
|
6
|
+
https://badge.fury.io/js/@origin-1%2Feslint-config.svg
|
|
7
|
+
|
|
8
|
+
[npm url]:
|
|
9
|
+
https://www.npmjs.com/package/@origin-1/eslint-config
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/create-config';
|
package/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JSVersion } from './rules.js';
|
|
2
|
+
import type { Linter } from 'eslint';
|
|
3
|
+
export interface ConfigData extends Linter.HasRules {
|
|
4
|
+
env?: Record<string, boolean> | undefined;
|
|
5
|
+
globals?: Record<string, boolean | 'readonly' | 'readable' | 'writable' | 'writeable'> | undefined;
|
|
6
|
+
jsVersion?: JSVersion | undefined;
|
|
7
|
+
parserOptions?: Linter.ParserOptions | undefined;
|
|
8
|
+
plugins?: string[] | undefined;
|
|
9
|
+
tsVersion?: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface ConfigDataWithFiles extends ConfigData {
|
|
12
|
+
excludedFiles?: string | string[] | undefined;
|
|
13
|
+
files: string | string[];
|
|
14
|
+
}
|
|
15
|
+
export declare function createBaseConfig(configData: ConfigData): Linter.BaseConfig;
|
|
16
|
+
export declare function createConfig(...configDataList: ConfigDataWithFiles[]): Linter.Config;
|
|
@@ -0,0 +1,171 @@
|
|
|
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.createConfig = exports.createBaseConfig = void 0;
|
|
7
|
+
const rules_js_1 = require("./rules.js");
|
|
8
|
+
const semver_1 = __importDefault(require("semver"));
|
|
9
|
+
function cloneRuleEntry(ruleEntry) {
|
|
10
|
+
return structuredClone(ruleEntry);
|
|
11
|
+
}
|
|
12
|
+
function createBaseConfig(configData) {
|
|
13
|
+
const { plugins, rules } = createCommonEntries();
|
|
14
|
+
const baseOverride = createBaseOverride(configData);
|
|
15
|
+
const { env, parser, parserOptions, plugins: overridePlugins = [], rules: overrideRules } = baseOverride;
|
|
16
|
+
plugins.push(...overridePlugins);
|
|
17
|
+
Object.assign(rules, overrideRules);
|
|
18
|
+
const baseConfig = { env, parser, parserOptions, plugins, reportUnusedDisableDirectives: true, rules };
|
|
19
|
+
return baseConfig;
|
|
20
|
+
}
|
|
21
|
+
exports.createBaseConfig = createBaseConfig;
|
|
22
|
+
function createBaseOverride(configData) {
|
|
23
|
+
const { plugins } = configData;
|
|
24
|
+
const lang = getLanguage(configData);
|
|
25
|
+
let ecmaVersion;
|
|
26
|
+
let envKey;
|
|
27
|
+
let parser;
|
|
28
|
+
const jsVersion = getJSVersion(configData);
|
|
29
|
+
if (jsVersion === 2015)
|
|
30
|
+
envKey = 'es6';
|
|
31
|
+
else if (jsVersion > 2015)
|
|
32
|
+
envKey = `es${jsVersion}`;
|
|
33
|
+
const tsVersion = getTSVersion(configData);
|
|
34
|
+
if (lang === 'ts') {
|
|
35
|
+
ecmaVersion = 'latest';
|
|
36
|
+
parser = '@typescript-eslint/parser';
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
ecmaVersion = jsVersion;
|
|
40
|
+
parser = 'espree';
|
|
41
|
+
}
|
|
42
|
+
const env = envKey ? { [envKey]: true } : {};
|
|
43
|
+
Object.assign(env, configData.env);
|
|
44
|
+
const parserOptions = { ecmaVersion, ...configData.parserOptions };
|
|
45
|
+
const rules = {};
|
|
46
|
+
const setOverrideRule = (ruleName, ruleLangSettings) => {
|
|
47
|
+
if (ruleLangSettings != null) {
|
|
48
|
+
const ruleEntry = isVersionedList(ruleLangSettings) ?
|
|
49
|
+
findRuleEntry(ruleLangSettings, jsVersion, tsVersion) : ruleLangSettings;
|
|
50
|
+
if (ruleEntry != null)
|
|
51
|
+
rules[ruleName] = cloneRuleEntry(ruleEntry);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
for (const [ruleName, ruleDef] of Object.entries(rules_js_1.RULES[rules_js_1.UNIQUE])) {
|
|
55
|
+
if (isJSTSEntry(ruleDef)) {
|
|
56
|
+
const ruleLangSettings = ruleDef[lang];
|
|
57
|
+
setOverrideRule(ruleName, ruleLangSettings);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
for (const [ruleName, ruleDef] of Object.entries(rules_js_1.RULES[rules_js_1.HYBRID])) {
|
|
61
|
+
if (isRuleEntry(ruleDef)) {
|
|
62
|
+
if (lang === 'ts') {
|
|
63
|
+
rules[ruleName] = 'off';
|
|
64
|
+
rules[`@typescript-eslint/${ruleName}`] = cloneRuleEntry(ruleDef);
|
|
65
|
+
}
|
|
66
|
+
else
|
|
67
|
+
rules[ruleName] = cloneRuleEntry(ruleDef);
|
|
68
|
+
}
|
|
69
|
+
if (isJSTSEntry(ruleDef)) {
|
|
70
|
+
if (lang === 'ts') {
|
|
71
|
+
rules[ruleName] = 'off';
|
|
72
|
+
setOverrideRule(`@typescript-eslint/${ruleName}`, ruleDef.ts);
|
|
73
|
+
}
|
|
74
|
+
else
|
|
75
|
+
setOverrideRule(ruleName, ruleDef.js);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const [pluginName, definedPluginRules] of Object.entries(rules_js_1.RULES)) {
|
|
79
|
+
const rulePrefix = (0, rules_js_1.getRulePrefix)(pluginName);
|
|
80
|
+
for (const [ruleName, ruleDef] of Object.entries(definedPluginRules)) {
|
|
81
|
+
if (isJSTSEntry(ruleDef)) {
|
|
82
|
+
const ruleLangSettings = ruleDef[lang];
|
|
83
|
+
setOverrideRule(`${rulePrefix}/${ruleName}`, ruleLangSettings);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
Object.assign(rules, configData.rules);
|
|
88
|
+
const baseOverride = { env, parser, parserOptions, plugins, rules };
|
|
89
|
+
return baseOverride;
|
|
90
|
+
}
|
|
91
|
+
function createCommonEntries() {
|
|
92
|
+
const plugins = [];
|
|
93
|
+
const rules = {};
|
|
94
|
+
for (const [ruleName, ruleDef] of Object.entries(rules_js_1.RULES[rules_js_1.UNIQUE])) {
|
|
95
|
+
if (isRuleEntry(ruleDef))
|
|
96
|
+
rules[ruleName] = cloneRuleEntry(ruleDef);
|
|
97
|
+
}
|
|
98
|
+
for (const [pluginName, definedPluginRules] of Object.entries(rules_js_1.RULES)) {
|
|
99
|
+
const rulePrefix = (0, rules_js_1.getRulePrefix)(pluginName);
|
|
100
|
+
plugins.push(rulePrefix);
|
|
101
|
+
for (const [ruleName, ruleDef] of Object.entries(definedPluginRules)) {
|
|
102
|
+
if (isRuleEntry(ruleDef))
|
|
103
|
+
rules[`${rulePrefix}/${ruleName}`] = cloneRuleEntry(ruleDef);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const commonEntries = { plugins, rules };
|
|
107
|
+
return commonEntries;
|
|
108
|
+
}
|
|
109
|
+
function createConfig(...configDataList) {
|
|
110
|
+
const { plugins, rules } = createCommonEntries();
|
|
111
|
+
const overrides = configDataList.map(createOverride);
|
|
112
|
+
const config = {
|
|
113
|
+
overrides,
|
|
114
|
+
parser: '@origin-1/eslint-config/no-parser',
|
|
115
|
+
plugins,
|
|
116
|
+
reportUnusedDisableDirectives: true,
|
|
117
|
+
root: true,
|
|
118
|
+
rules,
|
|
119
|
+
};
|
|
120
|
+
return config;
|
|
121
|
+
}
|
|
122
|
+
exports.createConfig = createConfig;
|
|
123
|
+
function createOverride(configData) {
|
|
124
|
+
const baseOverride = createBaseOverride(configData);
|
|
125
|
+
const { excludedFiles, files } = configData;
|
|
126
|
+
const override = { ...baseOverride, excludedFiles, files };
|
|
127
|
+
return override;
|
|
128
|
+
}
|
|
129
|
+
function findRuleEntry(versionedList, jsVersion, tsVersion) {
|
|
130
|
+
let index = versionedList.length;
|
|
131
|
+
while (index--) {
|
|
132
|
+
const { minVersion, ruleEntry } = versionedList[index];
|
|
133
|
+
switch (typeof minVersion) {
|
|
134
|
+
case 'number':
|
|
135
|
+
if (jsVersion >= minVersion)
|
|
136
|
+
return ruleEntry;
|
|
137
|
+
break;
|
|
138
|
+
case 'string':
|
|
139
|
+
if (tsVersion === 'latest' || semver_1.default.gte(tsVersion, minVersion))
|
|
140
|
+
return ruleEntry;
|
|
141
|
+
break;
|
|
142
|
+
default:
|
|
143
|
+
return ruleEntry;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function getJSVersion(configData) {
|
|
148
|
+
const { jsVersion } = configData;
|
|
149
|
+
return Number.isInteger(jsVersion) ? jsVersion : 5;
|
|
150
|
+
}
|
|
151
|
+
function getLanguage(configData) {
|
|
152
|
+
return configData.tsVersion == null ? 'js' : 'ts';
|
|
153
|
+
}
|
|
154
|
+
function getTSVersion(configData) {
|
|
155
|
+
const { tsVersion } = configData;
|
|
156
|
+
if (tsVersion != null) {
|
|
157
|
+
const cleanVersion = semver_1.default.clean(tsVersion);
|
|
158
|
+
if (cleanVersion != null)
|
|
159
|
+
return cleanVersion;
|
|
160
|
+
}
|
|
161
|
+
return 'latest';
|
|
162
|
+
}
|
|
163
|
+
function isJSTSEntry(ruleSettings) {
|
|
164
|
+
return typeof ruleSettings === 'object' && 'js' in ruleSettings && 'ts' in ruleSettings;
|
|
165
|
+
}
|
|
166
|
+
function isRuleEntry(ruleSettings) {
|
|
167
|
+
return typeof ruleSettings === 'string' || Array.isArray(ruleSettings);
|
|
168
|
+
}
|
|
169
|
+
function isVersionedList(ruleLangSettings) {
|
|
170
|
+
return Array.isArray(ruleLangSettings) && 'versioned' in ruleLangSettings;
|
|
171
|
+
}
|
package/lib/rules.js
ADDED
|
@@ -0,0 +1,479 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RULES = exports.getRulePrefix = exports.HYBRID = exports.UNIQUE = void 0;
|
|
4
|
+
exports.UNIQUE = Symbol('Unique built-in rules');
|
|
5
|
+
exports.HYBRID = Symbol('Hybrid rules');
|
|
6
|
+
function beforeOrElse(version, before, else_) {
|
|
7
|
+
const beforeEntry = { minVersion: undefined, ruleEntry: before };
|
|
8
|
+
const elseEntry = { minVersion: version, ruleEntry: else_ };
|
|
9
|
+
const array = [beforeEntry, elseEntry];
|
|
10
|
+
const versionedList = Object.assign(array, { versioned: true });
|
|
11
|
+
return versionedList;
|
|
12
|
+
}
|
|
13
|
+
function getRulePrefix(pluginName) {
|
|
14
|
+
const rulePrefix = pluginName.replace(/^eslint-plugin-|\/eslint-plugin$/, '');
|
|
15
|
+
return rulePrefix;
|
|
16
|
+
}
|
|
17
|
+
exports.getRulePrefix = getRulePrefix;
|
|
18
|
+
function jsts(jsEntry, tsEntry) {
|
|
19
|
+
return { js: jsEntry, ts: tsEntry };
|
|
20
|
+
}
|
|
21
|
+
function tsOnly(input) {
|
|
22
|
+
const output = Object.fromEntries(Object
|
|
23
|
+
.entries(input)
|
|
24
|
+
.map(([ruleName, tsEntry]) => [ruleName, jsts(undefined, tsEntry)]));
|
|
25
|
+
return output;
|
|
26
|
+
}
|
|
27
|
+
exports.RULES = {
|
|
28
|
+
[exports.UNIQUE]: {
|
|
29
|
+
// Problem
|
|
30
|
+
'array-callback-return': 'off',
|
|
31
|
+
'constructor-super': 'error',
|
|
32
|
+
'for-direction': 'error',
|
|
33
|
+
'getter-return': 'error',
|
|
34
|
+
'no-async-promise-executor': 'error',
|
|
35
|
+
'no-await-in-loop': 'off',
|
|
36
|
+
'no-class-assign': 'error',
|
|
37
|
+
'no-compare-neg-zero': 'error',
|
|
38
|
+
'no-cond-assign': 'off',
|
|
39
|
+
'no-const-assign': 'error',
|
|
40
|
+
'no-constant-binary-expression': 'error',
|
|
41
|
+
'no-constant-condition': 'error',
|
|
42
|
+
'no-constructor-return': 'off',
|
|
43
|
+
'no-control-regex': 'off',
|
|
44
|
+
'no-debugger': 'error',
|
|
45
|
+
'no-dupe-args': 'error',
|
|
46
|
+
'no-dupe-else-if': 'error',
|
|
47
|
+
'no-dupe-keys': 'error',
|
|
48
|
+
'no-duplicate-case': 'error',
|
|
49
|
+
// TypeScript has type only imports.
|
|
50
|
+
'no-duplicate-imports': jsts('error', 'off'),
|
|
51
|
+
'no-empty-character-class': 'error',
|
|
52
|
+
'no-empty-pattern': 'error',
|
|
53
|
+
'no-ex-assign': 'error',
|
|
54
|
+
'no-fallthrough': 'error',
|
|
55
|
+
'no-func-assign': 'error',
|
|
56
|
+
'no-import-assign': 'error',
|
|
57
|
+
'no-inner-declarations': 'error',
|
|
58
|
+
'no-invalid-regexp': 'error',
|
|
59
|
+
'no-irregular-whitespace': 'error',
|
|
60
|
+
'no-misleading-character-class': 'error',
|
|
61
|
+
'no-new-symbol': 'error',
|
|
62
|
+
'no-obj-calls': 'error',
|
|
63
|
+
'no-promise-executor-return': 'error',
|
|
64
|
+
'no-prototype-builtins': 'off',
|
|
65
|
+
'no-self-assign': 'error',
|
|
66
|
+
'no-self-compare': 'off',
|
|
67
|
+
'no-setter-return': 'error',
|
|
68
|
+
'no-sparse-arrays': 'off',
|
|
69
|
+
'no-template-curly-in-string': 'off',
|
|
70
|
+
'no-this-before-super': 'error',
|
|
71
|
+
'no-undef': jsts('error', 'off'),
|
|
72
|
+
'no-unexpected-multiline': 'off',
|
|
73
|
+
'no-unmodified-loop-condition': 'off',
|
|
74
|
+
'no-unreachable': 'error',
|
|
75
|
+
'no-unreachable-loop': 'error',
|
|
76
|
+
'no-unsafe-finally': 'error',
|
|
77
|
+
'no-unsafe-negation': 'error',
|
|
78
|
+
'no-unsafe-optional-chaining': 'error',
|
|
79
|
+
'no-unused-private-class-members': 'error',
|
|
80
|
+
'no-useless-backreference': 'error',
|
|
81
|
+
'require-atomic-updates': 'off',
|
|
82
|
+
'use-isnan': ['error', { enforceForSwitchCase: true }],
|
|
83
|
+
'valid-typeof': 'error',
|
|
84
|
+
// Suggestion
|
|
85
|
+
'accessor-pairs': ['error', { enforceForClassMembers: true }],
|
|
86
|
+
'arrow-body-style': 'error',
|
|
87
|
+
'block-scoped-var': 'off',
|
|
88
|
+
'camelcase': 'off',
|
|
89
|
+
'capitalized-comments': 'off',
|
|
90
|
+
'class-methods-use-this': 'off',
|
|
91
|
+
'complexity': 'off',
|
|
92
|
+
'consistent-return': 'off',
|
|
93
|
+
'consistent-this': 'off',
|
|
94
|
+
'curly': ['error', 'multi-or-nest'],
|
|
95
|
+
'default-case': 'off',
|
|
96
|
+
'default-case-last': 'off',
|
|
97
|
+
'eqeqeq': ['error', 'allow-null'],
|
|
98
|
+
'func-name-matching': 'off',
|
|
99
|
+
'func-names': ['error', 'never'],
|
|
100
|
+
'func-style': 'off',
|
|
101
|
+
'grouped-accessor-pairs': ['error', 'getBeforeSet'],
|
|
102
|
+
'guard-for-in': 'off',
|
|
103
|
+
'id-denylist': 'off',
|
|
104
|
+
'id-length': 'off',
|
|
105
|
+
'id-match': 'off',
|
|
106
|
+
'max-classes-per-file': 'off',
|
|
107
|
+
'max-depth': 'off',
|
|
108
|
+
'max-lines': 'off',
|
|
109
|
+
'max-lines-per-function': 'off',
|
|
110
|
+
'max-nested-callbacks': 'off',
|
|
111
|
+
'max-params': 'off',
|
|
112
|
+
'max-statements': 'off',
|
|
113
|
+
'multiline-comment-style': 'off',
|
|
114
|
+
'new-cap': ['error', { capIsNew: false }],
|
|
115
|
+
'no-alert': 'error',
|
|
116
|
+
'no-bitwise': 'off',
|
|
117
|
+
'no-caller': 'error',
|
|
118
|
+
'no-case-declarations': 'error',
|
|
119
|
+
'no-confusing-arrow': 'off',
|
|
120
|
+
'no-console': 'off',
|
|
121
|
+
'no-continue': 'off',
|
|
122
|
+
'no-delete-var': 'error',
|
|
123
|
+
'no-div-regex': 'error',
|
|
124
|
+
'no-else-return': 'error',
|
|
125
|
+
'no-empty': ['error', { allowEmptyCatch: true }],
|
|
126
|
+
'no-eq-null': 'off',
|
|
127
|
+
'no-eval': 'off',
|
|
128
|
+
'no-extend-native': 'error',
|
|
129
|
+
'no-extra-bind': 'error',
|
|
130
|
+
'no-extra-boolean-cast': 'error',
|
|
131
|
+
'no-extra-label': 'error',
|
|
132
|
+
'no-floating-decimal': 'error',
|
|
133
|
+
'no-global-assign': 'error',
|
|
134
|
+
'no-implicit-coercion': 'off',
|
|
135
|
+
'no-implicit-globals': 'off',
|
|
136
|
+
'no-inline-comments': 'off',
|
|
137
|
+
'no-iterator': 'error',
|
|
138
|
+
'no-label-var': 'error',
|
|
139
|
+
'no-labels': ['error', { allowLoop: true, allowSwitch: true }],
|
|
140
|
+
'no-lone-blocks': 'error',
|
|
141
|
+
'no-lonely-if': 'off',
|
|
142
|
+
'no-mixed-operators': 'off',
|
|
143
|
+
'no-multi-assign': 'off',
|
|
144
|
+
'no-multi-str': 'error',
|
|
145
|
+
'no-negated-condition': 'off',
|
|
146
|
+
'no-nested-ternary': 'off',
|
|
147
|
+
'no-new': 'off',
|
|
148
|
+
'no-new-func': 'off',
|
|
149
|
+
'no-new-object': 'error',
|
|
150
|
+
'no-new-wrappers': 'error',
|
|
151
|
+
'no-nonoctal-decimal-escape': 'error',
|
|
152
|
+
'no-octal': 'error',
|
|
153
|
+
'no-octal-escape': 'error',
|
|
154
|
+
'no-param-reassign': 'off',
|
|
155
|
+
'no-plusplus': 'off',
|
|
156
|
+
'no-proto': 'error',
|
|
157
|
+
'no-regex-spaces': 'off',
|
|
158
|
+
'no-restricted-exports': 'off',
|
|
159
|
+
'no-restricted-globals': 'error',
|
|
160
|
+
'no-restricted-properties': 'off',
|
|
161
|
+
'no-restricted-syntax': 'error',
|
|
162
|
+
'no-return-assign': ['error', 'always'],
|
|
163
|
+
'no-return-await': 'error',
|
|
164
|
+
'no-script-url': 'error',
|
|
165
|
+
'no-sequences': 'error',
|
|
166
|
+
'no-shadow-restricted-names': 'error',
|
|
167
|
+
'no-ternary': 'off',
|
|
168
|
+
'no-undef-init': 'error',
|
|
169
|
+
'no-undefined': 'off',
|
|
170
|
+
'no-underscore-dangle': 'off',
|
|
171
|
+
'no-unneeded-ternary': 'error',
|
|
172
|
+
'no-unused-labels': 'error',
|
|
173
|
+
'no-useless-call': 'error',
|
|
174
|
+
'no-useless-catch': 'error',
|
|
175
|
+
'no-useless-computed-key': 'error',
|
|
176
|
+
'no-useless-concat': 'error',
|
|
177
|
+
'no-useless-escape': 'error',
|
|
178
|
+
'no-useless-rename': 'error',
|
|
179
|
+
'no-useless-return': 'error',
|
|
180
|
+
'no-var': 'error',
|
|
181
|
+
'no-void': 'off',
|
|
182
|
+
'no-warning-comments': 'off',
|
|
183
|
+
'no-with': 'error',
|
|
184
|
+
'object-shorthand': 'error',
|
|
185
|
+
'one-var': ['error', 'never'],
|
|
186
|
+
'one-var-declaration-per-line': 'error',
|
|
187
|
+
'operator-assignment': 'error',
|
|
188
|
+
'prefer-arrow-callback': 'error',
|
|
189
|
+
'prefer-const': ['error', { ignoreReadBeforeAssign: true }],
|
|
190
|
+
'prefer-destructuring': 'error',
|
|
191
|
+
// Do not prefer the exponentiation operator in TypeScript, because that would result in
|
|
192
|
+
// getting the value of Math.pow upon every evaluation in ES5 transpiled code.
|
|
193
|
+
'prefer-exponentiation-operator': jsts('error', 'off'),
|
|
194
|
+
'prefer-named-capture-group': 'off',
|
|
195
|
+
'prefer-numeric-literals': 'error',
|
|
196
|
+
'prefer-object-has-own': 'error',
|
|
197
|
+
'prefer-object-spread': 'off',
|
|
198
|
+
'prefer-promise-reject-errors': 'off',
|
|
199
|
+
'prefer-regex-literals': 'off',
|
|
200
|
+
'prefer-rest-params': 'error',
|
|
201
|
+
'prefer-spread': 'error',
|
|
202
|
+
'prefer-template': 'error',
|
|
203
|
+
'quote-props': 'off',
|
|
204
|
+
'radix': 'error',
|
|
205
|
+
'require-unicode-regexp': 'off',
|
|
206
|
+
'require-yield': 'error',
|
|
207
|
+
'sort-imports': ['error', { ignoreDeclarationSort: true }],
|
|
208
|
+
'sort-keys': 'off',
|
|
209
|
+
'sort-vars': 'off',
|
|
210
|
+
'spaced-comment': 'error',
|
|
211
|
+
'strict': jsts(['error', 'global'], 'off'),
|
|
212
|
+
'symbol-description': 'off',
|
|
213
|
+
'vars-on-top': 'off',
|
|
214
|
+
'yoda': 'error',
|
|
215
|
+
// Layout
|
|
216
|
+
'array-bracket-newline': ['error', 'consistent'],
|
|
217
|
+
'array-bracket-spacing': 'error',
|
|
218
|
+
'array-element-newline': 'off',
|
|
219
|
+
'arrow-parens': ['error', 'as-needed'],
|
|
220
|
+
'arrow-spacing': 'error',
|
|
221
|
+
'block-spacing': 'error',
|
|
222
|
+
'comma-style': ['error', 'last', { exceptions: { ArrayExpression: true } }],
|
|
223
|
+
'computed-property-spacing': 'error',
|
|
224
|
+
'dot-location': ['error', 'property'],
|
|
225
|
+
'eol-last': 'error',
|
|
226
|
+
'function-call-argument-newline': ['error', 'consistent'],
|
|
227
|
+
'function-paren-newline': ['error', 'consistent'],
|
|
228
|
+
'generator-star-spacing': ['error', 'both'],
|
|
229
|
+
'implicit-arrow-linebreak': 'off',
|
|
230
|
+
'jsx-quotes': 'error',
|
|
231
|
+
'key-spacing': ['error', { mode: 'minimum' }],
|
|
232
|
+
'line-comment-position': 'off',
|
|
233
|
+
'linebreak-style': 'error',
|
|
234
|
+
// In TypeScript files, lines-around-comment doesn't work well at the start of a block.
|
|
235
|
+
'lines-around-comment': jsts(['error', { allowBlockStart: true, allowObjectStart: true }], 'off'),
|
|
236
|
+
'max-len': ['error', { code: 100 }],
|
|
237
|
+
'max-statements-per-line': 'error',
|
|
238
|
+
'multiline-ternary': 'off',
|
|
239
|
+
'new-parens': 'error',
|
|
240
|
+
'newline-per-chained-call': 'off',
|
|
241
|
+
'no-mixed-spaces-and-tabs': 'off',
|
|
242
|
+
'no-multi-spaces': 'off',
|
|
243
|
+
'no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],
|
|
244
|
+
'no-tabs': 'error',
|
|
245
|
+
'no-trailing-spaces': 'error',
|
|
246
|
+
'no-whitespace-before-property': 'error',
|
|
247
|
+
'nonblock-statement-body-position': 'off',
|
|
248
|
+
'object-curly-newline': 'off',
|
|
249
|
+
'object-property-newline': ['error', { allowMultiplePropertiesPerLine: true }],
|
|
250
|
+
'operator-linebreak': ['error', 'after'],
|
|
251
|
+
'padded-blocks': ['error', 'never'],
|
|
252
|
+
'rest-spread-spacing': 'error',
|
|
253
|
+
'semi-spacing': 'error',
|
|
254
|
+
'semi-style': 'error',
|
|
255
|
+
'space-in-parens': 'error',
|
|
256
|
+
'space-unary-ops': 'error',
|
|
257
|
+
'switch-colon-spacing': ['error', { after: true, before: false }],
|
|
258
|
+
'template-curly-spacing': 'error',
|
|
259
|
+
'template-tag-spacing': ['error', 'always'],
|
|
260
|
+
'unicode-bom': 'error',
|
|
261
|
+
'wrap-iife': 'off',
|
|
262
|
+
'wrap-regex': 'off',
|
|
263
|
+
'yield-star-spacing': ['error', 'both'],
|
|
264
|
+
},
|
|
265
|
+
[exports.HYBRID]: {
|
|
266
|
+
// Problem
|
|
267
|
+
'no-dupe-class-members': 'error',
|
|
268
|
+
'no-loss-of-precision': 'error',
|
|
269
|
+
'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' }]),
|
|
270
|
+
'no-use-before-define': 'off',
|
|
271
|
+
// Suggestion
|
|
272
|
+
'default-param-last': 'off',
|
|
273
|
+
'dot-notation': 'error',
|
|
274
|
+
'init-declarations': 'off',
|
|
275
|
+
'no-array-constructor': 'error',
|
|
276
|
+
'no-empty-function': 'off',
|
|
277
|
+
'no-extra-semi': 'error',
|
|
278
|
+
'no-implied-eval': 'off',
|
|
279
|
+
'no-invalid-this': 'off',
|
|
280
|
+
'no-loop-func': 'error',
|
|
281
|
+
'no-magic-numbers': 'off',
|
|
282
|
+
// Redeclarations are acceptable in TypeScript.
|
|
283
|
+
'no-redeclare': jsts(['error', { builtinGlobals: true }], 'off'),
|
|
284
|
+
'no-restricted-imports': 'off',
|
|
285
|
+
'no-shadow': 'off',
|
|
286
|
+
'no-throw-literal': 'error',
|
|
287
|
+
'no-unused-expressions': 'error',
|
|
288
|
+
'no-useless-constructor': 'error',
|
|
289
|
+
'require-await': 'error',
|
|
290
|
+
// Layout
|
|
291
|
+
'brace-style': ['error', 'allman'],
|
|
292
|
+
'comma-dangle': ['error', 'always-multiline'],
|
|
293
|
+
'comma-spacing': 'error',
|
|
294
|
+
'func-call-spacing': 'off',
|
|
295
|
+
// typescript-eslint rule is flawed.
|
|
296
|
+
'indent': jsts([
|
|
297
|
+
'error',
|
|
298
|
+
4,
|
|
299
|
+
{
|
|
300
|
+
CallExpression: { arguments: 'first' },
|
|
301
|
+
FunctionDeclaration: { parameters: 'first' },
|
|
302
|
+
FunctionExpression: { parameters: 'first' },
|
|
303
|
+
MemberExpression: 0,
|
|
304
|
+
VariableDeclarator: 0,
|
|
305
|
+
ignoredNodes: [
|
|
306
|
+
'ArrowFunctionExpression',
|
|
307
|
+
'ClassDeclaration[superClass]',
|
|
308
|
+
'ConditionalExpression',
|
|
309
|
+
'ImportDeclaration',
|
|
310
|
+
],
|
|
311
|
+
},
|
|
312
|
+
], 'off'),
|
|
313
|
+
'keyword-spacing': 'error',
|
|
314
|
+
'lines-between-class-members': 'off',
|
|
315
|
+
'no-extra-parens': 'error',
|
|
316
|
+
'object-curly-spacing': ['error', 'always'],
|
|
317
|
+
'padding-line-between-statements': [
|
|
318
|
+
'error',
|
|
319
|
+
{
|
|
320
|
+
blankLine: 'always',
|
|
321
|
+
prev: '*',
|
|
322
|
+
next: ['class', 'directive', 'export', 'function', 'import'],
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
blankLine: 'always',
|
|
326
|
+
prev: ['class', 'directive', 'export', 'function', 'import'],
|
|
327
|
+
next: '*',
|
|
328
|
+
},
|
|
329
|
+
{ blankLine: 'any', prev: 'export', next: 'export' },
|
|
330
|
+
{ blankLine: 'any', prev: 'import', next: 'import' },
|
|
331
|
+
],
|
|
332
|
+
'quotes': ['error', 'single'],
|
|
333
|
+
'semi': 'error',
|
|
334
|
+
'space-before-blocks': 'error',
|
|
335
|
+
'space-before-function-paren': 'off',
|
|
336
|
+
// typescript-eslint rule does not handle well colons (":") in mapped types.
|
|
337
|
+
'space-infix-ops': jsts('error', 'off'),
|
|
338
|
+
},
|
|
339
|
+
'@typescript-eslint/eslint-plugin': tsOnly({
|
|
340
|
+
// Problem
|
|
341
|
+
'await-thenable': 'error',
|
|
342
|
+
'ban-ts-comment': 'off',
|
|
343
|
+
'class-literal-property-style': ['error', 'getters'],
|
|
344
|
+
'explicit-function-return-type': ['error', { allowTypedFunctionExpressions: false }],
|
|
345
|
+
'explicit-member-accessibility': 'error',
|
|
346
|
+
'explicit-module-boundary-types': 'error',
|
|
347
|
+
'no-confusing-non-null-assertion': 'error',
|
|
348
|
+
'no-confusing-void-expression': 'off',
|
|
349
|
+
'no-duplicate-enum-values': 'off',
|
|
350
|
+
'no-extra-non-null-assertion': 'error',
|
|
351
|
+
'no-floating-promises': 'error',
|
|
352
|
+
'no-for-in-array': 'error',
|
|
353
|
+
'no-invalid-void-type': 'off',
|
|
354
|
+
'no-misused-new': 'error',
|
|
355
|
+
'no-misused-promises': 'error',
|
|
356
|
+
'no-non-null-asserted-nullish-coalescing': 'error',
|
|
357
|
+
'no-non-null-asserted-optional-chain': 'error',
|
|
358
|
+
'no-non-null-assertion': 'off',
|
|
359
|
+
'no-require-imports': 'error',
|
|
360
|
+
'no-unsafe-argument': 'error',
|
|
361
|
+
'no-unsafe-assignment': 'error',
|
|
362
|
+
'no-unsafe-call': 'off',
|
|
363
|
+
'no-unsafe-member-access': 'error',
|
|
364
|
+
'no-unsafe-return': 'error',
|
|
365
|
+
'no-var-requires': 'error',
|
|
366
|
+
'parameter-properties': ['error', { prefer: 'parameter-property' }],
|
|
367
|
+
'prefer-reduce-type-parameter': 'error',
|
|
368
|
+
'prefer-ts-expect-error': 'error',
|
|
369
|
+
'require-array-sort-compare': 'off',
|
|
370
|
+
'restrict-plus-operands': 'off',
|
|
371
|
+
'restrict-template-expressions': 'off',
|
|
372
|
+
'return-await': 'error',
|
|
373
|
+
'unbound-method': 'off',
|
|
374
|
+
// Suggestion
|
|
375
|
+
'adjacent-overload-signatures': 'error',
|
|
376
|
+
'array-type': 'error',
|
|
377
|
+
'ban-tslint-comment': 'error',
|
|
378
|
+
'ban-types': 'off',
|
|
379
|
+
'consistent-generic-constructors': 'error',
|
|
380
|
+
'consistent-indexed-object-style': 'error',
|
|
381
|
+
'consistent-type-assertions': 'error',
|
|
382
|
+
'consistent-type-definitions': ['error', 'interface'],
|
|
383
|
+
'consistent-type-exports': 'error',
|
|
384
|
+
'consistent-type-imports': beforeOrElse('3.8.0', ['error', { prefer: 'no-type-imports' }], 'error'),
|
|
385
|
+
'member-delimiter-style': ['error', { singleline: { requireLast: true } }],
|
|
386
|
+
'member-ordering': 'error',
|
|
387
|
+
'method-signature-style': 'off',
|
|
388
|
+
'naming-convention': 'off',
|
|
389
|
+
'no-base-to-string': 'error',
|
|
390
|
+
'no-dynamic-delete': 'off',
|
|
391
|
+
'no-empty-interface': ['error', { allowSingleExtends: true }],
|
|
392
|
+
'no-explicit-any': 'off',
|
|
393
|
+
'no-extraneous-class': ['error', { allowConstructorOnly: true }],
|
|
394
|
+
'no-inferrable-types': 'error',
|
|
395
|
+
'no-meaningless-void-operator': ['error', { checkNever: true }],
|
|
396
|
+
'no-namespace': 'off',
|
|
397
|
+
'no-redundant-type-constituents': 'error',
|
|
398
|
+
'no-this-alias': 'off',
|
|
399
|
+
'no-type-alias': 'off',
|
|
400
|
+
'no-unnecessary-boolean-literal-compare': 'error',
|
|
401
|
+
'no-unnecessary-condition': 'error',
|
|
402
|
+
'no-unnecessary-qualifier': 'error',
|
|
403
|
+
'no-unnecessary-type-arguments': 'error',
|
|
404
|
+
'no-unnecessary-type-assertion': 'error',
|
|
405
|
+
'no-unnecessary-type-constraint': 'error',
|
|
406
|
+
'no-useless-empty-export': 'error',
|
|
407
|
+
'non-nullable-type-assertion-style': 'error',
|
|
408
|
+
'prefer-as-const': 'error',
|
|
409
|
+
'prefer-enum-initializers': 'off',
|
|
410
|
+
'prefer-for-of': 'error',
|
|
411
|
+
// https://github.com/typescript-eslint/typescript-eslint/issues/454
|
|
412
|
+
'prefer-function-type': 'off',
|
|
413
|
+
'prefer-includes': 'error',
|
|
414
|
+
'prefer-literal-enum-member': 'off',
|
|
415
|
+
'prefer-namespace-keyword': 'off',
|
|
416
|
+
'prefer-nullish-coalescing': 'error',
|
|
417
|
+
'prefer-optional-chain': 'error',
|
|
418
|
+
'prefer-readonly': 'error',
|
|
419
|
+
'prefer-readonly-parameter-types': 'off',
|
|
420
|
+
'prefer-regexp-exec': 'error',
|
|
421
|
+
'prefer-return-this-type': 'error',
|
|
422
|
+
'prefer-string-starts-ends-with': 'error',
|
|
423
|
+
'promise-function-async': ['error', { allowAny: true }],
|
|
424
|
+
'sort-type-union-intersection-members': 'off',
|
|
425
|
+
'strict-boolean-expressions': 'off',
|
|
426
|
+
'switch-exhaustiveness-check': 'error',
|
|
427
|
+
'triple-slash-reference': ['error', { lib: 'never' }],
|
|
428
|
+
'typedef': 'error',
|
|
429
|
+
'unified-signatures': 'error',
|
|
430
|
+
// Layout
|
|
431
|
+
'type-annotation-spacing': 'error',
|
|
432
|
+
}),
|
|
433
|
+
'@fasttime/eslint-plugin': {
|
|
434
|
+
// Layout
|
|
435
|
+
'nice-space-before-function-paren': 'error',
|
|
436
|
+
'no-spaces-in-call-expression': 'error',
|
|
437
|
+
},
|
|
438
|
+
'eslint-plugin-n': {
|
|
439
|
+
// Problem
|
|
440
|
+
'no-callback-literal': 'off',
|
|
441
|
+
'no-deprecated-api': 'error',
|
|
442
|
+
'no-exports-assign': 'error',
|
|
443
|
+
'no-extraneous-import': jsts('error', 'off'),
|
|
444
|
+
'no-extraneous-require': 'error',
|
|
445
|
+
'no-missing-import': 'off',
|
|
446
|
+
'no-missing-require': 'off',
|
|
447
|
+
'no-unpublished-bin': 'error',
|
|
448
|
+
'no-unpublished-import': 'error',
|
|
449
|
+
'no-unpublished-require': 'off',
|
|
450
|
+
'no-unsupported-features/es-builtins': 'off',
|
|
451
|
+
'no-unsupported-features/es-syntax': 'off',
|
|
452
|
+
'no-unsupported-features/node-builtins': 'off',
|
|
453
|
+
'process-exit-as-throw': 'error',
|
|
454
|
+
'shebang': 'off',
|
|
455
|
+
// Suggestion
|
|
456
|
+
'callback-return': 'off',
|
|
457
|
+
'exports-style': 'off',
|
|
458
|
+
'file-extension-in-import': 'off',
|
|
459
|
+
'global-require': 'off',
|
|
460
|
+
'handle-callback-err': 'error',
|
|
461
|
+
'no-mixed-requires': 'error',
|
|
462
|
+
'no-new-require': 'error',
|
|
463
|
+
'no-path-concat': 'error',
|
|
464
|
+
'no-process-env': 'off',
|
|
465
|
+
'no-process-exit': 'off',
|
|
466
|
+
'no-restricted-import': 'error',
|
|
467
|
+
'no-restricted-require': 'error',
|
|
468
|
+
'no-sync': 'off',
|
|
469
|
+
'prefer-global/buffer': 'error',
|
|
470
|
+
'prefer-global/console': 'error',
|
|
471
|
+
'prefer-global/process': 'error',
|
|
472
|
+
'prefer-global/text-decoder': 'error',
|
|
473
|
+
'prefer-global/text-encoder': 'error',
|
|
474
|
+
'prefer-global/url': 'error',
|
|
475
|
+
'prefer-global/url-search-params': 'error',
|
|
476
|
+
'prefer-promises/dns': 'error',
|
|
477
|
+
'prefer-promises/fs': 'off',
|
|
478
|
+
},
|
|
479
|
+
};
|
package/no-parser.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@origin-1/eslint-config",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "ESLint configuration generator with origin-1 presets",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "Francesco Trotta <ft@fasttime.org> (https://github.com/fasttime)",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@fasttime/eslint-plugin": "0.6",
|
|
9
|
+
"@types/eslint": "8",
|
|
10
|
+
"@typescript-eslint/eslint-plugin": "5.30",
|
|
11
|
+
"@typescript-eslint/parser": "5.30",
|
|
12
|
+
"eslint-plugin-n": "15.2",
|
|
13
|
+
"semver": "7"
|
|
14
|
+
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"eslint": "8"
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./index.js",
|
|
23
|
+
"./no-parser": "./no-parser.js",
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
}
|
|
26
|
+
}
|