eslint-config-sandi-ts-flat 0.1.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/.eslintrc.json ADDED
File without changes
package/index.js ADDED
@@ -0,0 +1,143 @@
1
+
2
+ import js from "@eslint/js";
3
+ import noTypeAssertion from "eslint-plugin-no-type-assertion";
4
+ import globals from "globals";
5
+ //import tsParser from "@typescript-eslint/parser";
6
+ import tseslint from 'typescript-eslint';
7
+ import path from "node:path";
8
+ import { fileURLToPath } from "node:url";
9
+ import { FlatCompat } from "@eslint/eslintrc";
10
+
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+ const compat = new FlatCompat({
14
+ baseDirectory: __dirname,
15
+ recommendedConfig: js.configs.recommended,
16
+ allConfig: js.configs.all
17
+ });
18
+
19
+ const ts = tseslint.configs.recommended
20
+
21
+ export default [
22
+ js.configs.recommended,
23
+ ...tseslint.configs.recommended,
24
+ {
25
+ ignores: ["**/dist", "**/*.cjs", "**/*.js"],
26
+
27
+ // },
28
+ // ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"),
29
+ // {
30
+ plugins: {
31
+ "no-type-assertion": noTypeAssertion,
32
+ },
33
+
34
+ languageOptions: {
35
+ globals: {
36
+ ...globals.node,
37
+ },
38
+
39
+ //parser: tsParser,
40
+ //ecmaVersion: 12,
41
+ //sourceType: "module",
42
+
43
+ parserOptions: {
44
+ project: true,
45
+ },
46
+ },
47
+
48
+ rules: {
49
+ "no-undef": "off",
50
+ "no-import-assign": "error",
51
+ "no-unexpected-multiline": "error",
52
+ "consistent-return": "error",
53
+ "no-fallthrough": "error",
54
+ "no-unsafe-negation": "error",
55
+
56
+ "no-restricted-globals": ["error", {
57
+ name: "__dirname",
58
+ message: "__dirname does not exist in ES6 modules. Extract dirname from import.meta.url.",
59
+ }, {
60
+ name: "require",
61
+ message: "require does not exist in ES6 modules. Use import { createRequire } from 'module'; const require = createRequire(import.meta.url) if you need require.",
62
+ }, {
63
+ name: "module",
64
+ message: "module does not exist in ES6 modules. Use export if trying to export from ES6 modules.",
65
+ }, {
66
+ name: "exports",
67
+ message: "exports does not exist in ES6 modules. Use export to export from ES6 modules.",
68
+ }],
69
+
70
+ "no-case-declarations": "warn",
71
+ "no-cond-assign": "warn",
72
+ "no-unreachable": "warn",
73
+ "require-await": "warn",
74
+ "no-return-await": "warn",
75
+ "no-unused-vars": "off",
76
+ "prefer-const": "warn",
77
+ "no-useless-escape": "warn",
78
+ "no-empty": "warn",
79
+ semi: ["warn", "never"],
80
+
81
+ indent: ["warn", 4, {
82
+ SwitchCase: 1,
83
+ MemberExpression: "off",
84
+ ignoreComments: true,
85
+ }],
86
+
87
+ "no-mixed-spaces-and-tabs": "warn",
88
+
89
+ "no-trailing-spaces": ["warn", {
90
+ skipBlankLines: true,
91
+ ignoreComments: true,
92
+ }],
93
+
94
+ "keyword-spacing": ["warn", {
95
+ overrides: {
96
+ catch: {
97
+ after: true,
98
+ },
99
+ },
100
+ }],
101
+
102
+ "object-shorthand": ["warn", "properties"],
103
+
104
+ "max-len": ["warn", 120, {
105
+ ignoreComments: true,
106
+ }],
107
+
108
+ "brace-style": ["warn", "1tbs", {
109
+ allowSingleLine: true,
110
+ }],
111
+
112
+ camelcase: ["warn", {
113
+ allow: ["^(db|DB|mongo|MONGO|mysql|MYSQL|postgres?|POSTGRES?)_"],
114
+ ignoreGlobals: true,
115
+ }],
116
+
117
+ "@typescript-eslint/ban-types": "warn",
118
+ "@typescript-eslint/no-empty-interface": "warn",
119
+ "@typescript-eslint/no-empty-function": "warn",
120
+ "@typescript-eslint/no-namespace": "warn",
121
+ "@typescript-eslint/no-unnecessary-type-assertion": "warn",
122
+ "@typescript-eslint/strict-boolean-expressions": "warn",
123
+ "@typescript-eslint/no-this-alias": "warn",
124
+ "@typescript-eslint/ban-ts-comment": "warn",
125
+ "@typescript-eslint/no-inferrable-types": "warn",
126
+ "@typescript-eslint/no-explicit-any": "warn",
127
+
128
+ "@typescript-eslint/no-unused-vars": ["warn", {
129
+ varsIgnorePattern: "^_$|^unused$",
130
+ argsIgnorePattern: "^reject$|^_$|^unused$",
131
+ }],
132
+
133
+ "no-type-assertion/no-type-assertion": "warn",
134
+ },
135
+ },
136
+ // {
137
+ // files: ["**/*.cjs"],
138
+
139
+ // rules: {
140
+ // "no-restricted-globals": ["error", ""],
141
+ // },
142
+ // }
143
+ ];
package/index.js.old ADDED
@@ -0,0 +1,146 @@
1
+ module.exports = {
2
+
3
+ "ignorePatterns": ["dist", "*.cjs", "*.js"],
4
+
5
+ "extends": [
6
+ "eslint:recommended",
7
+ "plugin:@typescript-eslint/recommended"
8
+ ],
9
+
10
+ "plugins": [
11
+ "eslint-plugin-no-type-assertion"
12
+ ],
13
+
14
+ "env": {
15
+ "es2021" : true,
16
+ "node": true
17
+ },
18
+
19
+ "parser": "@typescript-eslint/parser",
20
+
21
+ "parserOptions": {
22
+ "ecmaVersion": 12,
23
+ "sourceType": "module",
24
+ "project": true
25
+ },
26
+
27
+ /*"settings": {
28
+ 'import/resolver': {
29
+ "babel-module": {
30
+ "extensions": ['.js', '.jsx', '.cjs', '.ts', '.tsx', '.css', '.scss', '.sass', '.less']
31
+ }
32
+ },
33
+ },*/
34
+
35
+ "rules": {
36
+
37
+ // new tweaks - organise later
38
+
39
+ //// errors or likely errors
40
+ "no-undef": "off", // doesn't work with TS
41
+ "no-import-assign": "error",
42
+ "no-unexpected-multiline": "error",
43
+ "consistent-return": "error",
44
+ "no-fallthrough": "error",
45
+ "no-unsafe-negation": "error",
46
+ "no-restricted-globals": ["error",
47
+ {
48
+ "name": "__dirname",
49
+ "message": "__dirname does not exist in ES6 modules. Extract dirname from import.meta.url."
50
+ },
51
+ {
52
+ "name": "require",
53
+ "message": "require does not exist in ES6 modules. Use import { createRequire } from 'module'; const require = createRequire(import.meta.url) if you need require."
54
+ },
55
+ {
56
+ "name": "module",
57
+ "message": "module does not exist in ES6 modules. Use export if trying to export from ES6 modules."
58
+ },
59
+ {
60
+ "name": "exports",
61
+ "message": "exports does not exist in ES6 modules. Use export to export from ES6 modules."
62
+ },
63
+
64
+ // add extra objects here, they are not stored within an array. weird.
65
+ ],
66
+
67
+ //// code regulation
68
+ "consistent-return": "error",
69
+
70
+ //// safety
71
+ //"import/no-default-export": "warn", // too restrictive, disabled
72
+ "no-case-declarations" : "warn", // warn about declaring variables in switch blocks due to scoping issues
73
+ "no-cond-assign": "warn", // assigning to a variable with = instead an if or other check. Allowed but warned
74
+
75
+ //// inefficiencies
76
+ "no-unreachable": "warn",
77
+ "require-await": "warn", // warn if async funcs don't have an await
78
+ "no-return-await": "warn",
79
+ // "no-unused-vars": ["warn", {
80
+ // "argsIgnorePattern": "^(?:_|req|request|res|response|next|resolve|reject|resolve|reject)$"
81
+ // } ],
82
+ "no-unused-vars": "off", // changed from warn, messes with typings
83
+
84
+ //// information
85
+ "prefer-const": "warn",
86
+ "no-useless-escape": "warn", // will turn to off eventually // came from eslint:recommended
87
+ "no-empty": "warn", // came from eslint:recommended
88
+
89
+ //// style
90
+ "semi": ["warn", "never"], // semi-colons
91
+ "indent": ["warn", 4, {
92
+ "SwitchCase": 1, // indent switch contents by 1 indent
93
+ "MemberExpression" : "off", // .then .catch etc chained methods - off to allow dev style?
94
+ "ignoreComments" : true
95
+ }],
96
+ "no-mixed-spaces-and-tabs": "warn",
97
+ "no-trailing-spaces" : ["warn", {
98
+ "skipBlankLines": true,
99
+ "ignoreComments": true
100
+ }],
101
+
102
+ //// minor style
103
+ "keyword-spacing": ["warn", {
104
+ "overrides": { // space after keywords like if
105
+ "catch": { "after": true } // after catch
106
+ }
107
+ }],
108
+ "object-shorthand": ["warn", "properties"], // use { prop } instead of { prop : prop }. But don't require { a() } instead of { a: function() }
109
+ "max-len" : ["warn", 120, {
110
+ "ignoreComments": true,
111
+ //"ignoreStrings": true, // too eager
112
+ } ], // maximum 120 chars per line
113
+ "brace-style": ["warn", "1tbs", { "allowSingleLine": true }], // { } rules
114
+ "camelcase": ["warn", {
115
+ "allow": ["^(db|DB|mongo|MONGO|mysql|MYSQL|postgres?|POSTGRES?)_"],
116
+ "ignoreGlobals": true
117
+ }], // camelCase variables
118
+
119
+ //// ts
120
+ "@typescript-eslint/ban-types": "warn", // copied from framework
121
+ "@typescript-eslint/no-empty-interface": "warn", // copied from framework
122
+ "@typescript-eslint/no-empty-function": "warn",
123
+ "@typescript-eslint/no-namespace": "warn",
124
+ "@typescript-eslint/no-unnecessary-type-assertion": "warn",
125
+ "@typescript-eslint/strict-boolean-expressions": "warn",
126
+ "@typescript-eslint/no-this-alias": "warn",
127
+ "@typescript-eslint/ban-ts-comment": "warn",
128
+ "@typescript-eslint/no-inferrable-types": "warn",
129
+ "@typescript-eslint/no-explicit-any": "warn",
130
+ "@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "^_$|^unused$", "argsIgnorePattern": "^reject$|^_$|^unused$" }],
131
+
132
+ // plugin-no-type-assertion
133
+ "no-type-assertion/no-type-assertion": "warn"
134
+ },
135
+
136
+ "overrides": [
137
+ {
138
+ "files": ["**/*.cjs"],
139
+ "rules": {
140
+ "no-restricted-globals": ["error", ""]
141
+ }
142
+ }
143
+ ]
144
+ };
145
+
146
+
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "eslint-config-sandi-ts-flat",
3
+ "version": "0.1.0",
4
+ "description": "",
5
+ "license": "ISC",
6
+ "main": "index.js",
7
+ "keywords": [],
8
+ "author": "Robert Sandiford <> (robertsandiford.co.uk)",
9
+ "dependencies": {
10
+ "@babel/core": "^7.23.7",
11
+ "@babel/eslint-parser": "^7.25.1",
12
+ "@babel/plugin-syntax-decorators": "^7.23.3",
13
+ "@eslint/eslintrc": "^3.1.0",
14
+ "@eslint/js": "^9.9.1",
15
+ "babel-plugin-module-resolver": "^5.0.0",
16
+ "eslint": "^9.9.1",
17
+ "eslint-import-resolver-babel-module": "^5.3.2",
18
+ "eslint-plugin-no-type-assertion": "^1.3.0",
19
+ "globals": "^15.9.0",
20
+ "typescript-eslint": "^8.3.0"
21
+ },
22
+ "scripts": {
23
+ "test": "echo \"Error: no test specified\" && exit 1"
24
+ }
25
+ }