@lipemat/eslint-config 3.0.2 → 3.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.
- package/helpers/config.js +50 -0
- package/index.js +18 -1
- package/package.json +25 -9
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const {getExtensionsConfig} = require( '@lipemat/js-boilerplate/helpers/config' );
|
|
2
|
+
const {getPackageConfig} = require( '@lipemat/js-boilerplate/helpers/package-config' );
|
|
3
|
+
const path = require( 'path' );
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Get a config from our /index.js merged with any
|
|
8
|
+
* matching configuration from the project directory.
|
|
9
|
+
*
|
|
10
|
+
* For instance if we have a file named config/eslint.config.js in our project
|
|
11
|
+
* we will merge the contents with our config/eslint.config.js in favor of whatever
|
|
12
|
+
* is specified with the project's file.
|
|
13
|
+
*
|
|
14
|
+
* If the `module.exports` are a function, the existing configuration will be passed
|
|
15
|
+
* as the only argument. Otherwise, standard `module.exports` are also supported.
|
|
16
|
+
*
|
|
17
|
+
* @see @lipemat/js-boilerplate/helpers/config
|
|
18
|
+
*
|
|
19
|
+
* @example ```ts
|
|
20
|
+
* // standard
|
|
21
|
+
* module.export = {
|
|
22
|
+
* externals: {extra: 'Extra'}
|
|
23
|
+
* }
|
|
24
|
+
* // function
|
|
25
|
+
* module.exports = function( config ) {
|
|
26
|
+
* return {
|
|
27
|
+
* externals: {...config.externals, extra: 'Extra'}
|
|
28
|
+
* }
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @return {Object}
|
|
33
|
+
*/
|
|
34
|
+
function getConfig( mergedConfig ) {
|
|
35
|
+
mergedConfig = {...mergedConfig, ...getExtensionsConfig( 'eslint.config', mergedConfig )};
|
|
36
|
+
try {
|
|
37
|
+
const localConfig = require( path.resolve( getPackageConfig().packageDirectory + '/config', 'eslint.config' ) );
|
|
38
|
+
if ( 'function' === typeof localConfig ) {
|
|
39
|
+
mergedConfig = {...mergedConfig, ...localConfig( mergedConfig )};
|
|
40
|
+
} else {
|
|
41
|
+
mergedConfig = {...mergedConfig, ...localConfig};
|
|
42
|
+
}
|
|
43
|
+
} catch ( e ) {
|
|
44
|
+
}
|
|
45
|
+
return mergedConfig;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
getConfig,
|
|
50
|
+
}
|
package/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
const {getConfig} = require( './helpers/config' );
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Default config if no extensions override it.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
let mergedConfig = {
|
|
2
8
|
"env": {
|
|
3
9
|
"browser": true
|
|
4
10
|
},
|
|
@@ -96,3 +102,14 @@ module.exports = {
|
|
|
96
102
|
},
|
|
97
103
|
},
|
|
98
104
|
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Merge in any extensions' config.
|
|
108
|
+
*/
|
|
109
|
+
try {
|
|
110
|
+
mergedConfig = getConfig( mergedConfig );
|
|
111
|
+
} catch( e ) {
|
|
112
|
+
// JS Boilerplate is not installed.
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
module.exports = mergedConfig;
|
package/package.json
CHANGED
|
@@ -1,25 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lipemat/eslint-config",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.1",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"description": "Eslint configuration for all @lipemat packages",
|
|
5
6
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
7
|
+
"node": ">=16.14.2"
|
|
7
8
|
},
|
|
8
9
|
"main": "index.js",
|
|
9
10
|
"files": [
|
|
10
|
-
"index.js"
|
|
11
|
+
"index.js",
|
|
12
|
+
"helpers/"
|
|
11
13
|
],
|
|
12
14
|
"repository": {
|
|
13
15
|
"type": "git",
|
|
14
16
|
"url": "git+https://github.com/lipemat/eslint-config.git"
|
|
15
17
|
},
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/lipemat/eslint-config/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/lipemat/eslint-config#readme",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"test": "lipemat-js-boilerplate test"
|
|
24
|
+
},
|
|
18
25
|
"dependencies": {
|
|
19
26
|
"@wordpress/eslint-plugin": "^12.2.0",
|
|
20
|
-
"eslint": "^8
|
|
27
|
+
"eslint": "^8"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@lipemat/js-boilerplate": "^10.3.1",
|
|
31
|
+
"@lipemat/js-boilerplate-svelte": "^0.0.3",
|
|
32
|
+
"@types/jest": "^29.5.3",
|
|
33
|
+
"@types/node": "^16",
|
|
34
|
+
"jest": "^29",
|
|
35
|
+
"typescript": "^5.1.6"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@lipemat/js-boilerplate": "^10.3.1"
|
|
21
39
|
},
|
|
22
|
-
"
|
|
23
|
-
"access": "public"
|
|
24
|
-
}
|
|
40
|
+
"packageManager": "yarn@3.6.1"
|
|
25
41
|
}
|