@lipemat/eslint-config 3.0.2 → 3.1.2

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,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
- module.exports = {
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
  },
@@ -90,9 +96,21 @@ module.exports = {
90
96
  'template-curly-spacing': [ 1, 'never' ],
91
97
  'yoda': [ 2, 'always', {'onlyEquality': true} ],
92
98
  },
99
+ 'root': true,
93
100
  'settings': {
94
101
  'react': {
95
102
  'version': '18.0',
96
103
  },
97
104
  },
98
105
  };
106
+
107
+ /**
108
+ * Merge in any extensions' config.
109
+ */
110
+ try {
111
+ mergedConfig = getConfig( mergedConfig );
112
+ } catch( e ) {
113
+ // JS Boilerplate is not installed.
114
+ }
115
+
116
+ module.exports = mergedConfig;
package/package.json CHANGED
@@ -1,25 +1,41 @@
1
1
  {
2
2
  "name": "@lipemat/eslint-config",
3
- "version": "3.0.2",
3
+ "version": "3.1.2",
4
+ "license": "MIT",
4
5
  "description": "Eslint configuration for all @lipemat packages",
5
6
  "engines": {
6
- "node": ">=13.0.0"
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
- "author": "lipemat <mat@matlipe.com>",
17
- "license": "MIT",
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.8.0"
27
+ "eslint": "^8"
28
+ },
29
+ "devDependencies": {
30
+ "@lipemat/js-boilerplate": "^10.3.1",
31
+ "@lipemat/js-boilerplate-svelte": "^0.0.4",
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
- "publishConfig": {
23
- "access": "public"
24
- }
40
+ "packageManager": "yarn@3.6.1"
25
41
  }