@o3r/eslint-config 14.0.0-next.0 → 14.0.0-next.10

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": "@o3r/eslint-config",
3
- "version": "14.0.0-next.0",
3
+ "version": "14.0.0-next.10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -37,7 +37,7 @@
37
37
  "build:builders": "tsc -b tsconfig.builders.json --pretty && yarn generate-cjs-manifest"
38
38
  },
39
39
  "dependencies": {
40
- "@o3r/schematics": "^14.0.0-next.0"
40
+ "@o3r/schematics": "~14.0.0-next.10"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "@angular-devkit/core": "^20.0.0",
@@ -46,10 +46,10 @@
46
46
  "@angular/compiler": "^20.0.0",
47
47
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
48
48
  "@eslint/js": "^8.57.0 || ^9.22.0",
49
- "@o3r/eslint-plugin": "^14.0.0-next.0",
50
- "@o3r/schematics": "^14.0.0-next.0",
49
+ "@o3r/eslint-plugin": "~14.0.0-next.10",
50
+ "@o3r/schematics": "~14.0.0-next.10",
51
51
  "@schematics/angular": "^20.0.0",
52
- "@stylistic/eslint-plugin": "~5.3.0",
52
+ "@stylistic/eslint-plugin": "~5.6.0",
53
53
  "@typescript-eslint/parser": "^8.15.0",
54
54
  "@typescript-eslint/types": "^8.15.0",
55
55
  "@typescript-eslint/utils": "^8.15.0",
@@ -60,62 +60,59 @@
60
60
  "eslint-plugin-import": "^2.31.0",
61
61
  "eslint-plugin-import-newlines": "^1.4.0",
62
62
  "eslint-plugin-jest": "^29.0.0",
63
- "eslint-plugin-jsdoc": "^54.0.0",
63
+ "eslint-plugin-jsdoc": "~61.5.0",
64
64
  "eslint-plugin-prefer-arrow": "^1.2.2",
65
- "eslint-plugin-unicorn": "^60.0.0",
65
+ "eslint-plugin-unicorn": "~62.0.0",
66
66
  "eslint-plugin-unused-imports": "^4.1.4",
67
67
  "globals": "^16.0.0",
68
68
  "globby": "^11.1.0",
69
- "jest": "^29.7.0",
69
+ "jest": "^29.0.0 || ^30.2.0",
70
70
  "jsonc-eslint-parser": "^2.4.0",
71
- "ts-node": "^10.9.2",
72
- "type-fest": "^4.30.1",
73
- "typescript": "^5.8.0",
71
+ "type-fest": "^5.3.1",
72
+ "typescript": "^5.9.0",
74
73
  "typescript-eslint": "^8.15.0",
75
74
  "yaml-eslint-parser": "^1.2.2"
76
75
  },
