newspack-scripts 1.2.0 → 1.4.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.
- package/README.md +65 -0
- package/config/eslintrc.js +32 -0
- package/config/stylelint.config.js +21 -0
- package/package.json +13 -1
package/README.md
CHANGED
|
@@ -10,3 +10,68 @@ Will run `jest` tests. Useful flags:
|
|
|
10
10
|
|
|
11
11
|
- `--watch` to run in file watch mode,
|
|
12
12
|
- `--coverage` to collect test coverage
|
|
13
|
+
|
|
14
|
+
### build
|
|
15
|
+
|
|
16
|
+
Will run `calypso-build`, creating optimised production builds.
|
|
17
|
+
|
|
18
|
+
### start
|
|
19
|
+
|
|
20
|
+
Will run `calypso-build` in watch mode.
|
|
21
|
+
|
|
22
|
+
## Available configs
|
|
23
|
+
|
|
24
|
+
This package exposes a couple of configuration files.
|
|
25
|
+
|
|
26
|
+
### webpack
|
|
27
|
+
|
|
28
|
+
The `webpack.config.js` file should use this package's config-extending function:
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
const getBaseWebpackConfig = require( 'newspack-scripts/config/getWebpackConfig' );
|
|
32
|
+
|
|
33
|
+
const webpackConfig = getBaseWebpackConfig(
|
|
34
|
+
{ WP: true },
|
|
35
|
+
{
|
|
36
|
+
entry: {
|
|
37
|
+
'some-script': './src/some-script.js'
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
module.exports = webpackConfig;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### babel
|
|
46
|
+
|
|
47
|
+
A basic `babel.config.js`:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
module.exports = api => {
|
|
51
|
+
api.cache( true );
|
|
52
|
+
return {
|
|
53
|
+
extends: 'newspack-scripts/config/babel.config.js',
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### eslint
|
|
59
|
+
|
|
60
|
+
Because of eslint's [issue](https://github.com/eslint/eslint/issues/3458) with resolving dependencies of extended configurations, a patch has to be used to use this config in a stand-alone fashion: install `@rushstack/eslint-patch` and set up the `.eslintrc.js` like so:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
require( '@rushstack/eslint-patch/modern-module-resolution' );
|
|
64
|
+
|
|
65
|
+
module.exports = {
|
|
66
|
+
extends: [ './node_modules/newspack-scripts/config/eslintrc.js' ],
|
|
67
|
+
// Additional options…
|
|
68
|
+
};
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### stylelint
|
|
72
|
+
|
|
73
|
+
Install `stylelint` via npm and reference this package's config file when running it, e.g.:
|
|
74
|
+
|
|
75
|
+
```shell
|
|
76
|
+
stylelint '**/*.scss' --syntax scss --config=./node_modules/newspack-scripts/config/stylelint.config.js
|
|
77
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
"plugin:@wordpress/eslint-plugin/recommended",
|
|
4
|
+
"plugin:react/recommended",
|
|
5
|
+
"plugin:import/errors",
|
|
6
|
+
"plugin:import/warnings",
|
|
7
|
+
],
|
|
8
|
+
env: {
|
|
9
|
+
browser: true,
|
|
10
|
+
jest: true,
|
|
11
|
+
},
|
|
12
|
+
ignorePatterns: ["dist/", "node_modules/"],
|
|
13
|
+
parser: "@babel/eslint-parser",
|
|
14
|
+
rules: {
|
|
15
|
+
"no-console": "off",
|
|
16
|
+
camelcase: "off",
|
|
17
|
+
// Disallow importing or requiring packages that are not listed in package.json
|
|
18
|
+
// This prevents us from depending on transitive dependencies, which could break in unexpected ways.
|
|
19
|
+
"import/no-extraneous-dependencies": ["error", { packageDir: "." }],
|
|
20
|
+
// There's a conflict with prettier here:
|
|
21
|
+
"react/jsx-curly-spacing": "off",
|
|
22
|
+
// Skip prop types validation for now
|
|
23
|
+
"react/prop-types": "off",
|
|
24
|
+
"react/react-in-jsx-scope": "off",
|
|
25
|
+
"react/self-closing-comp": "error",
|
|
26
|
+
// JSDoc rules overrides
|
|
27
|
+
"jsdoc/require-returns": "off",
|
|
28
|
+
"jsdoc/require-param": "off",
|
|
29
|
+
// Deprecated rules
|
|
30
|
+
"jsx-a11y/no-onchange": "off",
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: [
|
|
3
|
+
"@wordpress/stylelint-config/scss",
|
|
4
|
+
"stylelint-prettier/recommended",
|
|
5
|
+
],
|
|
6
|
+
rules: {
|
|
7
|
+
"rule-empty-line-before": null,
|
|
8
|
+
"at-rule-empty-line-before": null,
|
|
9
|
+
"comment-empty-line-before": null,
|
|
10
|
+
"string-quotes": "single",
|
|
11
|
+
"no-descending-specificity": null,
|
|
12
|
+
"function-url-quotes": null,
|
|
13
|
+
"declaration-property-unit-whitelist": null,
|
|
14
|
+
"font-weight-notation": null,
|
|
15
|
+
"color-named": null,
|
|
16
|
+
"function-parentheses-space-inside": "always-single-line",
|
|
17
|
+
"media-feature-parentheses-space-inside": "always",
|
|
18
|
+
"selector-pseudo-class-parentheses-space-inside": "always",
|
|
19
|
+
"selector-class-pattern": null,
|
|
20
|
+
},
|
|
21
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "newspack-scripts",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"bin": {
|
|
6
6
|
"newspack-scripts": "./bin/newspack-scripts.js"
|
|
@@ -9,16 +9,28 @@
|
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@automattic/calypso-build": "^10.0.0",
|
|
12
|
+
"@babel/eslint-parser": "^7.16.3",
|
|
12
13
|
"@babel/preset-env": "^7.16.4",
|
|
13
14
|
"@testing-library/jest-dom": "^5.15.1",
|
|
14
15
|
"@testing-library/react": "^12.1.2",
|
|
16
|
+
"@wordpress/eslint-plugin": "^9.3.0",
|
|
17
|
+
"@wordpress/stylelint-config": "^19.1.0",
|
|
15
18
|
"autoprefixer": "^10.4.0",
|
|
16
19
|
"babel-jest": "^27.4.2",
|
|
17
20
|
"cross-spawn": "^7.0.3",
|
|
21
|
+
"eslint": "^7.32.0",
|
|
22
|
+
"eslint-config-prettier": "^8.3.0",
|
|
23
|
+
"eslint-plugin-import": "^2.25.3",
|
|
24
|
+
"eslint-plugin-jest": "^25.3.0",
|
|
25
|
+
"eslint-plugin-react": "^7.27.1",
|
|
18
26
|
"jest": "^27.4.3",
|
|
19
27
|
"jest-environment-jsdom": "^27.4.3",
|
|
20
28
|
"postcss": "^8.4.4",
|
|
21
29
|
"postcss-focus-within": "^5.0.1",
|
|
30
|
+
"prettier": "npm:wp-prettier@2.2.1-beta-1",
|
|
31
|
+
"stylelint": "^13.3.1",
|
|
32
|
+
"stylelint-config-prettier": "^9.0.3",
|
|
33
|
+
"stylelint-prettier": "^1.2.0",
|
|
22
34
|
"webpack": "^5.65.0"
|
|
23
35
|
},
|
|
24
36
|
"scripts": {
|