@useinsider/eslint-config 1.0.1-beta.7 → 1.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/README.md CHANGED
@@ -1,20 +1,17 @@
1
- # ESLint Config
2
-
3
- Welcome to Insider's shared ESLint configuration! This project offers a set of
4
- ESLint rules tailored for both EcmaScript/JavaScript and TypeScript. It is
5
- designed to help you seamlessly integrate Insider's coding style into your
6
- development workflow.
1
+ # ESLint Configurations
7
2
 
8
3
  ## Table of Contents
9
- - [ESLint Config](#eslint-config)
4
+ - [ESLint Configurations](#eslint-configurations)
10
5
  - [Table of Contents](#table-of-contents)
11
6
  - [Getting Started](#getting-started)
12
7
  - [Installation](#installation)
8
+ - [Versioning Policy](#versioning-policy)
13
9
  - [Available Configurations](#available-configurations)
14
- - [Upcoming Configurations](#upcoming-configurations)
10
+ - [Vanilla 🍦](#vanilla-)
11
+ - [Framework-specific](#framework-specific)
12
+ - [⏳ Upcoming Configurations](#-upcoming-configurations)
15
13
  - [Contributing](#contributing)
16
14
 
17
-
18
15
  ## Getting Started
19
16
 
20
17
  To ensure consistency and prevent version conflicts, we recommend adding this
@@ -24,16 +21,19 @@ using the `-D` and `-E` flags in your package manager commands.
24
21
  ### Installation
25
22
 
26
23
  1. **Install as a Development Dependency:**
27
- - For npm users:
28
- ```bash
29
- npm install -D -E @useinsider/eslint-config
30
- ```
31
24
  - For pnpm users:
32
25
  ```bash
33
26
  pnpm add -D -E @useinsider/eslint-config
34
27
  ```
28
+ - For npm users:
29
+ ```bash
30
+ npm install -D -E @useinsider/eslint-config
31
+ ```
32
+ 2. **Create an ESLint config file:**
33
+ You'll need an ESLint config file in your projects root directory.
35
34
 
36
- 2. **Extend the Configuration:**
35
+ You can check the official [ESLint documentation] to get more details.
36
+ 3. **Extend the Configuration:**
37
37
  Add the following to your `.eslintrc` file to extend the configuration:
38
38
  ```json5
39
39
  {
@@ -42,28 +42,44 @@ using the `-D` and `-E` flags in your package manager commands.
42
42
  }
43
43
  ```
44
44
 
45
+ [ESLint documentation]: https://eslint.org/docs/latest/use/configure/configuration-files
46
+
47
+ ## Versioning Policy
48
+
49
+ This project follows the [Semantic Versioning](https://semver.org) policy.
50
+
45
51
  ## Available Configurations
46
52
 
47
53
  We provide a variety of configurations to suit different environments and
48
54
  frameworks. Here's a list of available configurations:
49
55
 
50
- | Environment | Browser | Node |
51
- | :---------------- | :--------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------- |
52
- | **EcmaScript/JS** | [`@useinsider/eslint-config/dom`](./src/dom.cjs) | [`@useinsider/eslint-config`](./src/node.cjs)<br>[`@useinsider/eslint-config/node`](./src/node.cjs) |
53
- | **TypeScript** | [`@useinsider/eslint-config/typescript-dom`](./src/typescript-dom.cjs) | [`@useinsider/eslint-config/typescript`](./src/typescript.cjs) |
54
- | **Vue 3** | [`@useinsider/eslint-config/vue3`](./src/vue3.cjs) | - |
56
+ ### Vanilla 🍦
55
57
 
56
- ### Upcoming Configurations
58
+ | Environment | Browser (DOM) | Node |
59
+ | :---------------- | :------------------------------------------------------------------------ | :-------------------------------------------------------------------------------------------------------- |
60
+ | **EcmaScript/JS** | [`@useinsider/eslint-config/dom`](./src/dom#readme) | [`@useinsider/eslint-config`](./src/node#readme)<br>[`@useinsider/eslint-config/node`](./src/node#readme) |
61
+ | **TypeScript** | [`@useinsider/eslint-config/typescript-dom`](./src/typescript-dom#readme) | [`@useinsider/eslint-config/typescript`](./src/typescript#readme) |
62
+ | **Config files** | | [`@useinsider/eslint-config/config`](./src/config#readme) |
63
+
64
+ ### Framework-specific
65
+
66
+ | Environment | JavaScript | TypeScript |
67
+ | :---------- | :---------------------------------------------------- | :-------------------------------------------------------------------------- |
68
+ | **Vue 3** | [`@useinsider/eslint-config/vue3`](./src/vue3#readme) | [`@useinsider/eslint-config/vue3-typescript`](./src/vue3-typescript#readme) |
69
+
70
+ ### ⏳ Upcoming Configurations
57
71
 
58
72
  Not available yet!
59
73
 
60
- | Environment | Browser | Node |
61
- | :---------------- | :------------------------------------------------------------- | :----------------------------------------------------- |
62
- | **Legacy ES5 💀​** | [`@useinsider/eslint-config/legacy-dom`](./src/legacy-dom.cjs) | [`@useinsider/eslint-config/legacy`](./src/legacy.cjs) |
63
- | **Vue 2** | [`@useinsider/eslint-config/vue2`](./src/vue2.cjs) | - |
74
+ | Environment | Browser (DOM) | Node |
75
+ | :---------------- | :---------------------------------------------------------------- | :-------------------------------------------------------- |
76
+ | **Legacy ES5 💀​** | [`@useinsider/eslint-config/legacy-dom`](./src/legacy-dom#readme) | [`@useinsider/eslint-config/legacy`](./src/legacy#readme) |
77
+
78
+ | Environment | JavaScript | TypeScript |
79
+ | :---------- | :---------------------------------------------------- | :-------------------------------------------------------------------------- |
80
+ | **Vue 2** | [`@useinsider/eslint-config/vue2`](./src/vue2#readme) | [`@useinsider/eslint-config/vue2-typescript`](./src/vue2-typescript#readme) |
64
81
 
65
82
  ## Contributing
66
83
 
67
- Your contributions are welcome!
68
- Please consult the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines on how
69
- to contribute to this project.
84
+ Please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines on
85
+ how to contribute to this project.
package/package.json CHANGED
@@ -1,29 +1,37 @@
1
1
  {
2
2
  "name": "@useinsider/eslint-config",
3
+ "version": "1.1.0",
4
+ "keywords": [
5
+ "useinsider",
6
+ "eslint",
7
+ "eslint-config"
8
+ ],
3
9
  "author": "Sahin Deniz <sahin.deniz@useinsider.com>",
4
10
  "license": "MIT",
5
- "version": "1.0.1-beta.7",
6
11
  "packageManager": "pnpm@8.11.0",
7
12
  "scripts": {
8
- "lint": "eslint --ext .js,.cjs ./",
9
- "lint:fix": "pnpm lint --fix"
13
+ "lint": "eslint ./",
14
+ "lint:ci": "pnpm lint --quiet",
15
+ "lint:fix": "pnpm lint --fix",
16
+ "release": "semantic-release -e semantic-release-monorepo"
10
17
  },
11
- "homepage": "https://github.com/useinsider/eslint-config#readme",
18
+ "homepage": "https://github.com/useinsider/config#readme",
12
19
  "repository": {
13
20
  "type": "git",
14
- "url": "git+https://github.com/useinsider/eslint-config.git"
21
+ "url": "git+https://github.com/useinsider/config.git"
15
22
  },
16
23
  "bugs": {
17
- "url": "https://github.com/useinsider/eslint-config/issues"
24
+ "url": "https://github.com/useinsider/config/issues"
18
25
  },
19
26
  "exports": {
20
- ".": "./src/node.cjs",
21
- "./dom": "./src/dom.cjs",
22
- "./typescript": "./src/typescript.cjs",
23
- "./typescript-dom": "./src/typescript-dom.cjs",
24
- "./vue3": "./src/vue3.cjs",
25
- "./node": "./src/node.cjs",
26
- "./config": "./src/config.cjs"
27
+ ".": "./src/node/index.cjs",
28
+ "./node": "./src/node/index.cjs",
29
+ "./config": "./src/config/index.cjs",
30
+ "./dom": "./src/dom/index.cjs",
31
+ "./typescript": "./src/typescript/index.cjs",
32
+ "./typescript-dom": "./src/typescript-dom/index.cjs",
33
+ "./vue3": "./src/vue3/index.cjs",
34
+ "./vue3-typescript": "./src/vue3-typescript/index.cjs"
27
35
  },
28
36
  "files": [
29
37
  "src/**/*"
@@ -44,7 +52,9 @@
44
52
  "@semantic-release/git": "10.0.1",
45
53
  "@types/eslint": "8.44.8",
46
54
  "@types/node": "20.10.2",
47
- "semantic-release": "22.0.8"
55
+ "@useinsider/release-config": "workspace:*",
56
+ "semantic-release": "19.0.5",
57
+ "semantic-release-monorepo": "7.0.5"
48
58
  },
49
59
  "optionalDependencies": {
50
60
  "@rushstack/eslint-patch": ">=1.6.0",
@@ -0,0 +1,56 @@
1
+ # @useinsider/eslint-config/config
2
+
3
+ This rule set specifically targets configuration files typically placed at the
4
+ root level of your project. These files are not part of your production build
5
+ but are crucial for maintaining consistent coding standards across your
6
+ development environment.
7
+
8
+ **Examples of such files include:**
9
+ - `.eslintrc.js`
10
+ - `vite.config.ts`
11
+ - `scripts/.../watch-build.js`
12
+ - ...and more.
13
+
14
+ ## How to Use
15
+
16
+ To integrate these rules into your project, modify your `.eslintrc` file as
17
+ follows:
18
+
19
+ ```js
20
+ /** @type {import("eslint").Linter.Config} */
21
+ module.exports = {
22
+ root: true,
23
+ overrides: [
24
+ {
25
+ // For JavaScript configuration files at root level
26
+ files: ['./*.js', './*.cjs'],
27
+ extends: [
28
+ '@useinsider/eslint-config',
29
+ '@useinsider/eslint-config/config',
30
+ ],
31
+ // Add additional configurations here
32
+ },
33
+
34
+ {
35
+ // For TypeScript configuration files, including those in 'scripts' directory
36
+ files: ['./*.ts', './scripts/**/*.ts'],
37
+ extends: [
38
+ '@useinsider/eslint-config',
39
+ '@useinsider/eslint-config/typescript',
40
+ '@useinsider/eslint-config/config',
41
+ ],
42
+ parserOptions: {
43
+ // Required for '@typescript-eslint/parser'
44
+ project: ['./tsconfig.json'],
45
+ },
46
+ },
47
+ ],
48
+ };
49
+ ```
50
+
51
+ <blockquote>
52
+ <p>[!NOTE]<br>
53
+ Ensure that the <code>parserOptions.project</code> path correctly points to
54
+ your <code>tsconfig.json</code> file to enable TypeScript linting.
55
+ </p>
56
+ </blockquote>
@@ -0,0 +1,56 @@
1
+ # @useinsider/eslint-config/dom
2
+
3
+ This configuration is designed for production source files typically located in
4
+ the `src` directory of your project. It provides ESLint rules specifically for
5
+ DOM-related code.
6
+
7
+ ## Installation
8
+
9
+ Before proceeding, ensure you have ESLint installed in your project.
10
+ If not, install it:
11
+
12
+ ```bash
13
+ pnpm add -E -D eslint
14
+ ```
15
+
16
+ ```bash
17
+ npm install -E -D eslint
18
+ ```
19
+
20
+ Then, install the ESLint plugins that our configuration extends. These are
21
+ necessary for the configuration to work correctly:
22
+
23
+ ```bash
24
+ pnpm add -E -D \
25
+ eslint-config-airbnb-base \
26
+ eslint-plugin-jsdoc \
27
+ @cspell/eslint-plugin
28
+ ```
29
+
30
+ ```bash
31
+ npm install -E -D \
32
+ eslint-config-airbnb-base \
33
+ eslint-plugin-jsdoc \
34
+ @cspell/eslint-plugin
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ To integrate these rules into your project, modify your `.eslintrc` file as
40
+ follows:
41
+
42
+ ```js
43
+ /** @type {import("eslint").Linter.Config} */
44
+ module.exports = {
45
+ root: true,
46
+ overrides: [
47
+ {
48
+ files: ['./src/**/*.js'],
49
+ extends: [
50
+ '@useinsider/eslint-config/dom',
51
+ ],
52
+ // Add additional configuration settings as needed
53
+ },
54
+ ],
55
+ };
56
+ ```
@@ -0,0 +1,19 @@
1
+ /** @type {import("eslint").Linter.Config} */
2
+ module.exports = {
3
+ extends: [
4
+ require.resolve('../base.cjs'),
5
+ 'airbnb-base',
6
+ 'plugin:jsdoc/recommended',
7
+ 'plugin:@cspell/recommended',
8
+ require.resolve('../rules/core.cjs'),
9
+ require.resolve('../rules/stylistic.cjs'),
10
+ require.resolve('../rules/jsdoc.cjs'),
11
+ ],
12
+ env: {
13
+ browser: true,
14
+ es2021: true,
15
+ },
16
+ parserOptions: {
17
+ ecmaVersion: 'latest',
18
+ },
19
+ };
@@ -0,0 +1,56 @@
1
+ # @useinsider/eslint-config/node
2
+
3
+ This ESLint configuration is ideal for Node.js projects without front-end
4
+ elements or DOM libraries. For mixed back-end and front-end projects, separate
5
+ override blocks or a combined `node` and `dom` setup in a single block are
6
+ possible, but not recommended.
7
+
8
+ ## Installation
9
+
10
+ Before proceeding, ensure you have ESLint installed in your project.
11
+ If not, install it:
12
+
13
+ ```bash
14
+ pnpm add -E -D eslint
15
+ ```
16
+
17
+ ```bash
18
+ npm install -E -D eslint
19
+ ```
20
+
21
+ Then, install the ESLint plugins that our configuration extends. These are
22
+ necessary for the configuration to work correctly:
23
+
24
+ ```bash
25
+ pnpm add -E -D \
26
+ eslint-config-airbnb-base \
27
+ eslint-plugin-jsdoc \
28
+ @cspell/eslint-plugin
29
+ ```
30
+
31
+ ```bash
32
+ npm install -E -D \
33
+ eslint-config-airbnb-base \
34
+ eslint-plugin-jsdoc \
35
+ @cspell/eslint-plugin
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ To integrate these rules into your project, modify your `.eslintrc` file as
41
+ follows:
42
+
43
+ ```js
44
+ module.exports = {
45
+ root: true,
46
+ overrides: [
47
+ {
48
+ files: ['./src/**/*.{js,cjs,mjs}'],
49
+ extends: [
50
+ '@useinsider/eslint-config',
51
+ ],
52
+ // Additional configuration here
53
+ },
54
+ ],
55
+ };
56
+ ```
@@ -0,0 +1,18 @@
1
+ /** @type {import("eslint").Linter.Config} */
2
+ module.exports = {
3
+ extends: [
4
+ require.resolve('../base.cjs'),
5
+ 'airbnb-base',
6
+ 'plugin:jsdoc/recommended',
7
+ 'plugin:@cspell/recommended',
8
+ require.resolve('../rules/core.cjs'),
9
+ require.resolve('../rules/stylistic.cjs'),
10
+ require.resolve('../rules/jsdoc.cjs'),
11
+ ],
12
+ env: {
13
+ node: true,
14
+ },
15
+ parserOptions: {
16
+ ecmaVersion: 'latest',
17
+ },
18
+ };
@@ -0,0 +1,6 @@
1
+ # Rules
2
+
3
+ Each file contains only the rules that are specific to its name.
4
+ When a new plugin is introduced, its rule file must be named after the plugin
5
+ and it should only contain rules that are specific to it. Even if it suppresses
6
+ a core rule, oppressed rule must be declared inside the `core.cjs` file.
@@ -13,7 +13,13 @@ module.exports = {
13
13
  'guard-for-in': 'error',
14
14
  'handle-callback-err': ['error'],
15
15
  'import/extensions': ['error', {
16
+ css: 'always',
16
17
  js: 'never',
18
+ json: 'always',
19
+ jsx: 'never',
20
+ sass: 'always',
21
+ scss: 'always',
22
+ svg: 'always',
17
23
  ts: 'never',
18
24
  tsx: 'never',
19
25
  vue: 'always',
@@ -62,6 +68,7 @@ module.exports = {
62
68
  }],
63
69
  'no-invalid-regexp': ['error'],
64
70
  'no-iterator': ['error'],
71
+ 'no-mixed-operators': 'off',
65
72
  'no-multi-str': ['error'],
66
73
  'no-native-reassign': 'error',
67
74
  'no-nested-ternary': ['error'],
@@ -120,18 +127,18 @@ module.exports = {
120
127
  },
121
128
  {
122
129
  blankLine: 'always',
123
- prev: ['*'],
124
130
  next: ['multiline-block-like'],
131
+ prev: ['*'],
125
132
  },
126
133
  {
127
134
  blankLine: 'always',
128
- prev: ['multiline-block-like'],
129
135
  next: ['*'],
136
+ prev: ['multiline-block-like'],
130
137
  },
131
138
  {
132
139
  blankLine: 'any',
133
- prev: ['case'],
134
140
  next: ['case'],
141
+ prev: ['case'],
135
142
  },
136
143
  {
137
144
  blankLine: 'any',
@@ -144,6 +151,7 @@ module.exports = {
144
151
  }],
145
152
  'prefer-destructuring': ['error'],
146
153
  radix: ['error', 'as-needed'],
154
+ semi: 'off',
147
155
  'space-before-function-paren': 'off',
148
156
  strict: ['error'],
149
157
  'use-isnan': ['error'],
@@ -24,6 +24,10 @@ module.exports = {
24
24
  '@stylistic/implicit-arrow-linebreak': ['error', 'beside'],
25
25
  '@stylistic/indent': ['error', 4, {
26
26
  SwitchCase: 1,
27
+ ignoredNodes: [
28
+ 'PropertyDefinition[decorators]',
29
+ 'TSUnionType',
30
+ ],
27
31
  }],
28
32
  '@stylistic/key-spacing': ['error'],
29
33
  '@stylistic/keyword-spacing': ['error'],
@@ -53,6 +57,7 @@ module.exports = {
53
57
  '@stylistic/multiline-ternary': ['error', 'always-multiline'],
54
58
  '@stylistic/new-parens': ['error', 'always'],
55
59
  '@stylistic/no-extra-parens': ['error', 'all', {
60
+ allowParensAfterCommentPattern: '@type',
56
61
  enforceForArrowConditionals: false,
57
62
  nestedBinaryExpressions: false,
58
63
  returnAssign: false,
@@ -24,13 +24,7 @@ module.exports = {
24
24
  'no-useless-constructor': 'off',
25
25
  '@typescript-eslint/no-useless-constructor': 'error',
26
26
  '@typescript-eslint/array-type': ['error', { default: 'array', readonly: 'array' }],
27
- '@typescript-eslint/indent': ['error', 4, {
28
- SwitchCase: 1,
29
- ignoredNodes: [
30
- 'PropertyDefinition[decorators]',
31
- 'TSUnionType',
32
- ],
33
- }],
27
+ '@typescript-eslint/indent': 'off',
34
28
  semi: 'off',
35
29
  '@typescript-eslint/semi': ['error', 'always'],
36
30
  '@typescript-eslint/no-misused-promises': ['error', {
@@ -42,9 +36,5 @@ module.exports = {
42
36
  '@typescript-eslint/lines-between-class-members': ['error', 'always', {
43
37
  exceptAfterSingleLine: true,
44
38
  }],
45
-
46
- // TODO enable after SD-80950
47
- '@typescript-eslint/no-empty-function': 'off',
48
- '@typescript-eslint/no-explicit-any': 'off',
49
39
  },
50
40
  };