eslint-config-salesforce-typescript 4.0.1 → 6.0.1

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.
Files changed (3) hide show
  1. package/index.mjs +162 -0
  2. package/package.json +26 -21
  3. package/index.js +0 -122
package/index.mjs ADDED
@@ -0,0 +1,162 @@
1
+ import eslint from '@eslint/js';
2
+ import tseslint from 'typescript-eslint';
3
+ import eslintConfigPrettier from 'eslint-config-prettier';
4
+ import importPlugin from 'eslint-plugin-import-x';
5
+ import jsdocPlugin from 'eslint-plugin-jsdoc';
6
+ import unicornPlugin from 'eslint-plugin-unicorn';
7
+ import headerPlugin from '@tony.ganchev/eslint-plugin-header';
8
+
9
+ export default tseslint.config(
10
+ {
11
+ ignores:
12
+ [
13
+ '**/node_modules/**',
14
+ 'lib/**',
15
+ '**/*.js',
16
+ '**/*.cjs',
17
+ '**/*.mjs',
18
+ ],
19
+ },
20
+ eslint.configs.recommended,
21
+ ...tseslint.configs.recommendedTypeChecked,
22
+ {
23
+ languageOptions: {
24
+ parserOptions: {
25
+ projectService: true,
26
+ },
27
+ },
28
+ plugins: {
29
+ 'import-x': importPlugin,
30
+ jsdoc: jsdocPlugin,
31
+ unicorn: unicornPlugin,
32
+ header: headerPlugin,
33
+ },
34
+ rules: {
35
+ 'valid-typeof': 'off',
36
+ 'arrow-body-style': 'error',
37
+ 'prefer-arrow-callback': 'error',
38
+ camelcase: 'error',
39
+ complexity: 'error',
40
+ curly: ['error', 'multi-line'],
41
+ 'class-methods-use-this': 'error',
42
+ eqeqeq: ['error', 'smart'],
43
+ 'guard-for-in': 'error',
44
+ 'id-denylist': 'error',
45
+ 'id-match': 'error',
46
+ 'no-await-in-loop': 'error',
47
+ 'no-caller': 'error',
48
+ 'no-console': 'error',
49
+ 'no-eval': 'error',
50
+ 'no-lonely-if': 'error',
51
+ 'no-new-wrappers': 'error',
52
+ 'no-octal-escape': 'error',
53
+ 'no-restricted-imports': [
54
+ 'error',
55
+ {
56
+ patterns: [
57
+ {
58
+ group: ['src/**'],
59
+ message: "imports from this repo's src folder should be a relative path",
60
+ },
61
+ {
62
+ group: ['**/../lib/**', 'lib/**'],
63
+ message: 'import from /src not from /lib. /lib is a build artifact',
64
+ },
65
+ ],
66
+ },
67
+ ],
68
+ 'no-shadow': 'off',
69
+ 'no-throw-literal': 'error',
70
+ 'no-undef-init': 'error',
71
+ 'no-underscore-dangle': 'error',
72
+ 'no-unsafe-finally': 'error',
73
+ 'no-unused-expressions': 'error',
74
+ 'no-var': 'error',
75
+ 'object-shorthand': 'error',
76
+ 'one-var': ['error', 'never'],
77
+ 'prefer-const': 'error',
78
+ 'prefer-spread': 'error',
79
+ radix: 'error',
80
+ 'spaced-comment': ['error', 'always', { markers: ['/'] }],
81
+ 'use-isnan': 'error',
82
+
83
+ 'import-x/order': 'error',
84
+
85
+ 'jsdoc/check-alignment': 'error',
86
+ 'jsdoc/check-indentation': 'error',
87
+ 'jsdoc/tag-lines': [2, 'any', { startLines: 1, endLines: 1 }],
88
+
89
+ 'unicorn/prefer-node-protocol': 'error',
90
+
91
+ '@typescript-eslint/no-explicit-any': 'error',
92
+ '@typescript-eslint/no-namespace': 'off',
93
+ '@typescript-eslint/restrict-template-expressions': [
94
+ 'error',
95
+ { allowNullish: true, allowBoolean: true, allowNumber: true },
96
+ ],
97
+ '@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
98
+ '@typescript-eslint/consistent-type-assertions': 'error',
99
+ '@typescript-eslint/explicit-function-return-type': 'error',
100
+ '@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'explicit' }],
101
+ '@typescript-eslint/member-ordering': 'error',
102
+ '@typescript-eslint/no-shadow': 'error',
103
+ '@typescript-eslint/return-await': 'error',
104
+ '@typescript-eslint/prefer-for-of': 'error',
105
+ '@typescript-eslint/prefer-function-type': 'error',
106
+ '@typescript-eslint/prefer-includes': 'error',
107
+ '@typescript-eslint/prefer-nullish-coalescing': 'error',
108
+ '@typescript-eslint/prefer-optional-chain': 'error',
109
+ '@typescript-eslint/prefer-reduce-type-parameter': 'error',
110
+ '@typescript-eslint/prefer-string-starts-ends-with': 'error',
111
+ '@typescript-eslint/switch-exhaustiveness-check': 'error',
112
+ '@typescript-eslint/unified-signatures': 'error',
113
+
114
+ 'header/header': [
115
+ 2,
116
+ 'block',
117
+ [
118
+ '',
119
+ {
120
+ pattern: ' \\* Copyright \\d{4}, Salesforce, Inc\\.',
121
+ template: ' * Copyright 2025, Salesforce, Inc.',
122
+ },
123
+ ' *',
124
+ ' * Licensed under the Apache License, Version 2.0 (the "License");',
125
+ ' * you may not use this file except in compliance with the License.',
126
+ ' * You may obtain a copy of the License at',
127
+ ' *',
128
+ ' * http://www.apache.org/licenses/LICENSE-2.0',
129
+ ' *',
130
+ ' * Unless required by applicable law or agreed to in writing, software',
131
+ ' * distributed under the License is distributed on an "AS IS" BASIS,',
132
+ ' * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.',
133
+ ' * See the License for the specific language governing permissions and',
134
+ ' * limitations under the License.',
135
+ ' ',
136
+ ],
137
+ ],
138
+ },
139
+ },
140
+ {
141
+ files: ['src/**/*.ts'],
142
+ rules: {
143
+ '@typescript-eslint/restrict-template-expressions': [
144
+ 'error',
145
+ { allowNullish: false, allowBoolean: true, allowNumber: true },
146
+ ],
147
+ },
148
+ },
149
+ {
150
+ files: ['test/**/*.ts'],
151
+ rules: {
152
+ 'no-unused-expressions': 'off',
153
+ '@typescript-eslint/no-unused-expressions': 'off',
154
+ '@typescript-eslint/explicit-function-return-type': 'off',
155
+ '@typescript-eslint/no-empty-function': 'off',
156
+ '@typescript-eslint/no-unsafe-function-type': 'off',
157
+ '@typescript-eslint/no-unsafe-assignment': 'off',
158
+ '@typescript-eslint/require-await': 'off',
159
+ },
160
+ },
161
+ eslintConfigPrettier
162
+ );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-config-salesforce-typescript",
3
- "version": "4.0.1",
4
- "description": "The eslint config for Salesforce typescript projects",
3
+ "version": "6.0.1",
4
+ "description": "The eslint flat config for Salesforce typescript projects",
5
5
  "keywords": [
6
6
  "Salesforce",
7
7
  "eslint",
@@ -10,36 +10,41 @@
10
10
  "author": "Salesforce",
11
11
  "homepage": "https://github.com/forcedotcom/eslint-config-salesforce-typescript#readme",
12
12
  "license": "Apache-2.0",
13
- "main": "index.js",
13
+ "type": "module",
14
+ "exports": {
15
+ ".": "./index.mjs",
16
+ "./package.json": "./package.json"
17
+ },
14
18
  "files": [
15
- "/index.js"
19
+ "index.mjs"
16
20
  ],
17
21
  "repository": "forcedotcom/eslint-config-salesforce-typescript",
18
22
  "bugs": {
19
23
  "url": "https://github.com/forcedotcom/eslint-config-salesforce-typescript/issues"
20
24
  },
21
- "devDependencies": {
22
- "@salesforce/prettier-config": "^0.0.3",
23
- "prettier": "^3.3.3",
24
- "typescript": "^5.4.5"
25
- },
26
25
  "publishConfig": {
27
26
  "access": "public"
28
27
  },
29
28
  "scripts": {
30
- "test": "eslint -c index.js",
31
- "build": "echo 'no build necessary'"
29
+ "build": "echo 'no build necessary'",
30
+ "test": "node --input-type=module -e \"import config from './index.mjs'; assert(Array.isArray(config), 'expected array'); console.log('ok:', config.length, 'config entries');\""
32
31
  },
33
32
  "dependencies": {
34
- "@typescript-eslint/eslint-plugin": "^6.21.0",
35
- "@typescript-eslint/parser": "^6.21.0",
36
- "eslint": "^8.56.0",
37
- "eslint-config-prettier": "^9.1.0",
38
- "eslint-config-salesforce": "^2.2.0",
39
- "eslint-config-salesforce-license": "^1.0.2",
40
- "eslint-plugin-header": "^3.1.1",
41
- "eslint-plugin-import": "^2.29.1",
42
- "eslint-plugin-jsdoc": "^46.10.1",
43
- "eslint-plugin-unicorn": "^50.0.1"
33
+ "@eslint/js": "^10.0.0",
34
+ "@tony.ganchev/eslint-plugin-header": "^3.4.4",
35
+ "eslint-config-prettier": "^10.1.5",
36
+ "eslint-plugin-import-x": "^4.17.1",
37
+ "eslint-plugin-jsdoc": "^63.3.2",
38
+ "eslint-plugin-unicorn": "^72.0.0",
39
+ "globals": "^15.14.0",
40
+ "typescript-eslint": "^8.66.0"
41
+ },
42
+ "peerDependencies": {
43
+ "eslint": "^10.0.0",
44
+ "typescript": "^6"
45
+ },
46
+ "devDependencies": {
47
+ "eslint": "^10.4.0",
48
+ "typescript": "^6.0.3"
44
49
  }
45
50
  }
