@w5s/eslint-config 3.28.0 → 3.30.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/eslint-config",
3
- "version": "3.28.0",
3
+ "version": "3.30.0",
4
4
  "description": "ESLint configuration presets",
5
5
  "keywords": [
6
6
  "eslint",
@@ -46,9 +46,9 @@
46
46
  "@typescript-eslint/eslint-plugin": "^8.0.0",
47
47
  "@typescript-eslint/parser": "^8.0.0",
48
48
  "@vitest/eslint-plugin": "~1.6.20",
49
- "@w5s/dev": "^3.19.0",
50
- "@w5s/eslint-config-ignore": "^1.18.0",
51
- "@w5s/prettier-config": "^3.13.0",
49
+ "@w5s/dev": "^3.21.0",
50
+ "@w5s/eslint-config-ignore": "^1.20.0",
51
+ "@w5s/prettier-config": "^3.15.0",
52
52
  "eslint-merge-processors": "^2.0.0",
53
53
  "eslint-plugin-import": "~2.32.0",
54
54
  "eslint-plugin-jsdoc": "~64.1.0",
@@ -85,5 +85,5 @@
85
85
  "publishConfig": {
86
86
  "access": "public"
87
87
  },
88
- "gitHead": "86fbbb9dc5e541529173a897bda1c0aa3efa0ec1"
88
+ "gitHead": "33447bdc0ec90e7ac57633399553002a2bc77b6b"
89
89
  }
@@ -1,17 +1,18 @@
1
- import { ESLintConfig, interopDefault, Project } from '@w5s/dev';
1
+ import { interopDefault, Project } from '@w5s/dev';
2
2
  import { mergeProcessors, processorPassThrough } from 'eslint-merge-processors';
3
3
 
4
4
  import type { RuleOptions } from '../typegen/markdown.js';
5
5
 
6
+ import { sourceGlob } from '../glob.js';
6
7
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
8
+ import { looseRules } from '../rules/looseRules.js';
7
9
  import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
8
10
 
9
11
  const defaultFiles = [`**/${Project.extensionsToGlob(Project.queryExtensions(['markdown']))}`];
10
12
 