77
76
  "devDependencies": {
78
- "@angular-devkit/core": "~20.2.0",
79
- "@angular-devkit/schematics": "~20.2.0",
80
- "@angular/compiler": "~20.2.0",
77
+ "@angular-devkit/core": "~20.3.13",
78
+ "@angular-devkit/schematics": "~20.3.13",
79
+ "@angular/compiler": "~20.3.15",
81
80
  "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
82
- "@eslint/js": "~9.35.0",
83
- "@nx/eslint-plugin": "~21.5.0",
84
- "@o3r/build-helpers": "^14.0.0-next.0",
85
- "@o3r/eslint-plugin": "^14.0.0-next.0",
86
- "@o3r/test-helpers": "^14.0.0-next.0",
87
- "@schematics/angular": "~20.2.0",
88
- "@stylistic/eslint-plugin": "~5.3.0",
89
- "@types/jest": "~29.5.2",
90
- "@types/node": "^22.0.0",
91
- "@typescript-eslint/parser": "~8.43.0",
92
- "angular-eslint": "~20.2.0",
81
+ "@eslint/js": "~9.39.0",
82
+ "@nx/eslint-plugin": "~21.6.0",
83
+ "@o3r/build-helpers": "~14.0.0-next.10",
84
+ "@o3r/eslint-plugin": "~14.0.0-next.10",
85
+ "@o3r/test-helpers": "~14.0.0-next.10",
86
+ "@schematics/angular": "~20.3.13",
87
+ "@stylistic/eslint-plugin": "~5.6.0",
88
+ "@types/jest": "~30.0.0",
89
+ "@types/node": "~24.10.0",
90
+ "@typescript-eslint/parser": "~8.51.0",
91
+ "angular-eslint": "~20.6.0",
93
92
  "cpy-cli": "^6.0.0",
94
- "eslint": "~9.35.0",
93
+ "eslint": "~9.39.0",
95
94
  "eslint-import-resolver-node": "~0.3.9",
96
95
  "eslint-import-resolver-typescript": "~4.4.0",
97
96
  "eslint-plugin-import": "~2.32.0",
98
97
  "eslint-plugin-import-newlines": "~1.4.0",
99
- "eslint-plugin-jest": "~29.0.0",
100
- "eslint-plugin-jsdoc": "~54.7.0",
98
+ "eslint-plugin-jest": "~29.11.0",
99
+ "eslint-plugin-jsdoc": "~61.5.0",
101
100
  "eslint-plugin-prefer-arrow": "~1.2.3",
102
- "eslint-plugin-unicorn": "~60.0.0",
103
- "eslint-plugin-unused-imports": "~4.2.0",
101
+ "eslint-plugin-unicorn": "~62.0.0",
102
+ "eslint-plugin-unused-imports": "~4.3.0",
104
103
  "globals": "^16.0.0",
105
- "jest": "~29.7.0",
104
+ "jest": "~30.2.0",
106
105
  "jest-junit": "~16.0.0",
107
- "jest-util": "~29.7.0",
106
+ "jest-util": "~30.2.0",
108
107
  "jsonc-eslint-parser": "~2.4.0",
109
- "nx": "~21.5.0",
110
- "pid-from-port": "^1.1.3",
108
+ "nx": "~21.6.0",
111
109
  "rxjs": "^7.8.1",
112
110
  "semver": "^7.5.2",
113
111
  "ts-jest": "~29.4.0",
114
- "ts-node": "~10.9.2",
115
112
  "tslib": "^2.6.2",
116
- "type-fest": "^4.30.1",
113
+ "type-fest": "^5.3.1",
117
114
  "typescript": "~5.9.2",
118
- "typescript-eslint": "~8.43.0"
115
+ "typescript-eslint": "~8.51.0"
119
116
  },
