Skip to content
This repository was archived by the owner on Oct 4, 2022. It is now read-only.

Commit a295be8

Browse files
Merge branch 'release-yoast-seo/9.7'
* Improves the feedback for the assessment that checks the length of the text in cornerstone articles. * Fixes a bug where a Flesch reading ease score of exactly 90 would incorrectly trigger a red bullet.
2 parents cd7efbf + 220af5c commit a295be8

File tree

117 files changed

+9484
-7453
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+9484
-7453
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ This changelog is according to [Keep a Changelog](http://keepachangelog.com).
55
All notable changes to this project will be documented in this file.
66
We will follow [Semantic Versioning](http://semver.org/) from version 2 and onwards.
77

8+
## 1.48.0 February 25th, 2019
9+
### Added
10+
* Improves the feedback for the assessment that checks the length of the text in cornerstone articles.
11+
12+
### Fixed
13+
* Fixes a bug where a Flesch reading ease score of exactly 90 would incorrectly trigger a red bullet.
14+
815
## 1.47.0 February 11th, 2019
916
### Fixed
1017
* Fixes accidental removal of the SEO Assessor export from the index. Props [Kingdutch](https://github.com/Kingdutch).

Gruntfile.js

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ module.exports = function( grunt ) {
88
grunt: "grunt/",
99
js: "src/",
1010
css: "css/",
11+
/**
12+
* Gets the path to the grunt config.
13+
*
14+
* @returns {string} The config path.
15+
*/
1116
get config() {
1217
return this.grunt + "config/";
1318
},
@@ -29,6 +34,11 @@ module.exports = function( grunt ) {
2934
scss: "css/*.scss",
3035
templates: "templates/*.jst",
3136
jed: "node_modules/jed/jed.js",
37+
/**
38+
* Gets the wildcard to get the grunt config files.
39+
*
40+
* @returns {string} The wildcard.
41+
*/
3242
get config() {
3343
return project.paths.config + "*.js";
3444
},

docs/jsdoc-conf.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": [ "plugins/markdown" ]
3+
}

examples/webpack/README.md

+17-2,393
Large diffs are not rendered by default.

examples/webpack/config/env.js

+66-66
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,95 @@
1-
'use strict';
21

3-
const fs = require('fs');
4-
const path = require('path');
5-
const paths = require('./paths');
2+
3+
const fs = require( "fs" );
4+
const path = require( "path" );
5+
const paths = require( "./paths" );
66

77
// Make sure that including paths.js after env.js will read .env variables.
8-
delete require.cache[require.resolve('./paths')];
8+
delete require.cache[ require.resolve( "./paths" ) ];
99

1010
const NODE_ENV = process.env.NODE_ENV;
11-
if (!NODE_ENV) {
12-
throw new Error(
13-
'The NODE_ENV environment variable is required but was not specified.'
14-
);
11+
if ( ! NODE_ENV ) {
12+
throw new Error(
13+
"The NODE_ENV environment variable is required but was not specified."
14+
);
1515
}
1616

1717
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
1818
var dotenvFiles = [
19-
`${paths.dotenv}.${NODE_ENV}.local`,
20-
`${paths.dotenv}.${NODE_ENV}`,
21-
// Don't include `.env.local` for `test` environment
22-
// since normally you expect tests to produce the same
23-
// results for everyone
24-
NODE_ENV !== 'test' && `${paths.dotenv}.local`,
25-
paths.dotenv,
26-
].filter(Boolean);
19+
`${paths.dotenv}.${NODE_ENV}.local`,
20+
`${paths.dotenv}.${NODE_ENV}`,
21+
// Don't include `.env.local` for `test` environment
22+
// Since normally you expect tests to produce the same
23+
// Results for everyone
24+
NODE_ENV !== "test" && `${paths.dotenv}.local`,
25+
paths.dotenv,
26+
].filter( Boolean );
2727

2828
// Load environment variables from .env* files. Suppress warnings using silent
29-
// if this file is missing. dotenv will never modify any environment variables
30-
// that have already been set. Variable expansion is supported in .env files.
29+
// If this file is missing. dotenv will never modify any environment variables
30+
// That have already been set. Variable expansion is supported in .env files.
3131
// https://github.com/motdotla/dotenv
3232
// https://github.com/motdotla/dotenv-expand
33-
dotenvFiles.forEach(dotenvFile => {
34-
if (fs.existsSync(dotenvFile)) {
35-
require('dotenv-expand')(
36-
require('dotenv').config({
37-
path: dotenvFile,
38-
})
39-
);
40-
}
41-
});
33+
dotenvFiles.forEach( dotenvFile => {
34+
if ( fs.existsSync( dotenvFile ) ) {
35+
require( "dotenv-expand" )(
36+
require( "dotenv" ).config( {
37+
path: dotenvFile,
38+
} )
39+
);
40+
}
41+
} );
4242

4343
// We support resolving modules according to `NODE_PATH`.
4444
// This lets you use absolute paths in imports inside large monorepos:
45-
// https://github.com/facebookincubator/create-react-app/issues/253.
45+
// https://github.com/facebook/create-react-app/issues/253.
4646
// It works similar to `NODE_PATH` in Node itself:
4747
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
4848
// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
4949
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
50-
// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421
50+
// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
5151
// We also resolve them to make sure all tools using them work consistently.
52-
const appDirectory = fs.realpathSync(process.cwd());
53-
process.env.NODE_PATH = (process.env.NODE_PATH || '')
54-
.split(path.delimiter)
55-
.filter(folder => folder && !path.isAbsolute(folder))
56-
.map(folder => path.resolve(appDirectory, folder))
57-
.join(path.delimiter);
52+
const appDirectory = fs.realpathSync( process.cwd() );
53+
process.env.NODE_PATH = ( process.env.NODE_PATH || "" )
54+
.split( path.delimiter )
55+
.filter( folder => folder && ! path.isAbsolute( folder ) )
56+
.map( folder => path.resolve( appDirectory, folder ) )
57+
.join( path.delimiter );
5858

5959
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
60-
// injected into the application via DefinePlugin in Webpack configuration.
60+
// Injected into the application via DefinePlugin in Webpack configuration.
6161
const REACT_APP = /^REACT_APP_/i;
6262

63-
function getClientEnvironment(publicUrl) {
64-
const raw = Object.keys(process.env)
65-
.filter(key => REACT_APP.test(key))
66-
.reduce(
67-
(env, key) => {
68-
env[key] = process.env[key];
69-
return env;
70-
},
71-
{
72-
// Useful for determining whether we’re running in production mode.
73-
// Most importantly, it switches React into the correct mode.
74-
NODE_ENV: process.env.NODE_ENV || 'development',
75-
// Useful for resolving the correct path to static assets in `public`.
76-
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
77-
// This should only be used as an escape hatch. Normally you would put
78-
// images into the `src` and `import` them in code to get their paths.
79-
PUBLIC_URL: publicUrl,
80-
// Custom variables.
81-
YOAST_RECALIBRATION: process.env.YOAST_RECALIBRATION || "disabled",
82-
}
83-
);
84-
// Stringify all values so we can feed into Webpack DefinePlugin
85-
const stringified = {
86-
'process.env': Object.keys(raw).reduce((env, key) => {
87-
env[key] = JSON.stringify(raw[key]);
88-
return env;
89-
}, {}),
90-
};
63+
function getClientEnvironment( publicUrl ) {
64+
const raw = Object.keys( process.env )
65+
.filter( key => REACT_APP.test( key ) )
66+
.reduce(
67+
( env, key ) => {
68+
env[ key ] = process.env[ key ];
69+
return env;
70+
},
71+
{
72+
// Useful for determining whether we’re running in production mode.
73+
// Most importantly, it switches React into the correct mode.
74+
NODE_ENV: process.env.NODE_ENV || "development",
75+
// Useful for resolving the correct path to static assets in `public`.
76+
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
77+
// This should only be used as an escape hatch. Normally you would put
78+
// Images into the `src` and `import` them in code to get their paths.
79+
PUBLIC_URL: publicUrl,
80+
// Custom variables.
81+
YOAST_RECALIBRATION: process.env.YOAST_RECALIBRATION || "disabled",
82+
}
83+
);
84+
// Stringify all values so we can feed into Webpack DefinePlugin
85+
const stringified = {
86+
"process.env": Object.keys( raw ).reduce( ( env, key ) => {
87+
env[ key ] = JSON.stringify( raw[ key ] );
88+
return env;
89+
}, {} ),
90+
};
9191

92-
return { raw, stringified };
92+
return { raw, stringified };
9393
}
9494

9595
module.exports = getClientEnvironment;
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
'use strict';
1+
22

33
// This is a custom Jest transformer turning style imports into empty objects.
44
// http://facebook.github.io/jest/docs/en/webpack.html
55

66
module.exports = {
7-
process() {
8-
return 'module.exports = {};';
9-
},
10-
getCacheKey() {
11-
// The output is always the same.
12-
return 'cssTransform';
13-
},
7+
process() {
8+
return "module.exports = {};";
9+
},
10+
getCacheKey() {
11+
// The output is always the same.
12+
return "cssTransform";
13+
},
1414
};
+23-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1-
'use strict';
21

3-
const path = require('path');
2+
3+
const path = require( "path" );
44

55
// This is a custom Jest transformer turning file imports into filenames.
66
// http://facebook.github.io/jest/docs/en/webpack.html
77

88
module.exports = {
9-
process(src, filename) {
10-
return `module.exports = ${JSON.stringify(path.basename(filename))};`;
11-
},
9+
process( src, filename ) {
10+
const assetFilename = JSON.stringify( path.basename( filename ) );
11+
12+
if ( filename.match( /\.svg$/ ) ) {
13+
return `module.exports = {
14+
__esModule: true,
15+
default: ${assetFilename},
16+
ReactComponent: (props) => ({
17+
$$typeof: Symbol.for('react.element'),
18+
type: 'svg',
19+
ref: null,
20+
key: null,
21+
props: Object.assign({}, props, {
22+
children: ${assetFilename}
23+
})
24+
}),
25+
};`;
26+
}
27+
28+
return `module.exports = ${assetFilename};`;
29+
},
1230
};

examples/webpack/config/paths.js

+63-35
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1-
'use strict';
21

3-
const path = require( 'path' );
4-
const fs = require( 'fs' );
5-
const url = require( 'url' );
2+
3+
const path = require( "path" );
4+
const fs = require( "fs" );
5+
const url = require( "url" );
66

77
// Make sure any symlinks in the project folder are resolved:
8-
// https://github.com/facebookincubator/create-react-app/issues/637
8+
// https://github.com/facebook/create-react-app/issues/637
99
const appDirectory = fs.realpathSync( process.cwd() );
1010
const resolveApp = relativePath => path.resolve( appDirectory, relativePath );
1111

1212
const envPublicUrl = process.env.PUBLIC_URL;
1313

14-
function ensureSlash( path, needsSlash ) {
15-
const hasSlash = path.endsWith( '/' );
14+
function ensureSlash( inputPath, needsSlash ) {
15+
const hasSlash = inputPath.endsWith( "/" );
1616
if ( hasSlash && ! needsSlash ) {
17-
return path.substr( path, path.length - 1 );
18-
}
19-
else if ( ! hasSlash && needsSlash ) {
20-
return `${path}/`;
21-
}
22-
else {
23-
return path;
17+
return inputPath.substr( 0, inputPath.length - 1 );
18+
} else if ( ! hasSlash && needsSlash ) {
19+
return `${inputPath}/`;
2420
}
21+
return inputPath;
2522
}
2623

2724
const getPublicUrl = appPackageJson =>
@@ -30,36 +27,67 @@ const getPublicUrl = appPackageJson =>
3027
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
3128
// "public path" at which the app is served.
3229
// Webpack needs to know it to put the right <script> hrefs into HTML even in
33-
// single-page apps that may serve index.html for nested URLs like /todos/42.
30+
// Single-page apps that may serve index.html for nested URLs like /todos/42.
3431
// We can't use a relative path in HTML because we don't want to load something
35-
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
32+
// Like /todos/42/static/js/bundle.7289d.js. We have to know the root.
3633
function getServedPath( appPackageJson ) {
3734
const publicUrl = getPublicUrl( appPackageJson );
3835
const servedUrl =
39-
envPublicUrl || (
40-
publicUrl ? url.parse( publicUrl ).pathname : '/'
41-
);
36+
envPublicUrl || ( publicUrl ? url.parse( publicUrl ).pathname : "/" );
4237
return ensureSlash( servedUrl, true );
4338
}
4439

45-
// config after eject: we're in ./config/
40+
const moduleFileExtensions = [
41+
"web.mjs",
42+
"mjs",
43+
"web.js",
44+
"js",
45+
"web.ts",
46+
"ts",
47+
"web.tsx",
48+
"tsx",
49+
"json",
50+
"web.jsx",
51+
"jsx",
52+
];
53+
54+
// Resolve file paths in the same order as webpack
55+
const resolveModule = ( resolveFn, filePath ) => {
56+
const extension = moduleFileExtensions.find( extension =>
57+
fs.existsSync( resolveFn( `${filePath}.${extension}` ) )
58+
);
59+
60+
if ( extension ) {
61+
return resolveFn( `${filePath}.${extension}` );
62+
}
63+
64+
return resolveFn( `${filePath}.js` );
65+
};
66+
67+
// Config after eject: we're in ./config/
4668
module.exports = {
47-
dotenv: resolveApp( '.env' ),
48-
appBuild: resolveApp( 'build' ),
49-
appPublic: resolveApp( 'public' ),
50-
appHtml: resolveApp( 'public/index.html' ),
51-
appIndexJs: resolveApp( 'src/index.js' ),
52-
appPackageJson: resolveApp( 'package.json' ),
53-
appSrc: resolveApp( 'src' ),
54-
yarnLockFile: resolveApp( 'yarn.lock' ),
55-
testsSetup: resolveApp( 'src/setupTests.js' ),
56-
appNodeModules: resolveApp( 'node_modules' ),
57-
publicUrl: getPublicUrl( resolveApp( 'package.json' ) ),
58-
servedPath: getServedPath( resolveApp( 'package.json' ) ),
59-
yoastSrc: resolveApp( '../../src' ),
60-
yoastSpec: resolveApp( '../../spec' ),
61-
yoastComponents: resolveApp( 'node_modules/yoast-components' ),
69+
dotenv: resolveApp( ".env" ),
70+
appPath: resolveApp( "." ),
71+
appBuild: resolveApp( "build" ),
72+
appPublic: resolveApp( "public" ),
73+
appHtml: resolveApp( "public/index.html" ),
74+
appIndexJs: resolveModule( resolveApp, "src/index" ),
75+
appPackageJson: resolveApp( "package.json" ),
76+
appSrc: resolveApp( "src" ),
77+
appTsConfig: resolveApp( "tsconfig.json" ),
78+
yarnLockFile: resolveApp( "yarn.lock" ),
79+
testsSetup: resolveModule( resolveApp, "src/setupTests" ),
80+
proxySetup: resolveApp( "src/setupProxy.js" ),
81+
appNodeModules: resolveApp( "node_modules" ),
82+
publicUrl: getPublicUrl( resolveApp( "package.json" ) ),
83+
servedPath: getServedPath( resolveApp( "package.json" ) ),
84+
yoastSrc: resolveApp( "../../src" ),
85+
yoastSpec: resolveApp( "../../spec" ),
86+
yoastComponents: resolveApp( "node_modules/yoast-components" ),
6287
wpI18n: resolveApp( "node_modules/@wordpress/i18n" ),
6388
react: resolveApp( "node_modules/react" ),
6489
reactDom: resolveApp( "node_modules/react-dom" ),
6590
};
91+
92+
93+
module.exports.moduleFileExtensions = moduleFileExtensions;

0 commit comments

Comments
 (0)