@codfish/eslint-config 13.1.0 → 13.1.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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-integration.spec.d.ts","sourceRoot":"","sources":["../../../tests/integration/react-integration.spec.js"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the version of a dependency from the consumer's package.json.
|
|
3
|
+
* Returns the major version as a string (e.g. '18', '19'), or null if not found.
|
|
4
|
+
*/
|
|
5
|
+
export function getDepVersion(dep: any): string | null;
|
|
1
6
|
export function hasLocalConfig(moduleName: any, searchOptions?: {}): boolean;
|
|
2
7
|
export function hasDep(props: any): boolean;
|
|
3
8
|
export function hasDevDep(props: any): boolean;
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../utils.js"],"names":[],"mappings":"AAyBA,6EAKC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../utils.js"],"names":[],"mappings":"AAyBA;;;GAGG;AACH,uDAKC;AAED,6EAKC;AA1BgC,4CAA+D;AAA/D,+CAA+D;AAA/D,gDAA+D;AAMzF,8CAA8E;AAE9E,yDAAmE"}
|
package/package.json
CHANGED
package/rules/react.js
CHANGED
|
@@ -7,7 +7,7 @@ import reactHooks from 'eslint-plugin-react-hooks';
|
|
|
7
7
|
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
8
8
|
import globals from 'globals';
|
|
9
9
|
|
|
10
|
-
import { ifAnyDep } from '../utils.js';
|
|
10
|
+
import { getDepVersion, ifAnyDep } from '../utils.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* React ESLint configuration. Includes React, React Hooks, and JSX accessibility rules.
|
|
@@ -41,7 +41,9 @@ export default defineConfig([
|
|
|
41
41
|
|
|
42
42
|
settings: {
|
|
43
43
|
react: {
|
|
44
|
-
|
|
44
|
+
// Avoid 'detect' — it uses context.getFilename() which was removed in ESLint 10.
|
|
45
|
+
// Read the major version from the consumer's package.json instead.
|
|
46
|
+
version: getDepVersion('react') || 'detect',
|
|
45
47
|
},
|
|
46
48
|
},
|
|
47
49
|
|
package/utils.js
CHANGED
|
@@ -23,6 +23,17 @@ export const hasAnyDep = args => [hasDep, hasDevDep, hasPeerDep].some(fn => fn(a
|
|
|
23
23
|
|
|
24
24
|
export const ifAnyDep = (deps, t, f) => (hasAnyDep([deps].flat()) ? t : f);
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Get the version of a dependency from the consumer's package.json.
|
|
28
|
+
* Returns the major version as a string (e.g. '18', '19'), or null if not found.
|
|
29
|
+
*/
|
|
30
|
+
export function getDepVersion(dep) {
|
|
31
|
+
const spec = pkg?.dependencies?.[dep] || pkg?.devDependencies?.[dep] || pkg?.peerDependencies?.[dep];
|
|
32
|
+
if (!spec) return null;
|
|
33
|
+
const match = spec.match(/\d+/);
|
|
34
|
+
return match ? match[0] : null;
|
|
35
|
+
}
|
|
36
|
+
|
|
26
37
|
export function hasLocalConfig(moduleName, searchOptions = {}) {
|
|
27
38
|
const explorerSync = cosmiconfigSync(moduleName, searchOptions);
|
|
28
39
|
const result = explorerSync.search(pkgPath || './');
|