120
117
  "peerDependenciesMeta": {
121
118
  "@angular-devkit/core": {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/eslint/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAQL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAsCpC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,EAAE,cAAc,MAAM,KAAG,IAyD3E,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../schematics/ng-add/eslint/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAOL,KAAK,IAAI,EAGV,MAAM,4BAA4B,CAAC;AAsEpC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,EAAE,cAAc,MAAM,KAAG,IAgE3E,CAAC"}
@@ -5,6 +5,11 @@ const path = require("node:path");
5
5
  const core_1 = require("@angular-devkit/core");
6
6
  const schematics_1 = require("@angular-devkit/schematics");
7
7
  const schematics_2 = require("@o3r/schematics");
8
+ /**
9
+ * Setup the lint task in the angular.json file
10
+ * @param projectName
11
+ * @param extension
12
+ */
8
13
  const editAngularJson = (projectName, extension) => (tree, context) => {
9
14
  let workspace = null;
10
15
  try {
@@ -24,13 +29,36 @@ const editAngularJson = (projectName, extension) => (tree, context) => {
24
29
  options: {
25
30
  eslintConfig: `${workspaceProject.root}/eslint.config.${extension}`,
26
31
  lintFilePatterns: [
27
- `${workspaceProject.sourceRoot || path.posix.join(workspaceProject.root, 'src')}/**/*.ts`
32
+ `${workspaceProject.root}/**/*.{m,c,}{j,t}s`,
33
+ `${workspaceProject.root}/**/*.json`,
34
+ `${workspaceProject.root}/**/*.html`
28
35
  ]
29
36
  }
30
37
  };
31
38
  workspace.projects[projectName] = workspaceProject;
32
39
  tree.overwrite('/angular.json', JSON.stringify(workspace, null, 2));
33
40
  };
41
+ /**
42
+ * Add the lint task in the package.json
43
+ * @param projectPath
44
+ * @param projectName
45
+ */
46
+ const editPackageJson = (projectPath, projectName) => (tree) => {
47
+ const packageJsonPath = path.posix.join(projectPath, 'package.json');
48
+ const packageJson = tree.readJson(packageJsonPath);
49
+ packageJson.scripts ??= {};
50
+ packageJson.scripts.lint ??= `ng lint ${projectName}`;
51
+ tree.overwrite(packageJsonPath, JSON.stringify(packageJson, null, 2));
52
+ };
53
+ const isInstalled = (packageName) => {
54
+ try {
55
+ require.resolve(packageName);
56
+ }
57
+ catch {
58
+ return false;
59
+ }
60
+ return true;
61
+ };
34
62
  /**
35
63
  * Update ESLint Config
36
64
  * @param rootPath
@@ -50,6 +78,8 @@ const updateEslintConfig = (rootPath, projectName) => (tree, context) => {
50
78
  const templateOptions = {
51
79
  extension: 'mjs',
52
80
  codeBeforeConfig: '',
81
+ playwrightInstalled: isInstalled('playwright'),
82
+ jest: isInstalled('jest'),
53
83
  codeAfterConfig: '',
54
84
  oldConfig: '',
55
85
  relativePathToRoot: path.posix.relative(projectRootPath, '.'),
@@ -75,7 +105,12 @@ const updateEslintConfig = (rootPath, projectName) => (tree, context) => {
75
105
  tree.delete(filePath);
76
106
  }
77
107
  return (0, schematics_1.chain)([
78
- projectName ? editAngularJson(projectName, templateOptions.extension) : (0, schematics_1.noop)(),
108
+ ...projectName
109
+ ? [
110
+ editAngularJson(projectName, templateOptions.extension),
111
+ editPackageJson(projectRootPath, projectName)
112
+ ]
113
+ : [],
79
114
  (0, schematics_1.applyToSubtree)(projectRootPath, [
80
115
  (0, schematics_1.mergeWith)((0, schematics_1.apply)((0, schematics_1.url)((0, schematics_2.getTemplateFolder)(rootPath, __dirname, `./templates/${projectRootPath === '.' ? 'workspace' : 'project'}`)), [
81
116
  (0, schematics_1.template)(templateOptions),
@@ -31,5 +31,18 @@ const __dirname = dirname(__filename);
31
31
  ...globals.browser
32
32
  }<% } %>
33
33
  }
34
- }
34
+ }<% if (playwrightInstalled) { %>,
35
+ {
36
+ name: '<%= packageName %>/e2e',
37
+ files: [
38
+ '**/e2e-playwright/**/*.{j,t}s'
39
+ ],
40
+ languageOptions: {
41
+ globals: {
42
+ ...globals.node,
43
+ NodeJS: true
44
+ }
45
+ }
46
+ }
47
+ <% } %>
35
48
  ]);
@@ -18,7 +18,8 @@
18
18
  },
19
19
  "fix": {
20
20
  "type": "boolean",
21
- "description": "Fix known issues with our ESLint config after Otter application or library generation"
21
+ "description": "Fix known issues with our ESLint config after Otter application or library generation",
22
+ "default": true
22
23
  },