package/index.js DELETED
@@ -1,122 +0,0 @@
1
- module.exports = {
2
- env: {
3
- es6: true,
4
- },
5
- extends: [
6
- 'eslint-config-salesforce',
7
- 'plugin:@typescript-eslint/eslint-recommended',
8
- 'plugin:@typescript-eslint/recommended',
9
- 'plugin:@typescript-eslint/recommended-requiring-type-checking',
10
- 'eslint-config-prettier',
11
- ],
12
- parser: '@typescript-eslint/parser',
13
- parserOptions: {
14
- project: [
15
- './packages/**/tsconfig.json',
16
- './packages/**/test/tsconfig.json',
17
- './tsconfig.json',
18
- './test/tsconfig.json',
19
- ],
20
- sourceType: 'module',
21
- },
22
- plugins: ['@typescript-eslint', 'eslint-plugin-import', 'eslint-plugin-jsdoc', 'unicorn'],
23
- rules: {
24
- 'unicorn/prefer-node-protocol': 'error',
25
- 'unicorn/numeric-separators-style': 'warn',
26
- // turn the rule off everywhere. Then, in overrides, turn it on for just src
27
- 'import/no-extraneous-dependencies': ['off'],
28
-
29
- // Override @typescript-eslint/recommended
30
- '@typescript-eslint/no-explicit-any': 'error',
31
- '@typescript-eslint/no-namespace': 'off',
32
- '@typescript-eslint/restrict-template-expressions': [
33
- 'error',
34
- {
35
- // true generally (so we get it in /test), we override it to false for src lower down
36
- allowNullish: true,
37
- allowBoolean: true,
38
- allowNumber: true,
39
- },
40
- ],
41
-
42
- // Custom @typescript-eslint
43
- '@typescript-eslint/array-type': [
44
- 'error',
45
- {
46
- default: 'array-simple',
47
- },
48
- ],
49
- '@typescript-eslint/consistent-type-assertions': 'error',
50
- '@typescript-eslint/consistent-type-definitions': ['warn', 'type'],
51
- '@typescript-eslint/explicit-function-return-type': 'error',
52
- '@typescript-eslint/explicit-member-accessibility': [
53
- 'error',
54
- {
55
- accessibility: 'explicit',
56
- },
57
- ],
58
- '@typescript-eslint/member-delimiter-style': [
59
- 'error',
60
- {
61
- multiline: {
62
- delimiter: 'semi',
63
- requireLast: true,
64
- },
65
- singleline: {
66
- delimiter: 'semi',
67
- requireLast: false,
68
- },
69
- },
70
- ],
71
- '@typescript-eslint/member-ordering': 'error',
72
- '@typescript-eslint/no-shadow': 'error',
73
- '@typescript-eslint/return-await': 'error',
74
- // turning off the base rule is recommended by ts-eslint
75
- 'no-return-await': 'off',
76
- '@typescript-eslint/prefer-for-of': 'error',
77
- '@typescript-eslint/prefer-function-type': 'error',
78
- '@typescript-eslint/prefer-includes': 'error',
79
- '@typescript-eslint/prefer-nullish-coalescing': 'error',
80
- '@typescript-eslint/prefer-optional-chain': 'error',
81
- '@typescript-eslint/prefer-reduce-type-parameter': 'error',
82
- '@typescript-eslint/prefer-string-starts-ends-with': 'error',
83
- '@typescript-eslint/quotes': [
84
- 'error',
85
- 'single',
86
- {
87
- avoidEscape: true,
88
- },
89
- ],
90
- '@typescript-eslint/switch-exhaustiveness-check': 'error',
91
- '@typescript-eslint/type-annotation-spacing': 'error',
92
- '@typescript-eslint/unified-signatures': 'error',
93
- 'no-shadow': 'off',
94
- },
95
- ignorePatterns: ['*.js'],
96
- overrides: [
97
- {
98
- // put stricter rules you only want to apply to production code here
99
- files: ['src/**'],
100
- rules: {
101
- '@typescript-eslint/restrict-template-expressions': [
102
- 'error',
103
- {
104
- allowNullish: false,
105
- allowBoolean: true,
106
- allowNumber: true,
107
- },
108
- ],
109
- 'import/no-extraneous-dependencies': [
110
- 'error',
111
- {
112
- includeTypes: false,
113
- devDependencies: false,
114
- peerDependencies: false,
115
- bundledDependencies: false,
116
- optionalDependencies: false,
117
- },
118
- ],
119
- },
120
- },
121
- ],
122
- };