@smartive/eslint-config 5.2.0 → 6.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/README.md CHANGED
@@ -10,24 +10,28 @@ $ npm install eslint @smartive/eslint-config -D
10
10
 
11
11
  ## Usage
12
12
 
13
- Create a `.eslintrc` file in the root of your project's directory (it should live where `package.json` does). This package offers two different rulesets, on for plain TypeScript applications (`@smartive/eslint-config`) and a separate one for React applications (`@smartive/eslint-config`). Your `.eslintrc` file should look like this:
13
+ This package offers two different rule sets, one for plain TypeScript applications and a separate one for React applications.
14
14
 
15
- ### Plain TypeScript applications
15
+ ### Flat Config (`eslint.config.mjs`)
16
16
 
17
- ```
18
- {
19
- "extends": [
20
- "@smartive/eslint-config"
21
- ]
22
- }
23
- ```
17
+ ```javascript
18
+ import { configs } from '@smartive/eslint-config'
24
19
 
25
- ### React applications
20
+ // For plain TS applications ..
21
+ export default configs.typescript;
26
22
 
23
+ // .. or React applications
24
+ export default configs.react;
27
25
  ```
26
+
27
+ ### Legacy Config (`.eslintrc`)
28
+
29
+ ```json
28
30
  {
29
31
  "extends": [
30
- "@smartive/eslint-config/react"
32
+ "@smartive/eslint-config/typescript-legacy" // Plain TS applications
33
+ // or
34
+ "@smartive/eslint-config/react-legacy" // React applications
31
35
  ]
32
36
  }
33
37
  ```
@@ -42,7 +46,3 @@ To use eslint add the following to your package.json:
42
46
  "lint:fix": "eslint . --fix"
43
47
  }
