@zthun/janitor-eslint-config 19.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.md +20 -0
- package/README.md +28 -0
- package/dist/configs/environments.d.mts +5 -0
- package/dist/configs/imports.d.mts +2 -0
- package/dist/configs/javascript.d.mts +2 -0
- package/dist/configs/prettier.d.mts +1 -0
- package/dist/configs/react.d.mts +2 -0
- package/dist/configs/recommended.d.mts +1 -0
- package/dist/configs/typescript.d.mts +1 -0
- package/dist/index.cjs +196 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +186 -0
- package/dist/index.js.map +1 -0
- package/package.json +62 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Anthony Bonta
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# ESLint Config
|
|
2
|
+
|
|
3
|
+
This is the shared eslint configuration for zthun scoped projects.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
# NPM
|
|
9
|
+
npm install @zthun/janitor-eslint-config --save-dev
|
|
10
|
+
# Yarn
|
|
11
|
+
yarn add @zthun/janitor-eslint-config --dev
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Make sure to install typescript and @typescript-eslint/eslint-plugin with all
|
|
15
|
+
peer dependencies.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
In the .eslintrc file, add the following
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"extends": ["@zthun/janitor-eslint-config"]
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
That's it. You now have the recommended rules for zthun scoped projects with
|
|
28
|
+
typescript.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const prettier: import("eslint").Linter.Config<import("eslint").Linter.RulesRecord>[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const recommended: (import("eslint").Linter.Config<import("eslint").Linter.RulesRecord> | import("@typescript-eslint/utils/ts-eslint").FlatConfig.Config)[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const typescript: import("@typescript-eslint/utils/ts-eslint").FlatConfig.Config[];
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
|
|
5
|
+
const globals = require('globals');
|
|
6
|
+
const _import = require('eslint-plugin-import');
|
|
7
|
+
const js = require('@eslint/js');
|
|
8
|
+
const pretty = require('eslint-plugin-prettier/recommended');
|
|
9
|
+
const _react = require('eslint-plugin-react');
|
|
10
|
+
const ts = require('typescript-eslint');
|
|
11
|
+
|
|
12
|
+
function _define_property(obj, key, value) {
|
|
13
|
+
if (key in obj) {
|
|
14
|
+
Object.defineProperty(obj, key, {
|
|
15
|
+
value: value,
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
obj[key] = value;
|
|
22
|
+
}
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
25
|
+
function _object_spread(target) {
|
|
26
|
+
for(var i = 1; i < arguments.length; i++){
|
|
27
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
28
|
+
var ownKeys = Object.keys(source);
|
|
29
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
30
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
31
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
ownKeys.forEach(function(key) {
|
|
35
|
+
_define_property(target, key, source[key]);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return target;
|
|
39
|
+
}
|
|
40
|
+
function environment(environment) {
|
|
41
|
+
return {
|
|
42
|
+
languageOptions: {
|
|
43
|
+
globals: _object_spread({}, environment)
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const environments = {
|
|
48
|
+
browser: [
|
|
49
|
+
environment(globals.browser)
|
|
50
|
+
],
|
|
51
|
+
node: [
|
|
52
|
+
environment(globals.node),
|
|
53
|
+
environment(globals.nodeBuiltin)
|
|
54
|
+
]
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const imports = [
|
|
58
|
+
_import.flatConfigs.recommended,
|
|
59
|
+
{
|
|
60
|
+
rules: {
|
|
61
|
+
// This lint error is the main reason to use import as we want to make
|
|
62
|
+
// sure we've installed our dependencies correctly.
|
|
63
|
+
"import/no-extraneous-dependencies": "error",
|
|
64
|
+
// These are straight up broken with Typescript when you need to work with
|
|
65
|
+
// mts files that must have the file extension present. These can be fixed
|
|
66
|
+
// using resolves, but it's such a pain and it's just not worth the hassle
|
|
67
|
+
// for basic linting support. The no-extraneous-dependencies is really
|
|
68
|
+
// the recommended config we want, so these being forced off are fine.
|
|
69
|
+
"import/named": "off",
|
|
70
|
+
"import/no-unresolved": "off"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const javascript = [
|
|
76
|
+
js.configs.recommended,
|
|
77
|
+
{
|
|
78
|
+
rules: {
|
|
79
|
+
// We want to support == null so we get a good check for undefined
|
|
80
|
+
// or null
|
|
81
|
+
eqeqeq: [
|
|
82
|
+
"error",
|
|
83
|
+
"smart"
|
|
84
|
+
],
|
|
85
|
+
// Would be fine, but there's a bug in this where you have a function with
|
|
86
|
+
// access arguments. Those constructors are often empty - so we want to let
|
|
87
|
+
// a part of this one through.
|
|
88
|
+
"no-empty-function": "off"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
const prettier = [
|
|
94
|
+
pretty
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
const react = [
|
|
98
|
+
{
|
|
99
|
+
files: [
|
|
100
|
+
"**/*.{js,cjs,mjs,ts,mts,jsx,tsx}"
|
|
101
|
+
],
|
|
102
|
+
plugins: {
|
|
103
|
+
react: _react
|
|
104
|
+
},
|
|
105
|
+
languageOptions: {
|
|
106
|
+
parserOptions: {
|
|
107
|
+
ecmaFeatures: {
|
|
108
|
+
jsx: true
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
settings: {
|
|
113
|
+
react: {
|
|
114
|
+
version: "detect"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
rules: {
|
|
118
|
+
// This one is not needed any longer as TypeScript jsx option
|
|
119
|
+
// should be set to react-jsx. You will need to turn this on
|
|
120
|
+
// manually if it is set to the legacy react setting. See
|
|
121
|
+
// https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#whats-different-in-the-new-transform
|
|
122
|
+
"react/react-in-jsx-scope": "off"
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
const typescript = [
|
|
128
|
+
...ts.configs.recommended,
|
|
129
|
+
{
|
|
130
|
+
rules: {
|
|
131
|
+
// There are times when any and legacy namespaces makes sense.
|
|
132
|
+
// If you use any kind of decorator library, you will almost
|
|
133
|
+
// be required to use any at some point. Forcing a non use of them
|
|
134
|
+
// means you're spending a bunch of time play type gymnastics and to
|
|
135
|
+
// hell with that.
|
|
136
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
137
|
+
"@typescript-eslint/no-namespace": "off",
|
|
138
|
+
// Would be fine, but there's a bug in this where you have a function with
|
|
139
|
+
// access arguments. Those constructors are often empty - so we want to let
|
|
140
|
+
// a part of this one through.
|
|
141
|
+
"no-empty-function": "off",
|
|
142
|
+
"@typescript-eslint/no-empty-function": [
|
|
143
|
+
"error",
|
|
144
|
+
{
|
|
145
|
+
allow: [
|
|
146
|
+
"constructors"
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
// A lot of 3rd party libraries still don't support esm
|
|
151
|
+
// and trying to force this right now just isn't feasible.
|
|
152
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
153
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
154
|
+
// I want aliasing support.
|
|
155
|
+
"@typescript-eslint/no-empty-object-type": "off",
|
|
156
|
+
"@typescript-eslint/no-empty-interface": "off",
|
|
157
|
+
// You will need unsafe declaration merging if you are doing anything
|
|
158
|
+
// with decorators as what often happens is that TypeScript cannot infer
|
|
159
|
+
// the output type of a decorator. So this has to be on to deal with
|
|
160
|
+
// TypeScripts shortcoming in this department. See
|
|
161
|
+
// https://github.com/microsoft/TypeScript/issues/4881 for more information.
|
|
162
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "off",
|
|
163
|
+
// I can technically agree with this, but where this comes in
|
|
164
|
+
// handy is unit testing and I value that, so I want support
|
|
165
|
+
// to make the assumption that I know what I'm doing when
|
|
166
|
+
// I make a non-null assertion.
|
|
167
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
168
|
+
// This is actually fine, but this is broken in typescript eslint 8.14.x.
|
|
169
|
+
// See https://github.com/typescript-eslint/typescript-eslint/issues/10353
|
|
170
|
+
// for the bug.
|
|
171
|
+
"no-unused-expressions": "off",
|
|
172
|
+
"@typescript-eslint/no-unused-expressions": [
|
|
173
|
+
"error",
|
|
174
|
+
{
|
|
175
|
+
allowShortCircuit: false
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
];
|
|
181
|
+
|
|
182
|
+
const recommended = [
|
|
183
|
+
...javascript,
|
|
184
|
+
...typescript,
|
|
185
|
+
...imports,
|
|
186
|
+
...prettier
|
|
187
|
+
];
|
|
188
|
+
|
|
189
|
+
exports.environments = environments;
|
|
190
|
+
exports.imports = imports;
|
|
191
|
+
exports.javascript = javascript;
|
|
192
|
+
exports.prettier = prettier;
|
|
193
|
+
exports.react = react;
|
|
194
|
+
exports.recommended = recommended;
|
|
195
|
+
exports.typescript = typescript;
|
|
196
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/configs/environments.mts","../src/configs/imports.mts","../src/configs/javascript.mts","../src/configs/prettier.mts","../src/configs/react.mts","../src/configs/typescript.mts","../src/configs/recommended.mts"],"sourcesContent":["import { Linter } from \"eslint\";\nimport globals from \"globals\";\n\nfunction environment(environment: object): Linter.Config {\n return {\n languageOptions: {\n globals: {\n ...environment,\n },\n },\n };\n}\n\nexport const environments = {\n browser: [environment(globals.browser)],\n node: [environment(globals.node), environment(globals.nodeBuiltin)],\n};\n","import { Linter } from \"eslint\";\nimport _import from \"eslint-plugin-import\";\n\nexport const imports: Linter.Config[] = [\n _import.flatConfigs.recommended,\n {\n rules: {\n // This lint error is the main reason to use import as we want to make\n // sure we've installed our dependencies correctly.\n \"import/no-extraneous-dependencies\": \"error\",\n\n // These are straight up broken with Typescript when you need to work with\n // mts files that must have the file extension present. These can be fixed\n // using resolves, but it's such a pain and it's just not worth the hassle\n // for basic linting support. The no-extraneous-dependencies is really\n // the recommended config we want, so these being forced off are fine.\n \"import/named\": \"off\",\n \"import/no-unresolved\": \"off\",\n },\n } satisfies Linter.Config,\n];\n","import js from \"@eslint/js\";\nimport { Linter } from \"eslint\";\n\nexport const javascript: Linter.Config[] = [\n js.configs.recommended,\n {\n rules: {\n // We want to support == null so we get a good check for undefined\n // or null\n eqeqeq: [\"error\", \"smart\"],\n // Would be fine, but there's a bug in this where you have a function with\n // access arguments. Those constructors are often empty - so we want to let\n // a part of this one through.\n \"no-empty-function\": \"off\",\n },\n },\n];\n","import pretty from \"eslint-plugin-prettier/recommended\";\n\nexport const prettier = [pretty];\n","import { ESLint, Linter } from \"eslint\";\nimport _react from \"eslint-plugin-react\";\n\nexport const react: Linter.Config[] = [\n {\n files: [\"**/*.{js,cjs,mjs,ts,mts,jsx,tsx}\"],\n plugins: {\n react: _react as ESLint.Plugin,\n },\n languageOptions: {\n parserOptions: {\n ecmaFeatures: {\n jsx: true,\n },\n },\n },\n settings: {\n react: {\n version: \"detect\",\n },\n },\n rules: {\n // This one is not needed any longer as TypeScript jsx option\n // should be set to react-jsx. You will need to turn this on\n // manually if it is set to the legacy react setting. See\n // https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#whats-different-in-the-new-transform\n \"react/react-in-jsx-scope\": \"off\",\n },\n },\n];\n","import { Linter } from \"eslint\";\nimport ts from \"typescript-eslint\";\n\nexport const typescript = [\n ...ts.configs.recommended,\n {\n rules: {\n // There are times when any and legacy namespaces makes sense.\n // If you use any kind of decorator library, you will almost\n // be required to use any at some point. Forcing a non use of them\n // means you're spending a bunch of time play type gymnastics and to\n // hell with that.\n \"@typescript-eslint/no-explicit-any\": \"off\",\n \"@typescript-eslint/no-namespace\": \"off\",\n\n // Would be fine, but there's a bug in this where you have a function with\n // access arguments. Those constructors are often empty - so we want to let\n // a part of this one through.\n \"no-empty-function\": \"off\",\n \"@typescript-eslint/no-empty-function\": [\n \"error\",\n { allow: [\"constructors\"] },\n ],\n\n // A lot of 3rd party libraries still don't support esm\n // and trying to force this right now just isn't feasible.\n \"@typescript-eslint/no-var-requires\": \"off\",\n \"@typescript-eslint/no-require-imports\": \"off\",\n\n // I want aliasing support.\n \"@typescript-eslint/no-empty-object-type\": \"off\",\n \"@typescript-eslint/no-empty-interface\": \"off\",\n\n // You will need unsafe declaration merging if you are doing anything\n // with decorators as what often happens is that TypeScript cannot infer\n // the output type of a decorator. So this has to be on to deal with\n // TypeScripts shortcoming in this department. See\n // https://github.com/microsoft/TypeScript/issues/4881 for more information.\n \"@typescript-eslint/no-unsafe-declaration-merging\": \"off\",\n\n // I can technically agree with this, but where this comes in\n // handy is unit testing and I value that, so I want support\n // to make the assumption that I know what I'm doing when\n // I make a non-null assertion.\n \"@typescript-eslint/no-non-null-assertion\": \"off\",\n\n // This is actually fine, but this is broken in typescript eslint 8.14.x.\n // See https://github.com/typescript-eslint/typescript-eslint/issues/10353\n // for the bug.\n \"no-unused-expressions\": \"off\",\n \"@typescript-eslint/no-unused-expressions\": [\n \"error\",\n {\n allowShortCircuit: false,\n },\n ],\n },\n } satisfies Linter.Config,\n];\n","import { imports } from \"./imports.mjs\";\nimport { javascript } from \"./javascript.mjs\";\nimport { prettier } from \"./prettier.mjs\";\nimport { typescript } from \"./typescript.mjs\";\n\nexport const recommended = [\n ...javascript,\n ...typescript,\n ...imports,\n ...prettier,\n];\n"],"names":["environment","languageOptions","globals","environments","browser","node","nodeBuiltin","imports","_import","flatConfigs","recommended","rules","javascript","js","configs","eqeqeq","prettier","pretty","react","files","plugins","_react","parserOptions","ecmaFeatures","jsx","settings","version","typescript","ts","allow","allowShortCircuit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,YAAYA,WAAmB,EAAA;IACtC,OAAO;QACLC,eAAiB,EAAA;AACfC,YAAAA,OAAAA,EAAS,cACJF,CAAAA,EAAAA,EAAAA,WAAAA;AAEP;AACF,KAAA;AACF;MAEaG,YAAe,GAAA;IAC1BC,OAAS,EAAA;AAACJ,QAAAA,WAAAA,CAAYE,QAAQE,OAAO;AAAE,KAAA;IACvCC,IAAM,EAAA;AAACL,QAAAA,WAAAA,CAAYE,QAAQG,IAAI,CAAA;AAAGL,QAAAA,WAAAA,CAAYE,QAAQI,WAAW;AAAE;AACrE;;MCbaC,OAA2B,GAAA;IACtCC,OAAQC,CAAAA,WAAW,CAACC,WAAW;AAC/B,IAAA;QACEC,KAAO,EAAA;;;YAGL,mCAAqC,EAAA,OAAA;;;;;;YAOrC,cAAgB,EAAA,KAAA;YAChB,sBAAwB,EAAA;AAC1B;AACF;;;MChBWC,UAA8B,GAAA;IACzCC,EAAGC,CAAAA,OAAO,CAACJ,WAAW;AACtB,IAAA;QACEC,KAAO,EAAA;;;YAGLI,MAAQ,EAAA;AAAC,gBAAA,OAAA;AAAS,gBAAA;AAAQ,aAAA;;;;YAI1B,mBAAqB,EAAA;AACvB;AACF;;;MCbWC,QAAW,GAAA;AAACC,IAAAA;;;MCCZC,KAAyB,GAAA;AACpC,IAAA;QACEC,KAAO,EAAA;AAAC,YAAA;AAAmC,SAAA;QAC3CC,OAAS,EAAA;YACPF,KAAOG,EAAAA;AACT,SAAA;QACApB,eAAiB,EAAA;YACfqB,aAAe,EAAA;gBACbC,YAAc,EAAA;oBACZC,GAAK,EAAA;AACP;AACF;AACF,SAAA;QACAC,QAAU,EAAA;YACRP,KAAO,EAAA;gBACLQ,OAAS,EAAA;AACX;AACF,SAAA;QACAf,KAAO,EAAA;;;;;YAKL,0BAA4B,EAAA;AAC9B;AACF;;;MCzBWgB,UAAa,GAAA;OACrBC,EAAGd,CAAAA,OAAO,CAACJ,WAAW;AACzB,IAAA;QACEC,KAAO,EAAA;;;;;;YAML,oCAAsC,EAAA,KAAA;YACtC,iCAAmC,EAAA,KAAA;;;;YAKnC,mBAAqB,EAAA,KAAA;YACrB,sCAAwC,EAAA;AACtC,gBAAA,OAAA;AACA,gBAAA;oBAAEkB,KAAO,EAAA;AAAC,wBAAA;AAAe;AAAC;AAC3B,aAAA;;;YAID,oCAAsC,EAAA,KAAA;YACtC,uCAAyC,EAAA,KAAA;;YAGzC,yCAA2C,EAAA,KAAA;YAC3C,uCAAyC,EAAA,KAAA;;;;;;YAOzC,kDAAoD,EAAA,KAAA;;;;;YAMpD,0CAA4C,EAAA,KAAA;;;;YAK5C,uBAAyB,EAAA,KAAA;YACzB,0CAA4C,EAAA;AAC1C,gBAAA,OAAA;AACA,gBAAA;oBACEC,iBAAmB,EAAA;AACrB;AACD;AACH;AACF;;;MCpDWpB,WAAc,GAAA;AACtBE,IAAAA,GAAAA,UAAAA;AACAe,IAAAA,GAAAA,UAAAA;AACApB,IAAAA,GAAAA,OAAAA;AACAS,IAAAA,GAAAA;;;;;;;;;;;"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './configs/environments.mjs';
|
|
2
|
+
export * from './configs/imports.mjs';
|
|
3
|
+
export * from './configs/javascript.mjs';
|
|
4
|
+
export * from './configs/prettier.mjs';
|
|
5
|
+
export * from './configs/react.mjs';
|
|
6
|
+
export * from './configs/recommended.mjs';
|
|
7
|
+
export * from './configs/typescript.mjs';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import globals from 'globals';
|
|
2
|
+
import _import from 'eslint-plugin-import';
|
|
3
|
+
import js from '@eslint/js';
|
|
4
|
+
import pretty from 'eslint-plugin-prettier/recommended';
|
|
5
|
+
import _react from 'eslint-plugin-react';
|
|
6
|
+
import ts from 'typescript-eslint';
|
|
7
|
+
|
|
8
|
+
function _define_property(obj, key, value) {
|
|
9
|
+
if (key in obj) {
|
|
10
|
+
Object.defineProperty(obj, key, {
|
|
11
|
+
value: value,
|
|
12
|
+
enumerable: true,
|
|
13
|
+
configurable: true,
|
|
14
|
+
writable: true
|
|
15
|
+
});
|
|
16
|
+
} else {
|
|
17
|
+
obj[key] = value;
|
|
18
|
+
}
|
|
19
|
+
return obj;
|
|
20
|
+
}
|
|
21
|
+
function _object_spread(target) {
|
|
22
|
+
for(var i = 1; i < arguments.length; i++){
|
|
23
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
24
|
+
var ownKeys = Object.keys(source);
|
|
25
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
26
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
27
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
ownKeys.forEach(function(key) {
|
|
31
|
+
_define_property(target, key, source[key]);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
}
|
|
36
|
+
function environment(environment) {
|
|
37
|
+
return {
|
|
38
|
+
languageOptions: {
|
|
39
|
+
globals: _object_spread({}, environment)
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const environments = {
|
|
44
|
+
browser: [
|
|
45
|
+
environment(globals.browser)
|
|
46
|
+
],
|
|
47
|
+
node: [
|
|
48
|
+
environment(globals.node),
|
|
49
|
+
environment(globals.nodeBuiltin)
|
|
50
|
+
]
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const imports = [
|
|
54
|
+
_import.flatConfigs.recommended,
|
|
55
|
+
{
|
|
56
|
+
rules: {
|
|
57
|
+
// This lint error is the main reason to use import as we want to make
|
|
58
|
+
// sure we've installed our dependencies correctly.
|
|
59
|
+
"import/no-extraneous-dependencies": "error",
|
|
60
|
+
// These are straight up broken with Typescript when you need to work with
|
|
61
|
+
// mts files that must have the file extension present. These can be fixed
|
|
62
|
+
// using resolves, but it's such a pain and it's just not worth the hassle
|
|
63
|
+
// for basic linting support. The no-extraneous-dependencies is really
|
|
64
|
+
// the recommended config we want, so these being forced off are fine.
|
|
65
|
+
"import/named": "off",
|
|
66
|
+
"import/no-unresolved": "off"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
const javascript = [
|
|
72
|
+
js.configs.recommended,
|
|
73
|
+
{
|
|
74
|
+
rules: {
|
|
75
|
+
// We want to support == null so we get a good check for undefined
|
|
76
|
+
// or null
|
|
77
|
+
eqeqeq: [
|
|
78
|
+
"error",
|
|
79
|
+
"smart"
|
|
80
|
+
],
|
|
81
|
+
// Would be fine, but there's a bug in this where you have a function with
|
|
82
|
+
// access arguments. Those constructors are often empty - so we want to let
|
|
83
|
+
// a part of this one through.
|
|
84
|
+
"no-empty-function": "off"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
const prettier = [
|
|
90
|
+
pretty
|
|
91
|
+
];
|
|
92
|
+
|
|
93
|
+
const react = [
|
|
94
|
+
{
|
|
95
|
+
files: [
|
|
96
|
+
"**/*.{js,cjs,mjs,ts,mts,jsx,tsx}"
|
|
97
|
+
],
|
|
98
|
+
plugins: {
|
|
99
|
+
react: _react
|
|
100
|
+
},
|
|
101
|
+
languageOptions: {
|
|
102
|
+
parserOptions: {
|
|
103
|
+
ecmaFeatures: {
|
|
104
|
+
jsx: true
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
settings: {
|
|
109
|
+
react: {
|
|
110
|
+
version: "detect"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
rules: {
|
|
114
|
+
// This one is not needed any longer as TypeScript jsx option
|
|
115
|
+
// should be set to react-jsx. You will need to turn this on
|
|
116
|
+
// manually if it is set to the legacy react setting. See
|
|
117
|
+
// https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#whats-different-in-the-new-transform
|
|
118
|
+
"react/react-in-jsx-scope": "off"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
];
|
|
122
|
+
|
|
123
|
+
const typescript = [
|
|
124
|
+
...ts.configs.recommended,
|
|
125
|
+
{
|
|
126
|
+
rules: {
|
|
127
|
+
// There are times when any and legacy namespaces makes sense.
|
|
128
|
+
// If you use any kind of decorator library, you will almost
|
|
129
|
+
// be required to use any at some point. Forcing a non use of them
|
|
130
|
+
// means you're spending a bunch of time play type gymnastics and to
|
|
131
|
+
// hell with that.
|
|
132
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
133
|
+
"@typescript-eslint/no-namespace": "off",
|
|
134
|
+
// Would be fine, but there's a bug in this where you have a function with
|
|
135
|
+
// access arguments. Those constructors are often empty - so we want to let
|
|
136
|
+
// a part of this one through.
|
|
137
|
+
"no-empty-function": "off",
|
|
138
|
+
"@typescript-eslint/no-empty-function": [
|
|
139
|
+
"error",
|
|
140
|
+
{
|
|
141
|
+
allow: [
|
|
142
|
+
"constructors"
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
// A lot of 3rd party libraries still don't support esm
|
|
147
|
+
// and trying to force this right now just isn't feasible.
|
|
148
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
149
|
+
"@typescript-eslint/no-require-imports": "off",
|
|
150
|
+
// I want aliasing support.
|
|
151
|
+
"@typescript-eslint/no-empty-object-type": "off",
|
|
152
|
+
"@typescript-eslint/no-empty-interface": "off",
|
|
153
|
+
// You will need unsafe declaration merging if you are doing anything
|
|
154
|
+
// with decorators as what often happens is that TypeScript cannot infer
|
|
155
|
+
// the output type of a decorator. So this has to be on to deal with
|
|
156
|
+
// TypeScripts shortcoming in this department. See
|
|
157
|
+
// https://github.com/microsoft/TypeScript/issues/4881 for more information.
|
|
158
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "off",
|
|
159
|
+
// I can technically agree with this, but where this comes in
|
|
160
|
+
// handy is unit testing and I value that, so I want support
|
|
161
|
+
// to make the assumption that I know what I'm doing when
|
|
162
|
+
// I make a non-null assertion.
|
|
163
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
164
|
+
// This is actually fine, but this is broken in typescript eslint 8.14.x.
|
|
165
|
+
// See https://github.com/typescript-eslint/typescript-eslint/issues/10353
|
|
166
|
+
// for the bug.
|
|
167
|
+
"no-unused-expressions": "off",
|
|
168
|
+
"@typescript-eslint/no-unused-expressions": [
|
|
169
|
+
"error",
|
|
170
|
+
{
|
|
171
|
+
allowShortCircuit: false
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
];
|
|
177
|
+
|
|
178
|
+
const recommended = [
|
|
179
|
+
...javascript,
|
|
180
|
+
...typescript,
|
|
181
|
+
...imports,
|
|
182
|
+
...prettier
|
|
183
|
+
];
|
|
184
|
+
|
|
185
|
+
export { environments, imports, javascript, prettier, react, recommended, typescript };
|
|
186
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/configs/environments.mts","../src/configs/imports.mts","../src/configs/javascript.mts","../src/configs/prettier.mts","../src/configs/react.mts","../src/configs/typescript.mts","../src/configs/recommended.mts"],"sourcesContent":["import { Linter } from \"eslint\";\nimport globals from \"globals\";\n\nfunction environment(environment: object): Linter.Config {\n return {\n languageOptions: {\n globals: {\n ...environment,\n },\n },\n };\n}\n\nexport const environments = {\n browser: [environment(globals.browser)],\n node: [environment(globals.node), environment(globals.nodeBuiltin)],\n};\n","import { Linter } from \"eslint\";\nimport _import from \"eslint-plugin-import\";\n\nexport const imports: Linter.Config[] = [\n _import.flatConfigs.recommended,\n {\n rules: {\n // This lint error is the main reason to use import as we want to make\n // sure we've installed our dependencies correctly.\n \"import/no-extraneous-dependencies\": \"error\",\n\n // These are straight up broken with Typescript when you need to work with\n // mts files that must have the file extension present. These can be fixed\n // using resolves, but it's such a pain and it's just not worth the hassle\n // for basic linting support. The no-extraneous-dependencies is really\n // the recommended config we want, so these being forced off are fine.\n \"import/named\": \"off\",\n \"import/no-unresolved\": \"off\",\n },\n } satisfies Linter.Config,\n];\n","import js from \"@eslint/js\";\nimport { Linter } from \"eslint\";\n\nexport const javascript: Linter.Config[] = [\n js.configs.recommended,\n {\n rules: {\n // We want to support == null so we get a good check for undefined\n // or null\n eqeqeq: [\"error\", \"smart\"],\n // Would be fine, but there's a bug in this where you have a function with\n // access arguments. Those constructors are often empty - so we want to let\n // a part of this one through.\n \"no-empty-function\": \"off\",\n },\n },\n];\n","import pretty from \"eslint-plugin-prettier/recommended\";\n\nexport const prettier = [pretty];\n","import { ESLint, Linter } from \"eslint\";\nimport _react from \"eslint-plugin-react\";\n\nexport const react: Linter.Config[] = [\n {\n files: [\"**/*.{js,cjs,mjs,ts,mts,jsx,tsx}\"],\n plugins: {\n react: _react as ESLint.Plugin,\n },\n languageOptions: {\n parserOptions: {\n ecmaFeatures: {\n jsx: true,\n },\n },\n },\n settings: {\n react: {\n version: \"detect\",\n },\n },\n rules: {\n // This one is not needed any longer as TypeScript jsx option\n // should be set to react-jsx. You will need to turn this on\n // manually if it is set to the legacy react setting. See\n // https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#whats-different-in-the-new-transform\n \"react/react-in-jsx-scope\": \"off\",\n },\n },\n];\n","import { Linter } from \"eslint\";\nimport ts from \"typescript-eslint\";\n\nexport const typescript = [\n ...ts.configs.recommended,\n {\n rules: {\n // There are times when any and legacy namespaces makes sense.\n // If you use any kind of decorator library, you will almost\n // be required to use any at some point. Forcing a non use of them\n // means you're spending a bunch of time play type gymnastics and to\n // hell with that.\n \"@typescript-eslint/no-explicit-any\": \"off\",\n \"@typescript-eslint/no-namespace\": \"off\",\n\n // Would be fine, but there's a bug in this where you have a function with\n // access arguments. Those constructors are often empty - so we want to let\n // a part of this one through.\n \"no-empty-function\": \"off\",\n \"@typescript-eslint/no-empty-function\": [\n \"error\",\n { allow: [\"constructors\"] },\n ],\n\n // A lot of 3rd party libraries still don't support esm\n // and trying to force this right now just isn't feasible.\n \"@typescript-eslint/no-var-requires\": \"off\",\n \"@typescript-eslint/no-require-imports\": \"off\",\n\n // I want aliasing support.\n \"@typescript-eslint/no-empty-object-type\": \"off\",\n \"@typescript-eslint/no-empty-interface\": \"off\",\n\n // You will need unsafe declaration merging if you are doing anything\n // with decorators as what often happens is that TypeScript cannot infer\n // the output type of a decorator. So this has to be on to deal with\n // TypeScripts shortcoming in this department. See\n // https://github.com/microsoft/TypeScript/issues/4881 for more information.\n \"@typescript-eslint/no-unsafe-declaration-merging\": \"off\",\n\n // I can technically agree with this, but where this comes in\n // handy is unit testing and I value that, so I want support\n // to make the assumption that I know what I'm doing when\n // I make a non-null assertion.\n \"@typescript-eslint/no-non-null-assertion\": \"off\",\n\n // This is actually fine, but this is broken in typescript eslint 8.14.x.\n // See https://github.com/typescript-eslint/typescript-eslint/issues/10353\n // for the bug.\n \"no-unused-expressions\": \"off\",\n \"@typescript-eslint/no-unused-expressions\": [\n \"error\",\n {\n allowShortCircuit: false,\n },\n ],\n },\n } satisfies Linter.Config,\n];\n","import { imports } from \"./imports.mjs\";\nimport { javascript } from \"./javascript.mjs\";\nimport { prettier } from \"./prettier.mjs\";\nimport { typescript } from \"./typescript.mjs\";\n\nexport const recommended = [\n ...javascript,\n ...typescript,\n ...imports,\n ...prettier,\n];\n"],"names":["environment","languageOptions","globals","environments","browser","node","nodeBuiltin","imports","_import","flatConfigs","recommended","rules","javascript","js","configs","eqeqeq","prettier","pretty","react","files","plugins","_react","parserOptions","ecmaFeatures","jsx","settings","version","typescript","ts","allow","allowShortCircuit"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,SAASA,YAAYA,WAAmB,EAAA;IACtC,OAAO;QACLC,eAAiB,EAAA;AACfC,YAAAA,OAAAA,EAAS,cACJF,CAAAA,EAAAA,EAAAA,WAAAA;AAEP;AACF,KAAA;AACF;MAEaG,YAAe,GAAA;IAC1BC,OAAS,EAAA;AAACJ,QAAAA,WAAAA,CAAYE,QAAQE,OAAO;AAAE,KAAA;IACvCC,IAAM,EAAA;AAACL,QAAAA,WAAAA,CAAYE,QAAQG,IAAI,CAAA;AAAGL,QAAAA,WAAAA,CAAYE,QAAQI,WAAW;AAAE;AACrE;;MCbaC,OAA2B,GAAA;IACtCC,OAAQC,CAAAA,WAAW,CAACC,WAAW;AAC/B,IAAA;QACEC,KAAO,EAAA;;;YAGL,mCAAqC,EAAA,OAAA;;;;;;YAOrC,cAAgB,EAAA,KAAA;YAChB,sBAAwB,EAAA;AAC1B;AACF;;;MChBWC,UAA8B,GAAA;IACzCC,EAAGC,CAAAA,OAAO,CAACJ,WAAW;AACtB,IAAA;QACEC,KAAO,EAAA;;;YAGLI,MAAQ,EAAA;AAAC,gBAAA,OAAA;AAAS,gBAAA;AAAQ,aAAA;;;;YAI1B,mBAAqB,EAAA;AACvB;AACF;;;MCbWC,QAAW,GAAA;AAACC,IAAAA;;;MCCZC,KAAyB,GAAA;AACpC,IAAA;QACEC,KAAO,EAAA;AAAC,YAAA;AAAmC,SAAA;QAC3CC,OAAS,EAAA;YACPF,KAAOG,EAAAA;AACT,SAAA;QACApB,eAAiB,EAAA;YACfqB,aAAe,EAAA;gBACbC,YAAc,EAAA;oBACZC,GAAK,EAAA;AACP;AACF;AACF,SAAA;QACAC,QAAU,EAAA;YACRP,KAAO,EAAA;gBACLQ,OAAS,EAAA;AACX;AACF,SAAA;QACAf,KAAO,EAAA;;;;;YAKL,0BAA4B,EAAA;AAC9B;AACF;;;MCzBWgB,UAAa,GAAA;OACrBC,EAAGd,CAAAA,OAAO,CAACJ,WAAW;AACzB,IAAA;QACEC,KAAO,EAAA;;;;;;YAML,oCAAsC,EAAA,KAAA;YACtC,iCAAmC,EAAA,KAAA;;;;YAKnC,mBAAqB,EAAA,KAAA;YACrB,sCAAwC,EAAA;AACtC,gBAAA,OAAA;AACA,gBAAA;oBAAEkB,KAAO,EAAA;AAAC,wBAAA;AAAe;AAAC;AAC3B,aAAA;;;YAID,oCAAsC,EAAA,KAAA;YACtC,uCAAyC,EAAA,KAAA;;YAGzC,yCAA2C,EAAA,KAAA;YAC3C,uCAAyC,EAAA,KAAA;;;;;;YAOzC,kDAAoD,EAAA,KAAA;;;;;YAMpD,0CAA4C,EAAA,KAAA;;;;YAK5C,uBAAyB,EAAA,KAAA;YACzB,0CAA4C,EAAA;AAC1C,gBAAA,OAAA;AACA,gBAAA;oBACEC,iBAAmB,EAAA;AACrB;AACD;AACH;AACF;;;MCpDWpB,WAAc,GAAA;AACtBE,IAAAA,GAAAA,UAAAA;AACAe,IAAAA,GAAAA,UAAAA;AACApB,IAAAA,GAAAA,OAAAA;AACAS,IAAAA,GAAAA;;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zthun/janitor-eslint-config",
|
|
3
|
+
"version": "19.0.0",
|
|
4
|
+
"description": "A shared configuration for eslint for @zthun scoped projects.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"eslint",
|
|
7
|
+
"eslint-config"
|
|
8
|
+
],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"main": "./dist/index.cjs",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"exports": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"require": "./dist/index.cjs",
|
|
16
|
+
"import": "./dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "vite build"
|
|
20
|
+
},
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/zthun/janitor",
|
|
25
|
+
"directory": "packages/janitor-eslint-config"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@eslint/js": "^9.28.0",
|
|
32
|
+
"eslint-config-prettier": "^10.1.5",
|
|
33
|
+
"eslint-plugin-import": "^2.31.0",
|
|
34
|
+
"eslint-plugin-prettier": "^5.4.1",
|
|
35
|
+
"eslint-plugin-react": "^7.37.5",
|
|
36
|
+
"globals": "^16.2.0",
|
|
37
|
+
"typescript-eslint": "^8.33.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@zthun/janitor-build-config": "^19.0.0",
|
|
41
|
+
"eslint": "^9.28.0",
|
|
42
|
+
"prettier": "^3.5.3",
|
|
43
|
+
"typescript": "~5.8.3",
|
|
44
|
+
"vite": "^6.3.5"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"eslint": "^9.0.0",
|
|
48
|
+
"prettier": "^3.0.0",
|
|
49
|
+
"react": ">=18.0.0 <=20.0.0",
|
|
50
|
+
"typescript": "^5.0.0"
|
|
51
|
+
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"react": {
|
|
54
|
+
"optional": true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"publishConfig": {
|
|
58
|
+
"access": "public"
|
|
59
|
+
},
|
|
60
|
+
"author": "Anthony Bonta",
|
|
61
|
+
"gitHead": "8277288093dff6023427448ccf903d83912865b5"
|
|
62
|
+
}
|