23
24
  "skipLinter": {
24
25
  "type": "boolean",
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * Get the @o3r plugin
3
+ * Get the `@o3r` plugin
4
4
  * @param {import('@typescript-eslint/utils').TSESLint.FlatConfig.Plugin} plugin
5
5
  * @returns {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} config
6
6
  */
@@ -2,7 +2,7 @@
2
2
  const o3rBaseConfig = require('../base.cjs');
3
3
 
4
4
  /**
5
- * Get the @o3r template recommended rules
5
+ * Get the `@o3r` template recommended rules
6
6
  * @param {import('@typescript-eslint/utils').TSESLint.FlatConfig.Plugin} plugin
7
7
  * @returns {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} config
8
8
  */
@@ -20,7 +20,17 @@ const config = [
20
20
  'jsdoc/check-tag-names': [
21
21
  'error',
22
22
  {
23
- definedTags: ['note', 'title', 'o3rRestrictionKey', 'o3rCategory', 'o3rCategories', 'o3rWidget', 'o3rWidgetParam', 'o3rRequired']
23
+ definedTags: [
24
+ 'experimental',
25
+ 'note',
26
+ 'title',
27
+ 'o3rRestrictionKey',
28
+ 'o3rCategory',
29
+ 'o3rCategories',
30
+ 'o3rWidget',
31
+ 'o3rWidgetParam',
32
+ 'o3rRequired'
33
+ ]
24
34
  }
25
35
  ],
26
36
  'jsdoc/no-defaults': 'off',
@@ -2,7 +2,7 @@
2
2
  const o3rBaseConfig = require('../base.cjs');
3
3
 
4
4
  /**
5
- * Get the @o3r typescript recommended rules
5
+ * Get the `@o3r` typescript recommended rules
6
6
  * @param {import('@typescript-eslint/utils').TSESLint.FlatConfig.Plugin} plugin
7
7
  * @returns {import('@typescript-eslint/utils').TSESLint.FlatConfig.Config} config
8
8
  */
@@ -2,6 +2,14 @@
2
2
  const stylistic = require('@stylistic/eslint-plugin');
3
3
  const { convertWarningsToErrors } = require('../utils.cjs');
4
4
 
5
+ const defaultCommatDangleOptions = {
6
+ arrays: 'never',
7
+ objects: 'never',
8
+ imports: 'always-multiline',
9
+ exports: 'always-multiline',
10
+ functions: 'never'
11
+ };
12
+
5
13
  /**
6
14
  * @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
7
15
  */
@@ -15,13 +23,7 @@ const config = [
15
23
  ...convertWarningsToErrors(stylistic.configs.recommended),
16
24
  '@stylistic/arrow-parens': ['error', 'always'],
17
25
  '@stylistic/brace-style': ['error', '1tbs'],
18
- '@stylistic/comma-dangle': ['error', {
19
- arrays: 'never',
20
- objects: 'never',
21
- imports: 'always-multiline',
22
- exports: 'always-multiline',
23
- functions: 'never'
24
- }],
26
+ '@stylistic/comma-dangle': ['error', defaultCommatDangleOptions],
25
27
  '@stylistic/indent': [
26
28
  'error',
27
29
  2,
@@ -95,6 +97,18 @@ const config = [
95
97
  'inside'
96
98
  ]
97
99
  }
100
+ },
101
+ {
102
+ name: '@o3r/eslint-config/stylistic-es-overrides',
103
+ files: [
104
+ '**/*.{c,m}{t,j}s'
105
+ ],
106
+ rules: {
107
+ '@stylistic/comma-dangle': ['error', {
108
+ ...defaultCommatDangleOptions,
109
+ generics: 'ignore'
110
+ }]
111
+ }
98
112
  }
99
113
  ];
100
114
 
@@ -7,6 +7,7 @@ const angular = require('angular-eslint');
7
7
  const importPlugin = require('eslint-plugin-import');
8
8
  const jsdoc = require('eslint-plugin-jsdoc');
9
9
  const unicorn = require('eslint-plugin-unicorn');
10
+ const globals = require('globals');
10
11
  const typescript = require('typescript-eslint');
11
12
  const commentsConfigOverrides = require('./typescript/comments.cjs');
12
13
  const angularConfigOverrides = require('./typescript/eslint-angular.cjs');
@@ -23,29 +24,19 @@ const stylisticConfig = require('./typescript/stylistic.cjs');
23
24
  const unicornConfig = require('./typescript/unicorn.cjs');
24
25
  const unusedImportsConfig = require('./typescript/unused-imports.cjs');
25
26
 
26
- /**
27
- * Get the jest config if dependency is present
28
- * @param {'recommended' | 'overrides'} type
29
- * @returns {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray} config
30
- */
31
- const getJestConfig = (type) => {
27
+ const checkDependency = (packageName) => {
32
28
  try {
33
- require.resolve('jest');
34
- return type === 'overrides'
35
- ? require('./typescript/jest.cjs')
36
- : [{
37
- // Name added for debugging purpose with @eslint/config-inspector
38
- name: 'jest/flat-recommended',
39
- files: [
40
- '**/*.{c,m,}{t,j}s'
41
- ],
42
- ...require('eslint-plugin-jest').configs['flat/recommended']
43
- }];
29
+ require.resolve(packageName);
44
30
  } catch {
45
- return [];
31
+ return false;
46
32
  }
33
+ return true;
47
34
  };
48
35
 
36
+ const hasPlaywrightInstalled = checkDependency('@playwright/test');
37
+
38
+ const hasJestDependency = checkDependency('jest');
39
+
49
40
  /**
50
41
  * @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigArray}
51
42
  */
@@ -87,7 +78,17 @@ const configArray = [
87
78
  ],
88
79
  ...unicorn.default.configs.recommended
89
80
  },
90
- ...(getJestConfig('recommended')),
81
+ ...(hasJestDependency
82
+ ? [{
83
+ // Name added for debugging purpose with @eslint/config-inspector
84
+ name: 'jest/flat-recommended',
85
+ files: [
86
+ '**/*.{c,m,}{t,j}s'
87
+ ],
88
+ ...require('eslint-plugin-jest').configs['flat/recommended']
89
+ }]
90
+ : []
91
+ ),
91
92
  {
92
93
  // Name added for debugging purpose with @eslint/config-inspector
93
94
  name: 'import/recommended',
@@ -107,7 +108,18 @@ const configArray = [
107
108
  ...typescriptConfigOverrides,
108
109
  ...angularConfigOverrides,
109
110
  ...jsdocConfigOverrides,
110
- ...(getJestConfig('overrides')),
111
+ ...(hasJestDependency
112
+ ? require('./typescript/jest.cjs')
113
+ : [{
114
+ name: '@o3r/eslint-config/typescript/jasmine-globals',
115
+ files: ['**/*.{c,m,}ts'],
116
+ languageOptions: {
117
+ globals: {
118
+ ...globals.jasmine
119
+ }
120
+ }
121
+ }]
122
+ ),
111
123
  ...preferArrowConfig,
112
124
  ...stylisticConfig,
113
125
  ...unicornConfig,
@@ -132,7 +144,33 @@ const configArray = [
132
144
  }
133
145
  }
134
146
  }
135
- }
147
+ }, {
148
+ name: '@o3r/eslint-config/node-files',
149
+ files: [
150
+ '**/schematics/**/*.{j,t}s',
151
+ ...hasJestDependency ? ['**/jest.config.{c,m,}{j,t}s'] : []
152
+ ],
153
+ languageOptions: {
154
+ globals: {
155
+ ...globals.node,
156
+ NodeJS: true
157
+ }
158
+ }
159
+ },
160
+ ...hasPlaywrightInstalled
161
+ ? [{
162
+ name: '@o3r/eslint-config/e2e-playwright',
163
+ files: [
164
+ '**/e2e-playwright/**/*.{j,t}s'
165
+ ],
166
+ languageOptions: {
167
+ globals: {
168
+ ...globals.node,
169
+ NodeJS: true
170
+ }
171
+ }
172
+ }]
173
+ : []
136
174
  ];
137
175
 
138
176
  module.exports = configArray;