@andrewt03/eslint-typescript-rules 0.0.65 → 0.0.67
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 +35 -35
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,25 +51,29 @@ npm install eslint eslint-plugin-import eslint-plugin-simple-import-sort eslint-
|
|
|
51
51
|
- Type `npm run lint` in your terminal to log your linting warnings/errors.
|
|
52
52
|
- Type `npm run lint:fix` in your terminal to allow `ESLint` to try and resolve your linting warnings/errors within your project (wherever possible).
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
## `ESLint` File Configuration
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
### Recommended (Stable) - `ESLint` File Configuration
|
|
57
|
+
|
|
58
|
+
- **Note:** In `ESModules`, the `__dirname` variable is not available. As a fix, in most cases, we can leverage `import.meta.dirname` or `process.cwd()` in this case since the `ESLint` file configuration is typically written at the top-level of a project. However, if this does not work, some alternatives can be found in this [StackOverflow](https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-js-when-using-es6-modules) post.
|
|
57
59
|
|
|
58
60
|
---
|
|
59
61
|
|
|
60
62
|
```js
|
|
61
|
-
// eslint.config.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
// eslint.config.mjs
|
|
64
|
+
import ESLINT_RULES from "@andrewt03/eslint-typescript-rules";
|
|
65
|
+
import eslintPluginUnicorn from "eslint-plugin-unicorn";
|
|
66
|
+
import globals from "globals";
|
|
67
|
+
import tseslint from "typescript-eslint";
|
|
68
|
+
import eslintPluginSimpleImportSort from "eslint-plugin-simple-import-sort";
|
|
69
|
+
import eslintImportPlugin from "eslint-plugin-import";
|
|
70
|
+
import angularEslintPlugin from "@angular-eslint/eslint-plugin";
|
|
71
|
+
import eslintReactPlugin from "eslint-plugin-react";
|
|
72
|
+
import eslintReactHooksPlugin from "eslint-plugin-react-hooks";
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
const DIR_NAME = import.meta.dirname;
|
|
75
|
+
|
|
76
|
+
export default [
|
|
73
77
|
{
|
|
74
78
|
ignores: ["**/dist"]
|
|
75
79
|
},
|
|
@@ -88,7 +92,7 @@ module.exports = [
|
|
|
88
92
|
parser: tseslint.parser,
|
|
89
93
|
parserOptions: {
|
|
90
94
|
projectService: true,
|
|
91
|
-
tsconfigRootDir:
|
|
95
|
+
tsconfigRootDir: DIR_NAME,
|
|
92
96
|
|
|
93
97
|
// React-Specific (Omit if not necessary)
|
|
94
98
|
ecmaFeatures: {
|
|
@@ -116,8 +120,8 @@ module.exports = [
|
|
|
116
120
|
// TypeScript ESLint Rules
|
|
117
121
|
...ESLINT_RULES.TYPESCRIPT_ESLINT_CONFIG_RULES,
|
|
118
122
|
|
|
119
|
-
// Unicorn ESLint Rules
|
|
120
|
-
|
|
123
|
+
// Unicorn ESLint Rules
|
|
124
|
+
...ESLINT_RULES.UNICORN_ESLINT_CONFIG_RULES,
|
|
121
125
|
|
|
122
126
|
// ESLint Rules: Console/Debugger to "Warn"
|
|
123
127
|
...ESLINT_RULES.CONSOLE_DEBUGGER_WARN_ESLINT_CONFIG_RULES,
|
|
@@ -167,27 +171,23 @@ module.exports = [
|
|
|
167
171
|
];
|
|
168
172
|
```
|
|
169
173
|
|
|
170
|
-
#### Alternative - `
|
|
171
|
-
|
|
172
|
-
- **Note:** In `ESModules`, the `__dirname` variable is not available. As a fix, in most cases, we can leverage `import.meta.dirname` or `process.cwd()` in this case since the `ESLint` file configuration is typically written at the top-level of a project. However, if this does not work, some alternatives can be found in this [StackOverflow](https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-js-when-using-es6-modules) post.
|
|
174
|
+
#### Alternative - `CommonJS` (No Longer Recommended)
|
|
173
175
|
|
|
174
176
|
---
|
|
175
177
|
|
|
176
178
|
```js
|
|
177
|
-
// eslint.config.
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const DIR_NAME = import.meta.dirname;
|
|
179
|
+
// eslint.config.cjs
|
|
180
|
+
const ESLINT_RULES = require("@andrewt03/eslint-typescript-rules");
|
|
181
|
+
const eslintPluginUnicorn = require("eslint-plugin-unicorn");
|
|
182
|
+
const globals = require("globals");
|
|
183
|
+
const tseslint = require("typescript-eslint");
|
|
184
|
+
const eslintPluginSimpleImportSort = require("eslint-plugin-simple-import-sort");
|
|
185
|
+
const eslintImportPlugin = require("eslint-plugin-import");
|
|
186
|
+
const angularEslintPlugin = require("@angular-eslint/eslint-plugin");
|
|
187
|
+
const eslintReactPlugin = require("eslint-plugin-react");
|
|
188
|
+
const eslintReactHooksPlugin = require("eslint-plugin-react-hooks");
|
|
189
189
|
|
|
190
|
-
|
|
190
|
+
module.exports = [
|
|
191
191
|
{
|
|
192
192
|
ignores: ["**/dist"]
|
|
193
193
|
},
|
|
@@ -206,7 +206,7 @@ export default [
|
|
|
206
206
|
parser: tseslint.parser,
|
|
207
207
|
parserOptions: {
|
|
208
208
|
projectService: true,
|
|
209
|
-
tsconfigRootDir:
|
|
209
|
+
tsconfigRootDir: __dirname,
|
|
210
210
|
|
|
211
211
|
// React-Specific (Omit if not necessary)
|
|
212
212
|
ecmaFeatures: {
|
|
@@ -234,8 +234,8 @@ export default [
|
|
|
234
234
|
// TypeScript ESLint Rules
|
|
235
235
|
...ESLINT_RULES.TYPESCRIPT_ESLINT_CONFIG_RULES,
|
|
236
236
|
|
|
237
|
-
// Unicorn ESLint Rules
|
|
238
|
-
...ESLINT_RULES.UNICORN_ESLINT_CONFIG_RULES,
|
|
237
|
+
// Unicorn ESLint Rules (Note: Deprecated. Do NOT add these rules to CommonJS configurations after 'v0.0.62')
|
|
238
|
+
// ...ESLINT_RULES.UNICORN_ESLINT_CONFIG_RULES,
|
|
239
239
|
|
|
240
240
|
// ESLint Rules: Console/Debugger to "Warn"
|
|
241
241
|
...ESLINT_RULES.CONSOLE_DEBUGGER_WARN_ESLINT_CONFIG_RULES,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrewt03/eslint-typescript-rules",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.67",
|
|
4
4
|
"description": "Recommended ESLint Rules for general TypeScript, Node.js/Express.js, Angular, and React.js Projects",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|