@szum-tech/eslint-config 2.1.3 → 2.1.5

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 CHANGED
@@ -46,20 +46,19 @@ use, because the configuration dynamically adapts to the needs of the project.
46
46
  ## 📖 Table of Contents
47
47
 
48
48
  <!-- TOC -->
49
-
50
- - [@szum-tech/eslint-config](#szum-techeslint-config)
51
- - [📚 Features](#-features)
52
- - [📖 Table of Contents](#-table-of-contents)
53
- - [🎯 Getting Started](#-getting-started)
54
- - [⚙️ Installation](#-installation)
55
- - [Configuration](#configuration)
56
- - [💻 Scripts](#-scripts)
57
- - [🚀 Minimal GitHub ESlint check workflow](#-minimal-github-eslint-check-workflow)
58
- - [🛠️ Developer Info](#-developer-info)
59
- - [Dependencies](#dependencies)
60
- - [Changelog](#changelog)
61
- - [📜 License](#-license)
62
- <!-- TOC -->
49
+ * [@szum-tech/eslint-config](#szum-techeslint-config)
50
+ * [📚 Features](#-features)
51
+ * [📖 Table of Contents](#-table-of-contents)
52
+ * [🎯 Getting Started](#-getting-started)
53
+ * [⚙️ Installation](#-installation)
54
+ * [Configuration](#configuration)
55
+ * [💻 Scripts](#-scripts)
56
+ * [🚀 Minimal GitHub ESlint check workflow](#-minimal-github-eslint-check-workflow)
57
+ * [🛠️ Developer Info](#-developer-info)
58
+ * [Dependencies](#dependencies)
59
+ * [📒 Changelog](#-changelog)
60
+ * [📜 License](#-license)
61
+ <!-- TOC -->
63
62
 
64
63
  ## 🎯 Getting Started
65
64
 
@@ -228,7 +227,7 @@ jobs:
228
227
  ![NPM (prod) Dependency Version](https://img.shields.io/npm/dependency-version/%40szum-tech%2Feslint-config/typescript-eslint)
229
228
  ![NPM (prod) Dependency Version](https://img.shields.io/npm/dependency-version/%40szum-tech%2Feslint-config/eslint-import-resolver-typescript)
230
229
 
231
- ## Changelog
230
+ ## 📒 Changelog
232
231
 
233
232
  The [changelog](https://github.com/JanSzewczyk/eslint-config/blob/main/CHANGELOG.md) is regularly updated to reflect
234
233
  what's changed in each new release.
package/dist/index.cjs CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var fs = require('fs');
4
+ var path = require('path');
3
5
  var importPlugin = require('eslint-plugin-import');
4
6
  var jestDomPlugin = require('eslint-plugin-jest-dom');
5
7
  var playwrightPlugin = require('eslint-plugin-playwright');
@@ -13,7 +15,6 @@ var tsEslint = require('typescript-eslint');
13
15
  var nextPlugin = require('@next/eslint-plugin-next');
14
16
  var vitestPlugin = require('@vitest/eslint-plugin');
15
17
 
16
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
17
18
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
18
19
 
19
20
  function _interopNamespace(e) {
@@ -38,7 +39,7 @@ var importPlugin__namespace = /*#__PURE__*/_interopNamespace(importPlugin);
38
39
  var jestDomPlugin__default = /*#__PURE__*/_interopDefault(jestDomPlugin);
39
40
  var playwrightPlugin__default = /*#__PURE__*/_interopDefault(playwrightPlugin);
40
41
  var reactPlugin__default = /*#__PURE__*/_interopDefault(reactPlugin);
41
- var reactHooksPlugin__default = /*#__PURE__*/_interopDefault(reactHooksPlugin);
42
+ var reactHooksPlugin__namespace = /*#__PURE__*/_interopNamespace(reactHooksPlugin);
42
43
  var storybookPlugin__default = /*#__PURE__*/_interopDefault(storybookPlugin);
43
44
  var tailwindcssPlugin__default = /*#__PURE__*/_interopDefault(tailwindcssPlugin);
44
45
  var testingLibraryPlugin__default = /*#__PURE__*/_interopDefault(testingLibraryPlugin);
@@ -48,31 +49,85 @@ var nextPlugin__default = /*#__PURE__*/_interopDefault(nextPlugin);
48
49
  var vitestPlugin__default = /*#__PURE__*/_interopDefault(vitestPlugin);
49
50
 
50
51
  // src/index.js
51
- var ERROR = "error";
52
- var WARN = "warn";
53
- var OFF = "off";
54
- var has = (pkg) => {
52
+ var logger = console;
53
+ function isPackageInstalled(packageName) {
54
+ const currentDir = process.cwd();
55
+ const packageJsonPath = findPackageJson(currentDir);
55
56
  try {
56
- undefined(pkg, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
57
- return true;
58
- } catch {
59
- return false;
57
+ const packageJson = fs.readFileSync(packageJsonPath, "utf-8");
58
+ const parsedPackageJson = JSON.parse(packageJson);
59
+ const dependencies = parsedPackageJson.dependencies || {};
60
+ const devDependencies = parsedPackageJson.devDependencies || {};
61
+ return dependencies.hasOwnProperty(packageName) || devDependencies.hasOwnProperty(packageName);
62
+ } catch (error) {
63
+ logger.error("Error reading package.json file:", error);
64
+ process.exit(1);
60
65
  }
61
- };
62
- var hasTypeScript = has("typescript");
63
- var hasTailwindcss = has("tailwindcss");
64
- var hasReact = has("react");
65
- var hasNext = has("next");
66
- var hasTestingLibrary = has("@testing-library/dom");
67
- var hasJestDom = has("@testing-library/jest-dom");
68
- var hasVitest = has("vitest");
69
- var hasPlaywright = has("@playwright/test");
70
- var hasStorybook = has("storybook");
66
+ }
67
+ var PACKAGE_JSON = "package.json";
68
+ function findPackageJson(startDir) {
69
+ let currentDir = startDir;
70
+ while (true) {
71
+ const packageJsonPath = path.join(currentDir, PACKAGE_JSON);
72
+ if (fs.existsSync(packageJsonPath)) {
73
+ return packageJsonPath;
74
+ }
75
+ const parentDir = path.resolve(currentDir, "..");
76
+ if (parentDir === currentDir) {
77
+ break;
78
+ }
79
+ currentDir = parentDir;
80
+ }
81
+ return null;
82
+ }
83
+ var hasTypeScript = isPackageInstalled("typescript");
84
+ var hasTailwindcss = isPackageInstalled("tailwindcss");
85
+ var hasReact = isPackageInstalled("react");
86
+ var hasNext = isPackageInstalled("next");
87
+ var hasTestingLibrary = isPackageInstalled("@testing-library/dom");
88
+ var hasJestDom = isPackageInstalled("@testing-library/jest-dom");
89
+ var hasVitest = isPackageInstalled("vitest");
90
+ var hasPlaywright = isPackageInstalled("@playwright/test");
91
+ var hasStorybook = isPackageInstalled("storybook");
71
92
  var typeScriptExtensions = [".ts", ".cts", ".mts", ".tsx"];
72
93
  var allExtensions = [...typeScriptExtensions, ".js", ".jsx", ".mjs", ".cjs"];
73
94
  var vitestFiles = ["**/__tests__/**/*", "**/*.test.*"];
74
95
  var testFiles = ["**/tests/**", ...vitestFiles];
75
96
  var playwrightFiles = ["**/e2e/**", "**/*.e2e.*"];
97
+ function showFeaturesTable() {
98
+ const tableData = [
99
+ { Name: "TypeScript", Status: hasTypeScript ? "\u2714\uFE0F" : "\u274C" },
100
+ { Name: "React", Status: hasReact ? "\u2714\uFE0F" : "\u274C" },
101
+ { Name: "Next", Status: hasNext ? "\u2714\uFE0F" : "\u274C" },
102
+ { Name: "Testing Library", Status: hasTestingLibrary ? "\u2714\uFE0F" : "\u274C" },
103
+ { Name: "Jest Dom", Status: hasJestDom ? "\u2714\uFE0F" : "\u274C" },
104
+ { Name: "Vitest", Status: hasVitest ? "\u2714\uFE0F" : "\u274C" },
105
+ { Name: "Playwright", Status: hasPlaywright ? "\u2714\uFE0F" : "\u274C" },
106
+ { Name: "Storybook", Status: hasStorybook ? "\u2714\uFE0F" : "\u274C" }
107
+ ].sort((a, b) => {
108
+ const aHasCheck = a.Status.includes("\u2714\uFE0F");
109
+ const bHasCheck = b.Status.includes("\u2714\uFE0F");
110
+ if (aHasCheck && !bHasCheck) {
111
+ return -1;
112
+ } else if (!aHasCheck && bHasCheck) {
113
+ return 1;
114
+ } else {
115
+ return 0;
116
+ }
117
+ });
118
+ logger.log("Hello There!\nHere are the features detected in your project:");
119
+ logger.table(tableData);
120
+ logger.log(`Dear Developer
121
+ `);
122
+ logger.log("Thanks a lot for using '@szum-tech/eslint-config'");
123
+ logger.log("If you like it, leave a star \u2B50 \u{1F449} https://github.com/JanSzewczyk/handy-szumrak");
124
+ logger.log("And recommend to others\n");
125
+ logger.log(`May the SZUMRAK be with You \u{1F680}\u{1F680}\u{1F680}`);
126
+ }
127
+ showFeaturesTable();
128
+ var ERROR = "error";
129
+ var WARN = "warn";
130
+ var OFF = "off";
76
131
  var config = [
77
132
  {
78
133
  name: "eslint/ignores",
@@ -103,6 +158,18 @@ var config = [
103
158
  warnOnUnsupportedTypeScriptVersion: false
104
159
  }
105
160
  },
161
+ settings: hasTypeScript ? {
162
+ "import/extensions": allExtensions,
163
+ "import/external-module-folders": ["node_modules", "node_modules/@types"],
164
+ "import/parsers": {
165
+ "@typescript-eslint/parser": typeScriptExtensions
166
+ },
167
+ "import/resolver": {
168
+ node: {
169
+ extensions: allExtensions
170
+ }
171
+ }
172
+ } : {},
106
173
  rules: {
107
174
  "no-unexpected-multiline": ERROR,
108
175
  "no-warning-comments": [ERROR, { terms: ["FIXME"], location: "anywhere" }],
@@ -154,7 +221,7 @@ var config = [
154
221
  files: ["**/*.tsx", "**/*.jsx"],
155
222
  plugins: {
156
223
  react: reactPlugin__default.default,
157
- "react-hooks": reactHooksPlugin__default.default
224
+ "react-hooks": reactHooksPlugin__namespace
158
225
  },
159
226
  languageOptions: {
160
227
  parser: tsEslint__default.default.parser,
@@ -258,18 +325,6 @@ var config = [
258
325
  plugins: {
259
326
  "@typescript-eslint": tsEslint__default.default.plugin
260
327
  },
261
- settings: {
262
- "import/extensions": allExtensions,
263
- "import/external-module-folders": ["node_modules", "node_modules/@types"],
264
- "import/parsers": {
265
- "@typescript-eslint/parser": typeScriptExtensions
266
- },
267
- "import/resolver": {
268
- node: {
269
- extensions: allExtensions
270
- }
271
- }
272
- },
273
328
  rules: {
274
329
  "no-unused-expressions": OFF,
275
330
  "no-array-constructor": OFF,
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
+ import { readFileSync, existsSync } from 'node:fs';
2
+ import { join, resolve } from 'node:path';
1
3
  import * as importPlugin from 'eslint-plugin-import';
2
4
  import jestDomPlugin from 'eslint-plugin-jest-dom';
3
5
  import playwrightPlugin from 'eslint-plugin-playwright';
4
6
  import reactPlugin from 'eslint-plugin-react';
5
- import reactHooksPlugin from 'eslint-plugin-react-hooks';
7
+ import * as reactHooksPlugin from 'eslint-plugin-react-hooks';
6
8
  import storybookPlugin from 'eslint-plugin-storybook';
7
9
  import tailwindcssPlugin from 'eslint-plugin-tailwindcss';
8
10
  import testingLibraryPlugin from 'eslint-plugin-testing-library';
@@ -12,31 +14,85 @@ import nextPlugin from '@next/eslint-plugin-next';
12
14
  import vitestPlugin from '@vitest/eslint-plugin';
13
15
 
14
16
  // src/index.js
15
- var ERROR = "error";
16
- var WARN = "warn";
17
- var OFF = "off";
18
- var has = (pkg) => {
17
+ var logger = console;
18
+ function isPackageInstalled(packageName) {
19
+ const currentDir = process.cwd();
20
+ const packageJsonPath = findPackageJson(currentDir);
19
21
  try {
20
- import.meta.resolve(pkg, import.meta.url);
21
- return true;
22
- } catch {
23
- return false;
22
+ const packageJson = readFileSync(packageJsonPath, "utf-8");
23
+ const parsedPackageJson = JSON.parse(packageJson);
24
+ const dependencies = parsedPackageJson.dependencies || {};
25
+ const devDependencies = parsedPackageJson.devDependencies || {};
26
+ return dependencies.hasOwnProperty(packageName) || devDependencies.hasOwnProperty(packageName);
27
+ } catch (error) {
28
+ logger.error("Error reading package.json file:", error);
29
+ process.exit(1);
30
+ }
31
+ }
32
+ var PACKAGE_JSON = "package.json";
33
+ function findPackageJson(startDir) {
34
+ let currentDir = startDir;
35
+ while (true) {
36
+ const packageJsonPath = join(currentDir, PACKAGE_JSON);
37
+ if (existsSync(packageJsonPath)) {
38
+ return packageJsonPath;
39
+ }
40
+ const parentDir = resolve(currentDir, "..");
41
+ if (parentDir === currentDir) {
42
+ break;
43
+ }
44
+ currentDir = parentDir;
24
45
  }
25
- };
26
- var hasTypeScript = has("typescript");
27
- var hasTailwindcss = has("tailwindcss");
28
- var hasReact = has("react");
29
- var hasNext = has("next");
30
- var hasTestingLibrary = has("@testing-library/dom");
31
- var hasJestDom = has("@testing-library/jest-dom");
32
- var hasVitest = has("vitest");
33
- var hasPlaywright = has("@playwright/test");
34
- var hasStorybook = has("storybook");
46
+ return null;
47
+ }
48
+ var hasTypeScript = isPackageInstalled("typescript");
49
+ var hasTailwindcss = isPackageInstalled("tailwindcss");
50
+ var hasReact = isPackageInstalled("react");
51
+ var hasNext = isPackageInstalled("next");
52
+ var hasTestingLibrary = isPackageInstalled("@testing-library/dom");
53
+ var hasJestDom = isPackageInstalled("@testing-library/jest-dom");
54
+ var hasVitest = isPackageInstalled("vitest");
55
+ var hasPlaywright = isPackageInstalled("@playwright/test");
56
+ var hasStorybook = isPackageInstalled("storybook");
35
57
  var typeScriptExtensions = [".ts", ".cts", ".mts", ".tsx"];
36
58
  var allExtensions = [...typeScriptExtensions, ".js", ".jsx", ".mjs", ".cjs"];
37
59
  var vitestFiles = ["**/__tests__/**/*", "**/*.test.*"];
38
60
  var testFiles = ["**/tests/**", ...vitestFiles];
39
61
  var playwrightFiles = ["**/e2e/**", "**/*.e2e.*"];
62
+ function showFeaturesTable() {
63
+ const tableData = [
64
+ { Name: "TypeScript", Status: hasTypeScript ? "\u2714\uFE0F" : "\u274C" },
65
+ { Name: "React", Status: hasReact ? "\u2714\uFE0F" : "\u274C" },
66
+ { Name: "Next", Status: hasNext ? "\u2714\uFE0F" : "\u274C" },
67
+ { Name: "Testing Library", Status: hasTestingLibrary ? "\u2714\uFE0F" : "\u274C" },
68
+ { Name: "Jest Dom", Status: hasJestDom ? "\u2714\uFE0F" : "\u274C" },
69
+ { Name: "Vitest", Status: hasVitest ? "\u2714\uFE0F" : "\u274C" },
70
+ { Name: "Playwright", Status: hasPlaywright ? "\u2714\uFE0F" : "\u274C" },
71
+ { Name: "Storybook", Status: hasStorybook ? "\u2714\uFE0F" : "\u274C" }
72
+ ].sort((a, b) => {
73
+ const aHasCheck = a.Status.includes("\u2714\uFE0F");
74
+ const bHasCheck = b.Status.includes("\u2714\uFE0F");
75
+ if (aHasCheck && !bHasCheck) {
76
+ return -1;
77
+ } else if (!aHasCheck && bHasCheck) {
78
+ return 1;
79
+ } else {
80
+ return 0;
81
+ }
82
+ });
83
+ logger.log("Hello There!\nHere are the features detected in your project:");
84
+ logger.table(tableData);
85
+ logger.log(`Dear Developer
86
+ `);
87
+ logger.log("Thanks a lot for using '@szum-tech/eslint-config'");
88
+ logger.log("If you like it, leave a star \u2B50 \u{1F449} https://github.com/JanSzewczyk/handy-szumrak");
89
+ logger.log("And recommend to others\n");
90
+ logger.log(`May the SZUMRAK be with You \u{1F680}\u{1F680}\u{1F680}`);
91
+ }
92
+ showFeaturesTable();
93
+ var ERROR = "error";
94
+ var WARN = "warn";
95
+ var OFF = "off";
40
96
  var config = [
41
97
  {
42
98
  name: "eslint/ignores",
@@ -67,6 +123,18 @@ var config = [
67
123
  warnOnUnsupportedTypeScriptVersion: false
68
124
  }
69
125
  },
126
+ settings: hasTypeScript ? {
127
+ "import/extensions": allExtensions,
128
+ "import/external-module-folders": ["node_modules", "node_modules/@types"],
129
+ "import/parsers": {
130
+ "@typescript-eslint/parser": typeScriptExtensions
131
+ },
132
+ "import/resolver": {
133
+ node: {
134
+ extensions: allExtensions
135
+ }
136
+ }
137
+ } : {},
70
138
  rules: {
71
139
  "no-unexpected-multiline": ERROR,
72
140
  "no-warning-comments": [ERROR, { terms: ["FIXME"], location: "anywhere" }],
@@ -222,18 +290,6 @@ var config = [
222
290
  plugins: {
223
291
  "@typescript-eslint": tsEslint.plugin
224
292
  },
225
- settings: {
226
- "import/extensions": allExtensions,
227
- "import/external-module-folders": ["node_modules", "node_modules/@types"],
228
- "import/parsers": {
229
- "@typescript-eslint/parser": typeScriptExtensions
230
- },
231
- "import/resolver": {
232
- node: {
233
- extensions: allExtensions
234
- }
235
- }
236
- },
237
293
  rules: {
238
294
  "no-unused-expressions": OFF,
239
295
  "no-array-constructor": OFF,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@szum-tech/eslint-config",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
4
4
  "description": "ESLint configuration for TypeScript projects",
5
5
  "keywords": [
6
6
  "eslint",
@@ -21,7 +21,7 @@
21
21
  "author": "Jan Szewczyk (Szum-Tech)",
22
22
  "type": "module",
23
23
  "main": "./dist/index.cjs",
24
- "module": ".dist/index.js",
24
+ "module": "./dist/index.js",
25
25
  "files": [
26
26
  "dist/**"
27
27
  ],
@@ -35,43 +35,42 @@
35
35
  "prettier:write": "prettier --write ."
36
36
  },
37
37
  "dependencies": {
38
- "@next/eslint-plugin-next": "^15.1.3",
39
- "@vitest/eslint-plugin": "^1.1.22",
38
+ "@next/eslint-plugin-next": "^15.1.6",
39
+ "@vitest/eslint-plugin": "^1.1.25",
40
40
  "eslint-import-resolver-typescript": "^3.7.0",
41
41
  "eslint-plugin-import": "^2.31.0",
42
42
  "eslint-plugin-jest-dom": "^5.4.0",
43
- "eslint-plugin-playwright": "^2.0.1",
44
- "eslint-plugin-react": "^7.37.3",
43
+ "eslint-plugin-playwright": "^2.2.0",
44
+ "eslint-plugin-react": "^7.37.4",
45
45
  "eslint-plugin-react-hooks": "^5.1.0",
46
- "eslint-plugin-storybook": "^0.11.0",
47
- "eslint-plugin-tailwindcss": "^3.17.5",
46
+ "eslint-plugin-storybook": "^0.11.2",
47
+ "eslint-plugin-tailwindcss": "^3.18.0",
48
48
  "eslint-plugin-testing-library": "^7.1.1",
49
49
  "globals": "^15.14.0",
50
- "typescript-eslint": "^8.19.0"
50
+ "typescript-eslint": "^8.21.0"
51
51
  },
52
52
  "devDependencies": {
53
- "@microsoft/eslint-formatter-sarif": "^3.1.0",
54
53
  "@szum-tech/prettier-config": "^1.4.5",
55
54
  "@szum-tech/semantic-release-config": "^2.2.1",
56
- "eslint": "^9.17.0",
55
+ "eslint": "^9.18.0",
57
56
  "prettier": "^3.4.2",
58
- "semantic-release": "^24.2.0",
57
+ "semantic-release": "^24.2.1",
59
58
  "tsup": "^8.3.5",
60
- "typescript": "^5.7.2"
59
+ "typescript": "^5.7.3"
61
60
  },
62
61
  "peerDependencies": {
63
- "eslint": "^9.17.0",
62
+ "eslint": "^9.18.0",
64
63
  "eslint-import-resolver-typescript": "^3.7.0",
65
64
  "eslint-plugin-import": "^2.31.0",
66
65
  "eslint-plugin-jest-dom": "^5.4.0",
67
- "eslint-plugin-playwright": "^2.0.1",
68
- "eslint-plugin-react": "^7.37.3",
66
+ "eslint-plugin-playwright": "^2.2.0",
67
+ "eslint-plugin-react": "^7.37.4",
69
68
  "eslint-plugin-react-hooks": "^5.1.0",
70
- "eslint-plugin-storybook": "^0.11.0",
71
- "eslint-plugin-tailwindcss": "^3.17.5",
69
+ "eslint-plugin-storybook": "^0.11.2",
70
+ "eslint-plugin-tailwindcss": "^3.18.0",
72
71
  "eslint-plugin-testing-library": "^7.1.1",
73
72
  "globals": "^15.14.0",
74
- "typescript-eslint": "^8.19.0"
73
+ "typescript-eslint": "^8.21.0"
75
74
  },
76
75
  "publishConfig": {
77
76
  "access": "public"