44
48
  ```
45
-
46
- ### TypeScript configuration
47
-
48
- Since there are some rules which require type information please make sure to set up a `tsconfig.json` configuration file in the root directory of your project. If your TypeScript configuration file is placed in another location you have to configure it using `parserOptions.project` in your ESLint configuration file. For more information have a look at the [typescript-eslint documentation](https://typescript-eslint.io/packages/parser/#project).
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var src_exports = {};
30
+ __export(src_exports, {
31
+ configs: () => configs,
32
+ generateLegacyConfig: () => generateLegacyConfig
33
+ });
34
+ module.exports = __toCommonJS(src_exports);
35
+ var import_js = __toESM(require("@eslint/js"));
36
+ var import_eslint_plugin_import = require("eslint-plugin-import");
37
+ var import_recommended = __toESM(require("eslint-plugin-prettier/recommended"));
38
+ var import_eslint_plugin_react = __toESM(require("eslint-plugin-react"));
39
+ var import_globals = __toESM(require("globals"));
40
+ var import_typescript_eslint = __toESM(require("typescript-eslint"));
41
+ const reactRules = {
42
+ "react/prop-types": "off",
43
+ "react/display-name": "off",
44
+ "react/forbid-component-props": ["warn", { forbid: ["style", "className"] }],
45
+ "@typescript-eslint/no-misused-promises": [
46
+ "error",
47
+ {
48
+ checksVoidReturn: {
49
+ attributes: false
50
+ }
51
+ }
52
+ ]
53
+ };
54
+ const rules = (react) => ({
55
+ "@typescript-eslint/no-unsafe-enum-comparison": "off",
56
+ "@typescript-eslint/consistent-type-definitions": "off",
57
+ "@typescript-eslint/explicit-function-return-type": "off",
58
+ "@typescript-eslint/explicit-module-boundary-types": "off",
59
+ "@typescript-eslint/no-var-requires": "warn",
60
+ "@typescript-eslint/no-unused-vars": ["error"],
61
+ "@typescript-eslint/no-floating-promises": ["error"],
62
+ "@typescript-eslint/no-explicit-any": ["error", { fixToUnknown: true }],
63
+ "no-constant-binary-expression": "error",
64
+ "array-callback-return": "error",
65
+ "no-debugger": "error",
66
+ "no-alert": "error",
67
+ "no-console": ["error", { allow: ["debug", "info", "warn", "error", "trace", "time", "timeEnd"] }],
68
+ "newline-before-return": "error",
69
+ "prefer-const": "error",
70
+ "no-else-return": "error",
71
+ "no-extra-semi": "error",
72
+ curly: "error",
73
+ eqeqeq: "error",
74
+ "default-case-last": "error",
75
+ "prettier/prettier": [
76
+ "error",
77
+ {
78
+ endOfLine: "auto"
79
+ }
80
+ ],
81
+ ...react ? reactRules : {}
82
+ });
83
+ const generateLegacyConfig = (react) => ({
84
+ rules: rules(react),
85
+ env: {
86
+ es2020: true,
87
+ browser: true,
88
+ node: true
89
+ },
90
+ parserOptions: {
91
+ ecmaVersion: 2020,
92
+ sourceType: "module",
93
+ projectService: true
94
+ },
95
+ extends: [
96
+ "eslint:recommended",
97
+ "plugin:prettier/recommended",
98
+ "plugin:import/errors",
99
+ "plugin:import/warnings",
100
+ "plugin:import/typescript",
101
+ "plugin:@typescript-eslint/recommended-type-checked",
102
+ "plugin:@typescript-eslint/stylistic-type-checked",
103
+ ...react ? ["plugin:react/recommended", "plugin:react/jsx-runtime"] : []
104
+ ],
105
+ globals: {
106
+ Atomics: "readonly",
107
+ SharedArrayBuffer: "readonly"
108
+ },
109
+ parser: "@typescript-eslint/parser",
110
+ plugins: ["@typescript-eslint", "prettier"]
111
+ });
112
+ const flatConfigTypescript = import_typescript_eslint.default.config(
113
+ import_js.default.configs.recommended,
114
+ import_recommended.default,
115
+ import_eslint_plugin_import.flatConfigs.errors,
116
+ import_eslint_plugin_import.flatConfigs.warnings,
117
+ import_eslint_plugin_import.flatConfigs.typescript,
118
+ import_typescript_eslint.default.configs.recommendedTypeChecked,
119
+ import_typescript_eslint.default.configs.stylisticTypeChecked,
120
+ {
121
+ rules: rules(false),
122
+ languageOptions: {
123
+ ecmaVersion: 2020,
124
+ sourceType: "module",
125
+ globals: {
126
+ ...import_globals.default.browser,
127
+ ...import_globals.default.node,
128
+ ...import_globals.default.es2020,
129
+ Atomics: "readonly",
130
+ SharedArrayBuffer: "readonly"
131
+ },
132
+ parserOptions: {
133
+ ecmaVersion: 2020,
134
+ sourceType: "module",
135
+ projectService: true
136
+ }
137
+ }
138
+ }
139
+ );
140
+ const flatConfigReact = import_typescript_eslint.default.config(
141
+ flatConfigTypescript,
142
+ import_eslint_plugin_react.default.configs.flat.recommended,
143
+ import_eslint_plugin_react.default.configs.flat["jsx-runtime"],
144
+ { rules: reactRules }
145
+ );
146
+ const configs = {
147
+ typescript: flatConfigTypescript,
148
+ react: flatConfigReact
149
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ var import__ = require("./");
3
+ module.exports = (0, import__.generateLegacyConfig)(true);
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ var import__ = require("./");
3
+ module.exports = (0, import__.generateLegacyConfig)(false);
@@ -0,0 +1,119 @@
1
+ import js from "@eslint/js";
2
+ import { flatConfigs as eslintPluginImportConfigs } from "eslint-plugin-import";
3
+ import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
4
+ import reactPlugin from "eslint-plugin-react";
5
+ import globals from "globals";
6
+ import tsEslint from "typescript-eslint";
7
+ const reactRules = {
8
+ "react/prop-types": "off",
9
+ "react/display-name": "off",
10
+ "react/forbid-component-props": ["warn", { forbid: ["style", "className"] }],
11
+ "@typescript-eslint/no-misused-promises": [
12
+ "error",
13
+ {
14
+ checksVoidReturn: {
15
+ attributes: false
16
+ }
17
+ }
18
+ ]
19
+ };
20
+ const rules = (react) => ({
21
+ "@typescript-eslint/no-unsafe-enum-comparison": "off",
22
+ "@typescript-eslint/consistent-type-definitions": "off",
23
+ "@typescript-eslint/explicit-function-return-type": "off",
24
+ "@typescript-eslint/explicit-module-boundary-types": "off",
25
+ "@typescript-eslint/no-var-requires": "warn",
26
+ "@typescript-eslint/no-unused-vars": ["error"],
27
+ "@typescript-eslint/no-floating-promises": ["error"],
28
+ "@typescript-eslint/no-explicit-any": ["error", { fixToUnknown: true }],
29
+ "no-constant-binary-expression": "error",
30
+ "array-callback-return": "error",
31
+ "no-debugger": "error",
32
+ "no-alert": "error",
33
+ "no-console": ["error", { allow: ["debug", "info", "warn", "error", "trace", "time", "timeEnd"] }],
34
+ "newline-before-return": "error",
35
+ "prefer-const": "error",
36
+ "no-else-return": "error",
37
+ "no-extra-semi": "error",
38
+ curly: "error",
39
+ eqeqeq: "error",
40
+ "default-case-last": "error",
41
+ "prettier/prettier": [
42
+ "error",
43
+ {
44
+ endOfLine: "auto"
45
+ }
46
+ ],
47
+ ...react ? reactRules : {}
48
+ });
49
+ const generateLegacyConfig = (react) => ({
50
+ rules: rules(react),
51
+ env: {
52
+ es2020: true,
53
+ browser: true,
54
+ node: true
55
+ },
56
+ parserOptions: {
57
+ ecmaVersion: 2020,
58
+ sourceType: "module",
59
+ projectService: true
60
+ },
61
+ extends: [
62
+ "eslint:recommended",
63
+ "plugin:prettier/recommended",
64
+ "plugin:import/errors",
65
+ "plugin:import/warnings",
66
+ "plugin:import/typescript",
67
+ "plugin:@typescript-eslint/recommended-type-checked",
68
+ "plugin:@typescript-eslint/stylistic-type-checked",
69
+ ...react ? ["plugin:react/recommended", "plugin:react/jsx-runtime"] : []
70
+ ],
71
+ globals: {
72
+ Atomics: "readonly",
73
+ SharedArrayBuffer: "readonly"
74
+ },
75
+ parser: "@typescript-eslint/parser",
76
+ plugins: ["@typescript-eslint", "prettier"]
77
+ });
78
+ const flatConfigTypescript = tsEslint.config(
79
+ js.configs.recommended,
80
+ eslintPluginPrettierRecommended,
81
+ eslintPluginImportConfigs.errors,
82
+ eslintPluginImportConfigs.warnings,
83
+ eslintPluginImportConfigs.typescript,
84
+ tsEslint.configs.recommendedTypeChecked,
85
+ tsEslint.configs.stylisticTypeChecked,
86
+ {
87
+ rules: rules(false),
88
+ languageOptions: {
89
+ ecmaVersion: 2020,
90
+ sourceType: "module",
91
+ globals: {
92
+ ...globals.browser,
93
+ ...globals.node,
94
+ ...globals.es2020,
95
+ Atomics: "readonly",
96
+ SharedArrayBuffer: "readonly"
97
+ },
98
+ parserOptions: {
99
+ ecmaVersion: 2020,
100
+ sourceType: "module",
101
+ projectService: true
102
+ }
103
+ }
104
+ }
105
+ );
106
+ const flatConfigReact = tsEslint.config(
107
+ flatConfigTypescript,
108
+ reactPlugin.configs.flat.recommended,
109
+ reactPlugin.configs.flat["jsx-runtime"],
110
+ { rules: reactRules }
111
+ );
112
+ const configs = {
113
+ typescript: flatConfigTypescript,
114
+ react: flatConfigReact
115
+ };
116
+ export {
117
+ configs,
118
+ generateLegacyConfig
119
+ };
@@ -0,0 +1,11 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __commonJS = (cb, mod) => function __require() {
3
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
+ };
5
+ import { generateLegacyConfig } from "./";
6
+ var require_react_legacy = __commonJS({
7
+ "src/react-legacy.ts"(exports, module) {
8
+ module.exports = generateLegacyConfig(true);
9
+ }
10
+ });
11
+ export default require_react_legacy();
@@ -0,0 +1,11 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __commonJS = (cb, mod) => function __require() {
3
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
+ };
5
+ import { generateLegacyConfig } from "./";
6
+ var require_typescript_legacy = __commonJS({
7
+ "src/typescript-legacy.ts"(exports, module) {
8
+ module.exports = generateLegacyConfig(false);
9
+ }
10
+ });
11
+ export default require_typescript_legacy();
@@ -0,0 +1,6 @@
1
+ import type { Linter } from 'eslint';
2
+ export declare const generateLegacyConfig: (react: boolean) => Linter.LegacyConfig;
3
+ export declare const configs: {
4
+ typescript: import("@typescript-eslint/utils/dist/ts-eslint").FlatConfig.ConfigArray;
5
+ react: import("@typescript-eslint/utils/dist/ts-eslint").FlatConfig.ConfigArray;
6
+ };
package/package.json CHANGED
@@ -1,8 +1,27 @@
1
1
  {
2
2
  "name": "@smartive/eslint-config",
3
- "version": "5.2.0",
3
+ "version": "6.0.0",
4
4
  "description": "ESLint configuration by smartive",
5
- "main": "index.js",
5
+ "files": [
6
+ "README.md",
7
+ "LICENSE",
8
+ "dist"
9
+ ],
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/esm/index.js",
14
+ "require": "./dist/cjs/index.js"
15
+ },
16
+ "./react-legacy": {
17
+ "import": "./dist/esm/react-legacy.js",
18
+ "require": "./dist/cjs/react-legacy.js"
19
+ },
20
+ "./typescript-legacy": {
21
+ "import": "./dist/esm/typescript-legacy.js",
22
+ "require": "./dist/cjs/typescript-legacy.js"
23
+ }
24
+ },
6
25
  "repository": {
7
26
  "type": "git",
8
27
  "url": "git+https://github.com/smartive/eslint-config.git"
@@ -20,26 +39,37 @@
20
39
  },
21
40
  "homepage": "https://github.com/smartive/eslint-config#readme",
22
41
  "dependencies": {
23
- "@typescript-eslint/eslint-plugin": "^6.7.4",
24
- "@typescript-eslint/parser": "^6.7.4",
25
- "eslint-config-prettier": "^9.0.0",
26
- "eslint-plugin-import": "^2.25.3",
27
- "eslint-plugin-prettier": ">=4.0.0 <6",
28
- "eslint-plugin-react": "^7.27.0",
29
- "eslint-plugin-react-hooks": "^4.3.0"
42
+ "@typescript-eslint/eslint-plugin": "^8.15.0",
43
+ "@typescript-eslint/parser": "^8.15.0",
44
+ "eslint-config-prettier": "^9.1.0",
45
+ "eslint-plugin-import": "^2.31.0",
46
+ "eslint-plugin-prettier": "^5.2.1",
47
+ "eslint-plugin-react": "^7.37.2",
48
+ "eslint-plugin-react-hooks": "^5.0.0",
49
+ "globals": "^15.13.0",
50
+ "typescript-eslint": "^8.15.0"
30
51
  },
31
52
  "peerDependencies": {
32
- "eslint": "^8.0.0"
53
+ "eslint": "^8.57.0 || ^9.0.0"
33
54
  },
34
55
  "devDependencies": {
35
- "@commitlint/cli": "^19.0.0",
36
- "@commitlint/config-conventional": "^19.0.0",
56
+ "@commitlint/cli": "^19.6.0",
57
+ "@commitlint/config-conventional": "^19.6.0",
58
+ "@eslint/js": "^9.15.0",
37
59
  "@smartive/prettier-config": "^3.0.0",
60
+ "@types/node": "^22.9.1",
38
61
  "cz-conventional-changelog": "^3.3.0",
39
- "husky": "^9.0.0",
40
- "prettier": "^3.0.0"
62
+ "esbuild": "0.24.0",
63
+ "eslint": "^9.15.0",
64
+ "husky": "^9.1.7",
65
+ "prettier": "^3.3.3",
66
+ "typescript": "^5.6.3"
41
67
  },
42
68
  "scripts": {
69
+ "build:types": "tsc --declaration --emitDeclarationOnly",
70
+ "build:cjs": "esbuild --platform=browser --format=cjs --outdir=dist/cjs/ ./src/*.ts",
71
+ "build:mjs": "esbuild --platform=neutral --format=esm --outdir=dist/esm/ ./src/*.ts",
72
+ "build": "rm -rf dist && npm run build:cjs && npm run build:mjs && npm run build:types",
43
73
  "commitlint": "commitlint --edit",
44
74
  "prepare": "[ ! -f node_modules/.bin/husky ] || husky"
45
75
  },
package/.eslintrc.js DELETED
@@ -1,56 +0,0 @@
1
- /** @type {import('eslint').Linter.Config} */
2
- module.exports = {
3
- rules: {
4
- '@typescript-eslint/no-unsafe-enum-comparison': 'off',
5
- '@typescript-eslint/consistent-type-definitions': 'off',
6
- '@typescript-eslint/explicit-function-return-type': 'off',
7
- '@typescript-eslint/explicit-module-boundary-types': 'off',
8
- '@typescript-eslint/no-var-requires': 'warn',
9
- '@typescript-eslint/no-unused-vars': ['error'],
10
- '@typescript-eslint/no-floating-promises': ['error'],
11
- '@typescript-eslint/no-explicit-any': ['error', { fixToUnknown: true }],
12
- 'no-constant-binary-expression': 'error',
13
- 'array-callback-return': 'error',
14
- 'no-debugger': 'error',
15
- 'no-alert': 'error',
16
- 'no-console': ['error', { allow: ['debug', 'info', 'warn', 'error', 'trace', 'time', 'timeEnd'] }],
17
- 'newline-before-return': 'error',
18
- 'prefer-const': 'error',
19
- 'no-else-return': 'error',
20
- 'no-extra-semi': 'error',
21
- curly: 'error',
22
- eqeqeq: 'error',
23
- 'default-case-last': 'error',
24
- 'prettier/prettier': [
25
- 'error',
26
- {
27
- endOfLine: 'auto',
28
- },
29
- ],
30
- },
31
- env: {
32
- es6: true,
33
- browser: true,
34
- node: true,
35
- },
36
- parserOptions: {
37
- ecmaVersion: 2018,
38
- sourceType: 'module',
39
- project: true,
40
- },
41
- extends: [
42
- 'eslint:recommended',
43
- 'plugin:prettier/recommended',
44
- 'plugin:import/errors',
45
- 'plugin:import/warnings',
46
- 'plugin:import/typescript',
47
- 'plugin:@typescript-eslint/recommended-type-checked',
48
- 'plugin:@typescript-eslint/stylistic-type-checked',
49
- ],
50
- globals: {
51
- Atomics: 'readonly',
52
- SharedArrayBuffer: 'readonly',
53
- },
54
- parser: '@typescript-eslint/parser',
55
- plugins: ['@typescript-eslint', 'prettier'],
56
- };
@@ -1,30 +0,0 @@
1
- /** @type {import('eslint').Linter.Config} */
2
- module.exports = {
3
- rules: {
4
- 'react/react-in-jsx-scope': 'off',
5
- 'react/prop-types': 'off',
6
- 'react/display-name': 'off',
7
- 'react/forbid-component-props': ['warn', { forbid: ['style', 'className'] }],
8
- '@typescript-eslint/no-misused-promises': [
9
- 'error',
10
- {
11
- checksVoidReturn: {
12
- attributes: false,
13
- },
14
- },
15
- ],
16
- },
17
- parserOptions: {
18
- ecmaFeatures: {
19
- jsx: true,
20
- },
21
- },
22
- extends: ['./index', 'plugin:react/recommended'],
23
- settings: {
24
- react: {
25
- pragma: 'React',
26
- version: 'detect',
27
- },
28
- },
29
- plugins: ['react', 'react-hooks'],
30
- };
package/.husky/commit-msg DELETED
@@ -1 +0,0 @@
1
- npm run commitlint ${1}
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- 20
package/.prettierrc DELETED
@@ -1 +0,0 @@
1
- "@smartive/prettier-config"
package/.releaserc.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "branches": [
3
- "main",
4
- {
5
- "name": "next",
6
- "prerelease": true
7
- }
8
- ],
9
- "plugins": [
10
- "@semantic-release/commit-analyzer",
11
- "@semantic-release/release-notes-generator",
12
- "@semantic-release/changelog",
13
- "@semantic-release/npm",
14
- "@semantic-release/github"
15
- ]
16
- }
package/CHANGELOG.md DELETED
@@ -1,6 +0,0 @@
1
- # [5.2.0](https://github.com/smartive/eslint-config/compare/v5.1.0...v5.2.0) (2024-11-07)
2
-
3
-
4
- ### Features
5
-
6
- * Allow console.debug() ([#33](https://github.com/smartive/eslint-config/issues/33)) ([1c56a19](https://github.com/smartive/eslint-config/commit/1c56a1931571a7edc2ab2cd0e2b094d18d7be772))
@@ -1 +0,0 @@
1
- module.exports = { extends: ['@commitlint/config-conventional'] };
package/index.js DELETED
@@ -1,3 +0,0 @@
1
- const eslintrc = require('./.eslintrc');
2
-
3
- module.exports = eslintrc;
package/react.js DELETED
@@ -1,3 +0,0 @@
1
- const eslintrc = require('./.eslintrc.react');
2
-
3
- module.exports = eslintrc;
package/renovate.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
- "extends": [
4
- "local>smartive/renovate-config", ":automergeDisabled", ":preserveSemverRanges"
5
- ]
6
- }