@lipemat/js-boilerplate 8.0.0 → 8.2.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/README.md +0 -9
- package/config/webpack.dev.js +1 -1
- package/helpers/config.js +9 -9
- package/helpers/package-config.js +5 -2
- package/package.json +2 -2
- package/scripts/lint.js +34 -2
package/README.md
CHANGED
|
@@ -15,12 +15,6 @@ A zero configuration starting point for a React or non React app.
|
|
|
15
15
|
yarn add @lipemat/js-boilerplate
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
## Version 7
|
|
19
|
-
|
|
20
|
-
**Version 7 has some backward incompatibilities and should be updated with focus and thoroughness.**
|
|
21
|
-
|
|
22
|
-
[Migration instructions are here.](https://github.com/lipemat/js-boilerplate/wiki/Version-7-Migration)
|
|
23
|
-
|
|
24
18
|
## Usage
|
|
25
19
|
Add the following to your package.json. (this may also be found in the `templates` directory.
|
|
26
20
|
|
|
@@ -85,9 +79,6 @@ Babel will automatically compile TypeScript files into the finished javascript,
|
|
|
85
79
|
All configurations are found in the `config` directory and may be extended by adding a matching file within your project directory.
|
|
86
80
|
For instance is you want to adjust `webpack.dev.js` you may add a `config/webpack.dev.js` file in your project directory.
|
|
87
81
|
|
|
88
|
-
**@note** The `jsPath` will be taken into account so if you specified a `jsPath` the `config` directory must be placed
|
|
89
|
-
inside it. (e.g. `js/config/wepack.dev.js`).
|
|
90
|
-
|
|
91
82
|
All declarations are merged in favor of the project config.
|
|
92
83
|
|
|
93
84
|
### Extensions
|
package/config/webpack.dev.js
CHANGED
|
@@ -17,7 +17,7 @@ const plugins = [
|
|
|
17
17
|
} ),
|
|
18
18
|
];
|
|
19
19
|
|
|
20
|
-
// Loads a thread which verifies any TypeScripts on changes.
|
|
20
|
+
// Loads a thread, which verifies any TypeScripts on changes.
|
|
21
21
|
// Only use this if the project has a tsconfig.json file.
|
|
22
22
|
if ( configHelper.hasLocalOverride( 'tsconfig.json', true ) ) {
|
|
23
23
|
plugins.push( new ForkTsCheckerWebpackPlugin( {
|
package/helpers/config.js
CHANGED
|
@@ -8,19 +8,19 @@ const extensions = Object.keys( packageConfig.dependencies ).filter( name => nam
|
|
|
8
8
|
/**
|
|
9
9
|
* Check to see if a local config file exists.
|
|
10
10
|
*
|
|
11
|
-
* @param {string}
|
|
12
|
-
* @param {boolean}
|
|
11
|
+
* @param {string} fileName
|
|
12
|
+
* @param {boolean} inWorkingDirectory - Look in working directory instead of their /config directory
|
|
13
13
|
*
|
|
14
14
|
* @return {boolean}
|
|
15
15
|
*/
|
|
16
|
-
function hasLocalOverride(
|
|
16
|
+
function hasLocalOverride( fileName, inWorkingDirectory = false ) {
|
|
17
17
|
let hasLocal = false;
|
|
18
18
|
try {
|
|
19
|
-
if (
|
|
20
|
-
require( path.resolve( packageConfig.workingDirectory,
|
|
19
|
+
if ( inWorkingDirectory ) {
|
|
20
|
+
require( path.resolve( packageConfig.workingDirectory, fileName ) );
|
|
21
21
|
hasLocal = true;
|
|
22
22
|
} else {
|
|
23
|
-
require( path.resolve( packageConfig.
|
|
23
|
+
require( path.resolve( packageConfig.packageDirectory + '/config', fileName ) );
|
|
24
24
|
hasLocal = true;
|
|
25
25
|
}
|
|
26
26
|
} catch ( e ) {
|
|
@@ -44,7 +44,7 @@ function hasLocalOverride( $fileName, $inRoot = false ) {
|
|
|
44
44
|
function getConfig( $fileName ) {
|
|
45
45
|
let config = {...require( '../config/' + $fileName ), ...getExtensionsConfig( $fileName )};
|
|
46
46
|
try {
|
|
47
|
-
const localConfig = require( path.resolve( packageConfig.
|
|
47
|
+
const localConfig = require( path.resolve( packageConfig.packageDirectory + '/config', $fileName ) );
|
|
48
48
|
config = {...config, ...localConfig};
|
|
49
49
|
} catch ( e ) {
|
|
50
50
|
}
|
|
@@ -52,8 +52,8 @@ function getConfig( $fileName ) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* Get a config from any existing extension's /config
|
|
56
|
-
* merged
|
|
55
|
+
* Get a config from any existing extension's /config directories
|
|
56
|
+
* merged into one.
|
|
57
57
|
*
|
|
58
58
|
* @param {string} $fileName
|
|
59
59
|
*
|
|
@@ -6,10 +6,13 @@ const fs = require( 'fs' );
|
|
|
6
6
|
const workingDirectory = fs.realpathSync( process.cwd() );
|
|
7
7
|
|
|
8
8
|
let packageConfig = require( path.resolve( workingDirectory, 'package.json' ) );
|
|
9
|
-
packageConfig.
|
|
9
|
+
packageConfig.es6Modules = packageConfig.es6Modules || [];
|
|
10
|
+
// Path of the package.json file (root).
|
|
11
|
+
packageConfig.packageDirectory = workingDirectory;
|
|
10
12
|
packageConfig.themeUrlPath = packageConfig.themeUrlPath || '/';
|
|
11
13
|
packageConfig.url = packageConfig.url || 'http://localhost';
|
|
12
|
-
|
|
14
|
+
// Path of JS application files.
|
|
15
|
+
packageConfig.workingDirectory = packageConfig.jsPath ? path.resolve( packageConfig.jsPath ) : workingDirectory;
|
|
13
16
|
|
|
14
17
|
try {
|
|
15
18
|
const localConfig = require( path.resolve( workingDirectory, './local-config.json' ) );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lipemat/js-boilerplate",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.2.0",
|
|
4
4
|
"description": "Dependencies and scripts for a no config JavaScript app",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=14.17.6"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@babel/preset-typescript": "^7.12.7",
|
|
38
38
|
"@hot-loader/react-dom": "^17.0.1",
|
|
39
39
|
"@lipemat/css-mqpacker": "^8.0.1",
|
|
40
|
-
"@lipemat/eslint-config": "^
|
|
40
|
+
"@lipemat/eslint-config": "^2.0.1",
|
|
41
41
|
"@lipemat/postcss-loader": "^3.1.2",
|
|
42
42
|
"@lipemat/webpack-cleanup-plugin": "^1.0.0",
|
|
43
43
|
"@types/lipemat__js-boilerplate": "lipemat/types-js-boilerplate#semver:^1.3.0",
|
package/scripts/lint.js
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
|
-
const
|
|
1
|
+
const {ESLint} = require( 'eslint' );
|
|
2
2
|
const packageConfig = require( '../helpers/package-config' );
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Use the public API to run the eslint commands.
|
|
6
|
+
*
|
|
7
|
+
* @link https://eslint.org/docs/developer-guide/nodejs-api
|
|
8
|
+
*/
|
|
9
|
+
( async function main() {
|
|
10
|
+
// 1. Create an instance with the `fix` option.
|
|
11
|
+
const eslint = new ESLint( {
|
|
12
|
+
fix: true,
|
|
13
|
+
} );
|
|
14
|
+
|
|
15
|
+
// 2. Lint files. This doesn't modify target files.
|
|
16
|
+
const results = await eslint.lintFiles( [
|
|
17
|
+
packageConfig.workingDirectory + '/src/**/*.{js,jsx,ts,tsx}',
|
|
18
|
+
] );
|
|
19
|
+
|
|
20
|
+
// 3. Modify the files with the fixed code.
|
|
21
|
+
await ESLint.outputFixes( results );
|
|
22
|
+
|
|
23
|
+
// 4. Format the results.
|
|
24
|
+
const formatter = await eslint.loadFormatter( 'stylish' );
|
|
25
|
+
const resultText = formatter.format( results );
|
|
26
|
+
|
|
27
|
+
// 5. Output it.
|
|
28
|
+
console.log( resultText );
|
|
29
|
+
if ( '' === resultText ) {
|
|
30
|
+
console.log( '>> Linted JS files without errors.' );
|
|
31
|
+
console.log( '-----------------------------------' );
|
|
32
|
+
}
|
|
33
|
+
}() ).catch( error => {
|
|
34
|
+
process.exitCode = 1;
|
|
35
|
+
console.error( error );
|
|
36
|
+
} );
|