@1stg/eslint-config 8.0.0 → 8.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 8.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`db3b78b`](https://github.com/1stG/configs/commit/db3b78b29159200362727141931016fcd6a85846)]:
8
+ - @1stg/config@1.0.0
9
+
3
10
  ## 8.0.0
4
11
 
5
12
  ### Major Changes
package/_util.js CHANGED
@@ -1,15 +1,25 @@
1
- const path = require('node:path')
1
+ // @ts-check
2
2
 
3
- const { preferPrettier } = require('@1stg/config')
4
- const {
3
+ import path from 'node:path'
4
+
5
+ import { preferPrettier } from '@1stg/config'
6
+ import {
5
7
  isMonorepo,
6
8
  isPkgAvailable,
7
9
  getMonorepoPkgs,
8
10
  tryRequirePkg,
9
- } = require('@pkgr/utils')
11
+ } from '@pkgr/utils'
12
+ import configPrettier from 'eslint-config-prettier'
13
+ import prettierRecommended from 'eslint-plugin-prettier/recommended'
14
+ import tseslint from 'typescript-eslint'
15
+
16
+ /**
17
+ * @type {string[]}
18
+ */
19
+ let allowModules = []
10
20
 
11
21
  if (isMonorepo()) {
12
- exports.allowModules = getMonorepoPkgs().reduce((acc, pkg) => {
22
+ allowModules = getMonorepoPkgs().reduce((acc, pkg) => {
13
23
  const pkgJson = tryRequirePkg(path.resolve(pkg, 'package.json'))
14
24
  if (!pkgJson) {
15
25
  return acc
@@ -21,15 +31,16 @@ if (isMonorepo()) {
21
31
  Object.keys(peerDependencies),
22
32
  Object.keys(dependencies),
23
33
  )
24
- }, [])
34
+ }, /** @type {string[]} */ ([]))
25
35
  }
26
36
 
27
- exports.isTsAvailable = isPkgAvailable('typescript')
37
+ export { allowModules }
38
+
39
+ export const isTsAvailable = isPkgAvailable('typescript')
28
40
 
29
- exports.isWebpackAvailable = isPkgAvailable('webpack')
41
+ export const isWebpackAvailable = isPkgAvailable('webpack')
30
42
 
31
- // https://webpack.js.org/api/module-variables/#__resourcequery-webpack-specific
32
- exports.webpackSpecVars = [
43
+ export const webpackSpecVars = [
33
44
  '__non_webpack_require__',
34
45
  '__resourceQuery',
35
46
  '__webpack_chunk_load__',
@@ -42,11 +53,11 @@ exports.webpackSpecVars = [
42
53
  'DEBUG',
43
54
  ]
44
55
 
45
- exports.magicNumbers = [
56
+ export const magicNumbers = [
46
57
  -1, 0, 1, 2, 3, 5, 7, 10, 12, 15, 20, 24, 30, 31, 50, 60, 100, 365, 366, 500,
47
58
  768, 1000, 1024, 3600, 4200, 8080,
48
59
  ]
49
60
 
50
- exports.prettierExtends = preferPrettier
51
- ? ['prettier']
52
- : ['plugin:prettier/recommended']
61
+ export const prettierExtends = tseslint.config(
62
+ preferPrettier ? configPrettier : prettierRecommended,
63
+ )
package/base.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { TSESLint } from '@typescript-eslint/utils'
2
+
3
+ export const base: TSESLint.FlatConfig.ConfigArray
package/base.js CHANGED
@@ -1,123 +1,174 @@
1
- const { isPkgAvailable } = require('@pkgr/utils')
2
- const { getGlobals } = require('eslint-plugin-mdx')
1
+ // @ts-check
3
2
 
4
- const {
3
+ import eslint from '@eslint/js'
4
+ import eslintCommentsConfigs from '@eslint-community/eslint-plugin-eslint-comments/configs'
5
+ import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'
6
+ import css from 'eslint-plugin-css'
7
+ import importX from 'eslint-plugin-import-x'
8
+ import { getGlobals } from 'eslint-plugin-mdx'
9
+ import n from 'eslint-plugin-n'
10
+ import promise from 'eslint-plugin-promise'
11
+ import regexp from 'eslint-plugin-regexp'
12
+ import simpleImportSort from 'eslint-plugin-simple-import-sort'
13
+ import sonarjs from 'eslint-plugin-sonarjs'
14
+ import unicorn from 'eslint-plugin-unicorn'
15
+ import globals from 'globals'
16
+ import tseslint from 'typescript-eslint'
17
+
18
+ import {
5
19
  isTsAvailable,
6
20
  isWebpackAvailable,
7
21
  magicNumbers,
8
22
  webpackSpecVars,
9
23
  prettierExtends,
10
- } = require('./_util')
24
+ } from './_util.js'
11
25
 
12
- module.exports = {
13
- extends: [
14
- 'eslint:recommended',
15
- 'plugin:@eslint-community/eslint-comments/recommended',
16
- 'plugin:css/recommended',
17
- 'plugin:import/recommended',
18
- 'plugin:n/recommended',
19
- 'plugin:promise/recommended',
20
- 'plugin:regexp/recommended',
21
- 'plugin:sonarjs/recommended',
22
- isPkgAvailable('typescript') && 'plugin:sonar/recommended',
23
- 'plugin:unicorn/recommended',
24
- 'standard',
25
- ...prettierExtends,
26
- ].filter(Boolean),
27
- plugins: ['es-x', 'simple-import-sort'],
28
- globals: isWebpackAvailable ? getGlobals(webpackSpecVars) : undefined,
29
- rules: {
30
- '@eslint-community/eslint-comments/disable-enable-pair': [
31
- 2,
32
- {
33
- allowWholeFile: true,
34
- },
35
- ],
36
- '@eslint-community/eslint-comments/no-unused-disable': 2,
37
- 'arrow-body-style': 2,
38
- camelcase: [
39
- 2,
40
- {
41
- properties: 'never',
42
- ignoreDestructuring: true,
43
- allow: isWebpackAvailable ? webpackSpecVars : undefined,
26
+ export const base = tseslint.config([
27
+ eslint.configs.recommended,
28
+ eslintCommentsConfigs.recommended,
29
+ css.configs['flat/recommended'],
30
+ importX.flatConfigs.recommended,
31
+ n.configs['flat/recommended'],
32
+ promise.configs['flat/recommended'],
33
+ regexp.configs['flat/recommended'],
34
+ sonarjs.configs.recommended,
35
+ unicorn.configs.recommended,
36
+ prettierExtends,
37
+ {
38
+ name: '@1stg/base',
39
+ plugins: {
40
+ 'simple-import-sort': simpleImportSort,
41
+ },
42
+ settings: {
43
+ 'import-x/external-module-folders': [
44
+ 'node_modules',
45
+ 'node_modules/@d-ts',
46
+ 'node_modules/@types',
47
+ ],
48
+ 'import-x/resolver-next': [createTypeScriptImportResolver()],
49
+ },
50
+ languageOptions: {
51
+ sourceType: 'module',
52
+ ecmaVersion: 'latest',
53
+ globals: {
54
+ ...globals.builtin,
55
+ ...(isWebpackAvailable && getGlobals(webpackSpecVars)),
44
56
  },
45
- ],
46
- curly: [2, 'all'],
47
- 'import/first': 2,
48
- 'import/newline-after-import': 2,
49
- 'import/no-duplicates': 2,
50
- 'import/order': [
51
- 2,
52
- {
53
- alphabetize: {
54
- order: 'asc',
57
+ },
58
+ rules: {
59
+ '@eslint-community/eslint-comments/disable-enable-pair': [
60
+ 2,
61
+ {
62
+ allowWholeFile: true,
55
63
  },
56
- 'newlines-between': 'always',
57
- },
58
- ],
59
- 'no-else-return': [
60
- 2,
61
- {
62
- allowElseIf: false,
63
- },
64
- ],
65
- 'no-empty': [
66
- 2,
67
- {
68
- allowEmptyCatch: true,
69
- },
70
- ],
71
- 'no-empty-function': 2,
72
- 'no-labels': isTsAvailable ? 0 : 2, // sonar/no-labels
73
- 'no-magic-numbers': [
74
- 2,
75
- {
76
- enforceConst: true,
77
- ignore: magicNumbers,
78
- ignoreArrayIndexes: true,
79
- },
80
- ],
81
- 'no-negated-condition': 2,
82
- 'no-process-exit': 0, // suspended by unicorn/no-process-exit
64
+ ],
65
+ '@eslint-community/eslint-comments/no-unused-disable': 2,
66
+ 'arrow-body-style': 2,
67
+ camelcase: [
68
+ 2,
69
+ {
70
+ properties: 'never',
71
+ ignoreDestructuring: true,
72
+ allow: isWebpackAvailable ? webpackSpecVars : undefined,
73
+ },
74
+ ],
75
+ curly: [2, 'all'],
76
+ 'import-x/first': 2,
77
+ 'import-x/newline-after-import': 2,
78
+ 'import-x/no-duplicates': 2,
79
+ 'import-x/order': [
80
+ 2,
81
+ {
82
+ alphabetize: {
83
+ order: 'asc',
84
+ },
85
+ 'newlines-between': 'always',
86
+ },
87
+ ],
88
+ 'no-else-return': [
89
+ 2,
90
+ {
91
+ allowElseIf: false,
92
+ },
93
+ ],
94
+ 'no-empty': [
95
+ 2,
96
+ {
97
+ allowEmptyCatch: true,
98
+ },
99
+ ],
100
+ 'no-empty-function': 2,
101
+ 'no-labels': isTsAvailable ? 0 : 2, // sonar/no-labels
102
+ 'no-magic-numbers': [
103
+ 2,
104
+ {
105
+ enforceConst: true,
106
+ ignore: magicNumbers,
107
+ ignoreArrayIndexes: true,
108
+ },
109
+ ],
110
+ 'no-negated-condition': 2,
111
+ 'no-process-exit': 0, // suspended by unicorn/no-process-exit
83
112
 
84
- // The following rules are duplicate with `eslint-plugin-import`
85
- 'n/no-extraneous-import': 0,
86
- 'n/no-extraneous-require': 0,
87
- 'n/no-missing-import': 0,
88
- 'n/no-missing-require': 0,
113
+ // The following rules are duplicate with `eslint-plugin-import`
114
+ 'n/no-extraneous-import': 0,
115
+ 'n/no-extraneous-require': 0,
116
+ 'n/no-missing-import': 0,
117
+ 'n/no-missing-require': 0,
89
118
 
90
- 'n/no-unsupported-features/es-syntax': 0,
91
- 'n/no-unsupported-features/node-builtins': 0,
92
- 'n/no-unpublished-import': 0,
93
- 'n/no-unpublished-require': 0,
94
- 'prefer-const': 2,
95
- 'prefer-object-spread': 2,
96
- 'simple-import-sort/exports': 2,
97
- 'unicorn/catch-error-name': [
98
- 2,
99
- {
100
- name: 'error',
101
- ignore: ['^e(rr)?$'],
102
- },
103
- ],
104
- 'unicorn/consistent-function-scoping': 0,
105
- 'unicorn/filename-case': [
106
- 2,
107
- {
108
- cases: {
109
- kebabCase: true,
110
- pascalCase: true,
119
+ 'n/no-unsupported-features/es-syntax': 0,
120
+ 'n/no-unsupported-features/node-builtins': 0,
121
+ 'n/no-unpublished-import': 0,
122
+ 'n/no-unpublished-require': 0,
123
+ 'prefer-const': 2,
124
+ 'prefer-object-spread': 2,
125
+ 'simple-import-sort/exports': 2,
126
+ 'unicorn/catch-error-name': [
127
+ 2,
128
+ {
129
+ name: 'error',
130
+ ignore: ['^e(rr)?$'],
111
131
  },
112
- // ignore UPPER_CASE markdown or yaml filenames
113
- ignore: [/^[A-Z](([\dA-Z]+_)*[\dA-Z]+)?\.(mdx?|ya?ml)$/],
114
- },
132
+ ],
133
+ 'unicorn/consistent-function-scoping': 0,
134
+ 'unicorn/filename-case': [
135
+ 2,
136
+ {
137
+ cases: {
138
+ kebabCase: true,
139
+ pascalCase: true,
140
+ },
141
+ // ignore UPPER_CASE markdown or yaml filenames
142
+ ignore: [/^[A-Z](([\dA-Z]+_)*[\dA-Z]+)?\.(mdx?|ya?ml)$/],
143
+ },
144
+ ],
145
+ 'unicorn/no-array-reduce': 0,
146
+ 'unicorn/no-null': 0,
147
+ 'unicorn/no-unreadable-array-destructuring': 0, // conflict with `no-unused-vars`
148
+ 'unicorn/prefer-module': 0,
149
+ 'unicorn/prefer-object-from-entries': 0,
150
+ 'unicorn/prevent-abbreviations': 0,
151
+ },
152
+ },
153
+ {
154
+ ignores: [
155
+ '**/*.less',
156
+ '**/*.log',
157
+ '**/*.patch',
158
+ '**/*.sass',
159
+ '**/*.scss',
160
+ '**/.type-coverage',
161
+ '**/coverage',
162
+ '**/dist',
163
+ '**/lib',
164
+ '**/node_modules',
165
+ '**/CHANGELOG.md',
166
+ '**/yarn.lock',
167
+ '**/package-lock.json',
168
+ '**/pnpm-lock.yaml',
169
+ '**/.yarn',
170
+ '!.github',
171
+ '!.*.{cjs,js,mjs,cts,ts,mts}',
115
172
  ],
116
- 'unicorn/no-array-reduce': 0,
117
- 'unicorn/no-null': 0,
118
- 'unicorn/no-unreadable-array-destructuring': 0, // conflict with `no-unused-vars`
119
- 'unicorn/prefer-module': 0,
120
- 'unicorn/prefer-object-from-entries': 0,
121
- 'unicorn/prevent-abbreviations': 0,
122
173
  },
123
- }
174
+ ])
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { recommended as default } from './recommended.js'
package/index.js CHANGED
@@ -1,6 +1 @@
1
- const { overrides } = require('./overrides')
2
-
3
- module.exports = {
4
- extends: require.resolve('./base'),
5
- overrides,
6
- }
1
+ export { recommended as default } from './recommended.js'
package/loose.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { TSESLint } from '@typescript-eslint/utils'
2
+
3
+ export const loose: TSESLint.FlatConfig.ConfigArray
package/loose.js CHANGED
@@ -1,31 +1,39 @@
1
- module.exports = {
2
- extends: ['@1stg'],
3
- rules: {
4
- '@angular-eslint/template/no-negated-async': 0,
5
- '@typescript-eslint/member-ordering': 0,
6
- '@typescript-eslint/naming-convention': 0,
7
- '@typescript-eslint/no-explicit-any': 0,
8
- '@typescript-eslint/no-floating-promises': 0,
9
- '@typescript-eslint/no-magic-numbers': 0,
10
- '@typescript-eslint/no-type-alias': 0,
11
- '@typescript-eslint/no-unnecessary-condition': 0,
12
- '@typescript-eslint/no-unsafe-assignment': 0,
13
- '@typescript-eslint/no-unsafe-member-access': 0,
14
- '@typescript-eslint/no-unsafe-return': 0,
15
- '@typescript-eslint/prefer-ts-expect-error': 0,
16
- '@typescript-eslint/restrict-plus-operands': 0,
17
- '@typescript-eslint/sort-type-union-intersection-members': 0,
18
- '@typescript-eslint/unbound-method': 0,
19
- 'accessor-pairs': 0,
20
- 'no-magic-numbers': 0,
21
- 'no-negated-condition': 0, // not auto-fixable
22
- 'promise/always-return': 0,
23
- 'promise/catch-or-return': 0,
24
- 'unicorn/explicit-length-check': 0,
25
- 'unicorn/no-array-for-each': 0,
26
- 'unicorn/no-fn-reference-in-iterator': 0,
27
- 'unicorn/prefer-number-properties': 0,
28
- 'unicorn/prefer-prototype-methods': 0,
29
- 'unicorn/prefer-spread': 0,
1
+ // @ts-check
2
+
3
+ import tseslint from 'typescript-eslint'
4
+
5
+ import { recommended } from './recommended.js'
6
+
7
+ export const loose = tseslint.config([
8
+ recommended,
9
+ {
10
+ rules: {
11
+ '@angular-eslint/template/no-negated-async': 0,
12
+ '@typescript-eslint/member-ordering': 0,
13
+ '@typescript-eslint/naming-convention': 0,
14
+ '@typescript-eslint/no-explicit-any': 0,
15
+ '@typescript-eslint/no-floating-promises': 0,
16
+ '@typescript-eslint/no-magic-numbers': 0,
17
+ '@typescript-eslint/no-type-alias': 0,
18
+ '@typescript-eslint/no-unnecessary-condition': 0,
19
+ '@typescript-eslint/no-unsafe-assignment': 0,
20
+ '@typescript-eslint/no-unsafe-member-access': 0,
21
+ '@typescript-eslint/no-unsafe-return': 0,
22
+ '@typescript-eslint/prefer-ts-expect-error': 0,
23
+ '@typescript-eslint/restrict-plus-operands': 0,
24
+ '@typescript-eslint/sort-type-union-intersection-members': 0,
25
+ '@typescript-eslint/unbound-method': 0,
26
+ 'accessor-pairs': 0,
27
+ 'no-magic-numbers': 0,
28
+ 'no-negated-condition': 0, // not auto-fixable
29
+ 'promise/always-return': 0,
30
+ 'promise/catch-or-return': 0,
31
+ 'unicorn/explicit-length-check': 0,
32
+ 'unicorn/no-array-for-each': 0,
33
+ 'unicorn/no-fn-reference-in-iterator': 0,
34
+ 'unicorn/prefer-number-properties': 0,
35
+ 'unicorn/prefer-prototype-methods': 0,
36
+ 'unicorn/prefer-spread': 0,
37
+ },
30
38
  },
31
- }
39
+ ])
package/overrides.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import type { TSESLint } from '@typescript-eslint/utils'
2
+
3
+ export const js: TSESLint.FlatConfig.ConfigArray
4
+ export const ts: TSESLint.FlatConfig.ConfigArray
5
+ export const dTs: TSESLint.FlatConfig.Config
6
+ export const react: TSESLint.FlatConfig.ConfigArray
7
+ export const vue: TSESLint.FlatConfig.ConfigArray
8
+ export const md: TSESLint.FlatConfig.ConfigArray
9
+ export const mdx: TSESLint.FlatConfig.ConfigArray
10
+ export const test: TSESLint.FlatConfig.Config
11
+ export const tests: TSESLint.FlatConfig.Config
12
+ export const jest: TSESLint.FlatConfig.ConfigArray
13
+ export const script: TSESLint.FlatConfig.Config
14
+ export const scripts: TSESLint.FlatConfig.Config
15
+ export const story: TSESLint.FlatConfig.Config
16
+ export const stories: TSESLint.FlatConfig.Config
17
+ export const config: TSESLint.FlatConfig.Config
18
+ export const configs: TSESLint.FlatConfig.Config
19
+ export const jsonc: TSESLint.FlatConfig.ConfigArray
20
+ export const json5: TSESLint.FlatConfig.ConfigArray
21
+ export const toml: TSESLint.FlatConfig.ConfigArray
22
+ export const yaml: TSESLint.FlatConfig.ConfigArray
23
+ export const yml: TSESLint.FlatConfig.ConfigArray
24
+ export const overrides: TSESLint.FlatConfig.ConfigArray