@lusc/eslint-config 1.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +9 -0
  3. package/index.js +102 -0
  4. package/package.json +39 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Luca
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, 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,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # @lusc/eslint-config
2
+
3
+ This is a collection of useful eslint configs and plugins.
4
+ It is meant to be used mainly with TypeScript and ESM.
5
+ Inspired by [xo](https://github.com/xojs/xo).
6
+
7
+ Use at your own risk!
8
+ This config is primarily intended to be used by me and my projects.
9
+ Any changes are likely breaking changes so any version bump can be breaking for you.
package/index.js ADDED
@@ -0,0 +1,102 @@
1
+ import js from '@eslint/js';
2
+ import comments from '@eslint-community/eslint-plugin-eslint-comments/configs';
3
+ import nodePlugin from 'eslint-plugin-n';
4
+ import pluginPromise from 'eslint-plugin-promise';
5
+ import eslintPluginUnicorn from 'eslint-plugin-unicorn';
6
+ import tseslint from 'typescript-eslint';
7
+ import globals from 'globals';
8
+
9
+ const ignores = ['dist/**', '.svelte-kit/**', 'build/**'];
10
+
11
+ export default [
12
+ {
13
+ ignores,
14
+ },
15
+ {
16
+ languageOptions: {
17
+ globals: {
18
+ ...globals.browser,
19
+ ...globals.nodeBuiltin,
20
+ },
21
+ },
22
+ },
23
+ js.configs.recommended,
24
+ {
25
+ rules: {
26
+ 'no-unused-vars': [
27
+ 'error',
28
+ {
29
+ vars: 'all',
30
+ varsIgnorePattern: /^_/.source,
31
+ args: 'after-used',
32
+ ignoreRestSiblings: true,
33
+ argsIgnorePattern: /^_/.source,
34
+ caughtErrors: 'all',
35
+ caughtErrorsIgnorePattern: /^_$/.source,
36
+ },
37
+ ],
38
+ },
39
+ },
40
+ ...tseslint.configs.strictTypeChecked.map(config => ({
41
+ files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
42
+ ...config,
43
+ })),
44
+ {
45
+ files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts'],
46
+ languageOptions: {
47
+ parserOptions: {
48
+ projectService: true,
49
+ tsconfigRootDir: import.meta.dirname,
50
+ },
51
+ },
52
+ rules: {
53
+ '@typescript-eslint/restrict-template-expressions': [
54
+ 'error',
55
+ {
56
+ allowNumber: true,
57
+ },
58
+ ],
59
+ '@typescript-eslint/no-non-null-assertion': 'off',
60
+ '@typescript-eslint/no-unused-vars': [
61
+ 'error',
62
+ {
63
+ vars: 'all',
64
+ varsIgnorePattern: /^_/.source,
65
+ args: 'after-used',
66
+ ignoreRestSiblings: true,
67
+ argsIgnorePattern: /^_/.source,
68
+ caughtErrors: 'all',
69
+ caughtErrorsIgnorePattern: /^_$/.source,
70
+ },
71
+ ],
72
+ '@typescript-eslint/no-misused-promises': [
73
+ 'error',
74
+ {
75
+ checksConditionals: true,
76
+ // Useful for event handlers
77
+ checksVoidReturn: false,
78
+ },
79
+ ],
80
+ },
81
+ },
82
+ comments.recommended,
83
+ nodePlugin.configs['flat/recommended'],
84
+ pluginPromise.configs['flat/recommended'],
85
+ eslintPluginUnicorn.configs['flat/recommended'],
86
+ {
87
+ rules: {
88
+ 'promise/prefer-await-to-then': 'error',
89
+ 'promise/always-return': 'off',
90
+ 'unicorn/no-null': 'off',
91
+ 'n/no-missing-import': 'off',
92
+ // Too many false positives
93
+ '@typescript-eslint/unbound-method': 'off',
94
+ 'no-empty': [
95
+ 'error',
96
+ {
97
+ allowEmptyCatch: true,
98
+ },
99
+ ],
100
+ },
101
+ },
102
+ ];
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "author": {
3
+ "name": "lusc",
4
+ "url": "https://github.com/melusc"
5
+ },
6
+ "dependencies": {
7
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
8
+ "@eslint/js": "^9.14.0",
9
+ "eslint-plugin-n": "^17.12.0",
10
+ "eslint-plugin-promise": "^7.1.0",
11
+ "eslint-plugin-unicorn": "^56.0.0",
12
+ "globals": "^15.12.0",
13
+ "typescript": "^5.6.3",
14
+ "typescript-eslint": "^8.13.0"
15
+ },
16
+ "devDependencies": {
17
+ "@types/eslint": "^9.6.1",
18
+ "eslint": "^9.14.0",
19
+ "prettier": "^3.3.3"
20
+ },
21
+ "exports": {
22
+ ".": "./index.js"
23
+ },
24
+ "files": [
25
+ "*.js"
26
+ ],
27
+ "license": "MIT",
28
+ "name": "@lusc/eslint-config",
29
+ "packageManager": "yarn@4.5.1",
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "fmt": "prettier -w .",
35
+ "lint": "eslint --fix"
36
+ },
37
+ "version": "1.0.0",
38
+ "type": "module"
39
+ }