11
13
  export async function markdown(options: markdown.Options = {}) {
12
- const [markdownPlugin, tsPlugin] = await Promise.all([
14
+ const [markdownPlugin] = await Promise.all([
13
15
  interopDefault(import('@eslint/markdown')),
14
- interopDefault(import('@typescript-eslint/eslint-plugin')),
15
16
  ] as const);
16
17
  const {
17
18
  files,
@@ -48,18 +49,36 @@ export async function markdown(options: markdown.Options = {}) {
48
49
  },
49
50
  },
50
51
  {
51
- files: resolvedFiles.map((f) => `${f}/**/*`),
52
+ files: resolvedFiles.map((f) => `${f}/${sourceGlob}`),
52
53
  languageOptions: {
53
54
  parserOptions: {
54
55
  project: false,
55
56
  projectService: false,
56
57
  },
57
58
  },
58
- name: 'w5s/markdown/embed',
59
- // eslint-disable-next-line ts/no-non-null-assertion
60
- rules: ESLintConfig.renameRules(tsPlugin.configs['disable-type-checked']!.rules as any, {
61
- '@typescript-eslint': 'ts',
62
- }),
59
+ name: 'w5s/markdown/embed-code',
60
+ rules: {
61
+ ...looseRules(),
62
+ 'no-alert': 'off',
63
+ 'no-console': 'off',
64
+ 'no-labels': 'off',
65
+ 'no-lone-blocks': 'off',
66
+ 'no-restricted-syntax': 'off',
67
+ 'no-undef': 'off',
68
+ 'no-unused-expressions': 'off',
69
+ 'no-unused-labels': 'off',
70
+ 'no-unused-vars': 'off',
71
+ 'node/prefer-global/process': 'off',
72
+ 'style/eol-last': 'off',
73
+ 'ts/consistent-type-imports': 'off',
74
+ 'ts/no-redeclare': 'off',
75
+ 'ts/no-require-imports': 'off',
76
+ 'ts/no-unused-expressions': 'off',
77
+ 'ts/no-unused-vars': 'off',
78
+ 'unicode-bom': 'off',
79
+ 'unused-imports/no-unused-imports': 'off',
80
+ 'unused-imports/no-unused-vars': 'off',
81
+ },
63
82
  },
64
83
  ] as [Config, Config, Config] satisfies Array<Config>;
65
84
  }
@@ -3,15 +3,15 @@ import { ESLintConfig, interopDefault, Project } from '@w5s/dev';
3
3
  import type { RuleOptions } from '../typegen/test.js';
4
4
 
5
5
  import { withDefaultFiles } from '../internal/withDefaultFiles.js';
6
+ import { looseRules } from '../rules/looseRules.js';
6
7
  import { type Config, type PluginOptionsBase, StylisticConfig } from '../type.js';
7
8
 
8
9
  const defaultFiles = Project.extensionsToTestGlob(Project.sourceExtensions());
9
10
 
10
11
  export async function test(options: test.Options = {}) {
11
- const [vitestPlugin, tsPlugin] = await Promise.all([
12
+ const [vitestPlugin] = await Promise.all(([
12
13
  interopDefault(import('@vitest/eslint-plugin')),
13
- interopDefault(import('@typescript-eslint/eslint-plugin')),
14
- ] as const);
14
+ ]) as const);
15
15
  const { files, recommended = true, rules = {}, stylistic = true } = options;
16
16
  const { enabled: stylisticEnabled } = StylisticConfig.from(stylistic);
17
17
 
@@ -31,28 +31,11 @@ export async function test(options: test.Options = {}) {
31
31
  ...ESLintConfig.renameRules(vitestPlugin.configs.recommended.rules, {
32
32
  vitest: 'test',
33
33
  }),
34
- // Loose rules
35
- 'e18e/prefer-static-regex': 'off',
34
+ ...looseRules(),
35
+
36
36
  // Improve some rules
37
37
  'test/expect-expect': ['error', { assertFunctionNames: ['expect*', 'assert*'] }],
38
38
  'test/valid-title': ESLintConfig.fixme(undefined),
39
- // Loose typing
40
- // eslint-disable-next-line ts/no-non-null-assertion
41
- ...ESLintConfig.renameRules(tsPlugin.configs['disable-type-checked']!.rules as any, {
42
- '@typescript-eslint': 'ts',
43
- }),
44
-
45
- 'ts/explicit-module-boundary-types': 'off',
46
- 'ts/no-empty-function': 'off',
47
- 'ts/no-explicit-any': 'off',
48
- 'ts/no-non-null-assertion': 'off',
49
- 'ts/no-unsafe-argument': 'off',
50
- 'ts/no-unsafe-assignment': 'off',
51
- 'ts/no-unsafe-call': 'off',
52
- 'ts/no-unsafe-member-access': 'off',
53
- 'ts/no-unsafe-return': 'off',
54
- 'ts/require-await': 'off',
55
- 'ts/unbound-method': 'off',
56
39
  }
57
40
  : {}),
58
41
  ...(stylisticEnabled
@@ -0,0 +1,12 @@
1
+ export function lazy<T>(fn: () => T): () => T {
2
+ let isSet = false;
3
+ let value: T | undefined;
4
+ return () => {
5
+ if (!isSet) {
6
+ value = fn();
7
+ isSet = true;
8
+ }
9
+ // eslint-disable-next-line ts/no-non-null-assertion
10
+ return value!;
11
+ };
12
+ }
@@ -94,5 +94,3 @@ export const esStylistic = () => ({
94
94
  // https://eslint.org/docs/rules/yield-star-spacing
95
95
  'yield-star-spacing': ['error', 'after'],
96
96
  } satisfies Linter.RulesRecord);
97
-
98
- export default esStylistic;
@@ -1,11 +1,12 @@
1
- import { bestPractices } from './esRules/bestPractices.js';
2
- import { errors } from './esRules/errors.js';
3
- import { es6 } from './esRules/es6.js';
4
- import { overrides } from './esRules/overrides.js';
5
- import { strict } from './esRules/strict.js';
6
- import { variables } from './esRules/variables.js';
1
+ import { lazy } from '../internal/lazy.js';
2
+ import { bestPractices } from './airbnb-base/bestPractices.js';
3
+ import { errors } from './airbnb-base/errors.js';
4
+ import { es6 } from './airbnb-base/es6.js';
5
+ import { overrides } from './airbnb-base/overrides.js';
6
+ import { strict } from './airbnb-base/strict.js';
7
+ import { variables } from './airbnb-base/variables.js';
7
8
 
8
- export const esRules = () => ({
9
+ export const esRules = lazy(() => ({
9
10
  ...bestPractices(),
10
11
  ...errors(),
11
12
  ...es6(),
@@ -14,4 +15,4 @@ export const esRules = () => ({
14
15
 
15
16
  // Must be last
16
17
  ...overrides(),
17
- });
18
+ }));
@@ -0,0 +1,29 @@
1
+ import tsPlugin from '@typescript-eslint/eslint-plugin';
2
+ import { ESLintConfig } from '@w5s/dev';
3
+
4
+ import { lazy } from '../internal/lazy.js';
5
+
6
+ export const looseRules = lazy(() => {
7
+ // eslint-disable-next-line ts/no-non-null-assertion
8
+ return Object.assign(ESLintConfig.renameRules(tsPlugin.configs['disable-type-checked']!.rules as any, {
9
+ '@typescript-eslint': 'ts',
10
+ }), {
11
+ // Loose rules
12
+ 'e18e/prefer-static-regex': 'off',
13
+ // TypeScript loose rules
14
+ 'ts/explicit-function-return-type': 'off',
15
+ 'ts/explicit-module-boundary-types': 'off',
16
+ 'ts/no-empty-function': 'off',
17
+ 'ts/no-explicit-any': 'off',
18
+ 'ts/no-namespace': 'off',
19
+ 'ts/no-non-null-assertion': 'off',
20
+ 'ts/no-unsafe-argument': 'off',
21
+ 'ts/no-unsafe-assignment': 'off',
22
+ 'ts/no-unsafe-call': 'off',
23
+ 'ts/no-unsafe-member-access': 'off',
24
+ 'ts/no-unsafe-return': 'off',
25
+ 'ts/no-use-before-define': 'off',
26
+ 'ts/require-await': 'off',
27
+ 'ts/unbound-method': 'off',
28
+ });
29
+ });
@@ -1,8 +1,9 @@
1
1
  import { ESLintConfig } from '@w5s/dev';
2
2
 
3
+ import { lazy } from '../internal/lazy.js';
3
4
  import { esRules } from './esRules.js';
4
5
 
5
- export const tsRules = () => {
6
+ export const tsRules = lazy(() => {
6
7
  const baseRules = esRules();
7
8
 
8
9
  return ESLintConfig.renameRules(
@@ -32,6 +33,7 @@ export const tsRules = () => {
32
33
  '@typescript-eslint/no-loss-of-precision': baseRules['no-loss-of-precision'],
33
34
  '@typescript-eslint/no-magic-numbers': baseRules['no-magic-numbers'],
34
35
  '@typescript-eslint/no-misused-new': 'error',
36
+ '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: false }],
35
37
  '@typescript-eslint/no-namespace': 'off', // We don't agree with community, namespaces are great and not deprecated
36
38
  '@typescript-eslint/no-non-null-assertion': 'error',
37
39
  '@typescript-eslint/no-redeclare': ESLintConfig.fixme(baseRules['no-redeclare']),
@@ -68,4 +70,4 @@ export const tsRules = () => {
68
70
  '@typescript-eslint': 'ts',
69
71
  },
70
72
  );
71
- };
73
+ });
File without changes
File without changes
File without changes
File without changes
File without changes