Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

294 correctly use and bundle yoastseo package in premium #21006

Draft
wants to merge 30 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a4b61d5
Specifying modules: false in the ``@babel/preset-env` config to preve…
FAMarfuaty Dec 22, 2023
40c7880
Add back missing spaces
FAMarfuaty Dec 22, 2023
2e51793
Bundle language entries based on the build code of yoastseo package
FAMarfuaty Dec 22, 2023
4ffb462
Group the language processing helpers into one module
FAMarfuaty Jan 2, 2024
d4d1098
Adjust imports
FAMarfuaty Jan 2, 2024
e6aa3be
Adjust import
FAMarfuaty Jan 3, 2024
564bbe4
Fix typos
FAMarfuaty Jan 4, 2024
dbadc81
Merge branch 'releasing-yoastseo' of github.com:Yoast/wordpress-seo i…
FAMarfuaty Jan 4, 2024
73fc90f
Compile code to CommonJS when test is running
FAMarfuaty Jan 5, 2024
0ac32f7
Improve exporting syntax
FAMarfuaty Jan 5, 2024
b97808c
Add eslint plugin for tree shaking
FAMarfuaty Jan 8, 2024
7b61e10
Add tree shaking config
FAMarfuaty Jan 8, 2024
d792697
Disable tree-shaking plugin for spec folder
FAMarfuaty Jan 10, 2024
37d3a9a
Refactor classes to use newer syntax with `class` keyword
FAMarfuaty Jan 11, 2024
1bdd161
Upgrade dependencies
FAMarfuaty Jan 11, 2024
d87b712
Adjust unit tests
FAMarfuaty Jan 11, 2024
5f7a0e8
use `import` statement instead of `require`
FAMarfuaty Jan 11, 2024
006e5c2
Add exception to tree shaking config rule
FAMarfuaty Jan 15, 2024
967d44a
Refactor the class
FAMarfuaty Jan 15, 2024
349f89d
Explicitly make parse method static. This way this method can only be…
FAMarfuaty Jan 16, 2024
02ec24e
Remove irrelevant tests. Now parse method is a static method of the c…
FAMarfuaty Jan 16, 2024
58f0c0b
Fix import statement
FAMarfuaty Jan 16, 2024
c361c6c
Fix a copy paste mistake. `getKeywordDensity` should return `getKeyph…
FAMarfuaty Jan 16, 2024
4a60b42
Remove unnecessary import
FAMarfuaty Jan 16, 2024
aaa0463
refactor AssessorPresenter to use class
FAMarfuaty Jan 16, 2024
e1f0a21
Fix the way we access the `parse` method
FAMarfuaty Jan 16, 2024
c665001
Merge branch 'releasing-yoastseo' of github.com:Yoast/wordpress-seo i…
FAMarfuaty Jan 18, 2024
7c8feee
Upgrade dependencies
FAMarfuaty Jan 22, 2024
01d52a5
Merge branch 'releasing-yoastseo' of github.com:Yoast/wordpress-seo i…
FAMarfuaty Jan 22, 2024
845ce24
Add rule to exclude parsing source map from `parse5`
FAMarfuaty Jan 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactor classes to use newer syntax with class keyword
  • Loading branch information
FAMarfuaty committed Jan 11, 2024
commit 37d3a9a980b14c6df80ee00cf436539cb5f91c77
2 changes: 1 addition & 1 deletion packages/js/src/insights/initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const createUpdater = () => {
* @returns {void}
*/
return () => {
const paper = Paper.parse( collectData() );
const paper = Paper.prototype.parse( collectData() );

runResearch( "readingTime", paper ).then( response => setEstimatedReadingTime( response.result ) );
runResearch( "getFleschReadingScore", paper ).then( response => {
Expand Down
163 changes: 84 additions & 79 deletions packages/yoastseo/src/languageProcessing/values/ProminentWord.js
Original file line number Diff line number Diff line change
@@ -1,90 +1,95 @@
/**
* Represents a prominent word in the context of relevant words.
*
* @constructor
*
* @param {string} word The word.
* @param {string} [stem] The stem / base form of the word, defaults to the word.
* @param {number} [occurrences] The number of occurrences, defaults to 0.
*/
function ProminentWord( word, stem, occurrences ) {
this._word = word;
this._stem = stem ? stem : word;
this._occurrences = occurrences || 0;
}
*/
class ProminentWord {
/**
* Constructs Prominent word object.
*
* @constructor
*
* @param {string} word The word.
* @param {string} [stem] The stem / base form of the word, defaults to the word.
* @param {number} [occurrences] The number of occurrences, defaults to 0.
*/
constructor( word, stem, occurrences ) {
this._word = word;
this._stem = stem ? stem : word;
this._occurrences = occurrences || 0;
}

/**
* Sets the word.
*
* @param {string} word The word to set.
*
* @returns {void}.
*/
ProminentWord.prototype.setWord = function( word ) {
this._word = word;
};
/**
* Sets the word.
*
* @param {string} word The word to set.
*
* @returns {void}.
*/
setWord( word ) {
this._word = word;
}

/**
* Returns the word.
*
* @returns {string} The word.
*/
ProminentWord.prototype.getWord = function() {
return this._word;
};
/**
* Returns the word.
*
* @returns {string} The word.
*/
getWord() {
return this._word;
}

/**
* Returns the stem of the word.
*
* @returns {string} The stem.
*/
ProminentWord.prototype.getStem = function() {
return this._stem;
};
/**
* Returns the stem of the word.
*
* @returns {string} The stem.
*/
getStem() {
return this._stem;
}

/**
* Sets the number of occurrences to the word.
*
* @param {int} numberOfOccurrences The number of occurrences to set.
*
* @returns {void}.
*/
ProminentWord.prototype.setOccurrences = function( numberOfOccurrences ) {
this._occurrences = numberOfOccurrences;
};
/**
* Sets the number of occurrences to the word.
*
* @param {int} numberOfOccurrences The number of occurrences to set.
*
* @returns {void}.
*/
setOccurrences( numberOfOccurrences ) {
this._occurrences = numberOfOccurrences;
}

/**
* Returns the amount of occurrences of this word.
*
* @returns {number} The number of occurrences.
*/
ProminentWord.prototype.getOccurrences = function() {
return this._occurrences;
};
/**
* Returns the amount of occurrences of this word.
*
* @returns {number} The number of occurrences.
*/
getOccurrences() {
return this._occurrences;
}

/**
* Serializes the ProminentWord instance to an object.
*
* @returns {Object} The serialized ProminentWord.
*/
ProminentWord.prototype.serialize = function() {
return {
_parseClass: "ProminentWord",
word: this._word,
stem: this._stem,
occurrences: this._occurrences,
};
};
/**
* Serializes the ProminentWord instance to an object.
*
* @returns {Object} The serialized ProminentWord.
*/
serialize() {
return {
_parseClass: "ProminentWord",
word: this._word,
stem: this._stem,
occurrences: this._occurrences,
};
}

/**
* Parses the object to a ProminentWord.
*
* @param {Object} serialized The serialized object.
*
* @returns {ProminentWord} The parsed ProminentWord.
*/
ProminentWord.parse = function( serialized ) {
return new ProminentWord( serialized.word, serialized.stem, serialized.occurrences );
};
/**
* Parses the object to a ProminentWord.
*
* @param {Object} serialized The serialized object.
*
* @returns {ProminentWord} The parsed ProminentWord.
*/
parse( serialized ) {
return new ProminentWord( serialized.word, serialized.stem, serialized.occurrences );
}
}

export default ProminentWord;
61 changes: 31 additions & 30 deletions packages/yoastseo/src/scoring/taxonomyAssessor.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { inherits } from "util";

import IntroductionKeywordAssessment from "./assessments/seo/IntroductionKeywordAssessment";
import KeyphraseLengthAssessment from "./assessments/seo/KeyphraseLengthAssessment";
import KeyphraseDensityAssessment from "./assessments/seo/KeywordDensityAssessment";
Expand Down Expand Up @@ -34,36 +32,39 @@ export const getTextLengthAssessment = function() {

/**
* Creates the Assessor used for taxonomy pages.
*
* @param {Researcher} researcher The researcher used for the analysis.
* @param {Object?} options The options for this assessor.
* @constructor
*/
const TaxonomyAssessor = function( researcher, options ) {
Assessor.call( this, researcher, options );
this.type = "taxonomyAssessor";
class TaxonomyAssessor extends Assessor {
/**
* Creates a new taxonomy assessor.
*
* @param {Researcher} researcher The researcher to use.
* @param {Object} options The assessor options.
*/
constructor( researcher, options ) {
super( researcher, options );

this._assessments = [
new IntroductionKeywordAssessment(),
new KeyphraseLengthAssessment(),
new KeyphraseDensityAssessment(),
new MetaDescriptionKeywordAssessment(),
new MetaDescriptionLengthAssessment(),
getTextLengthAssessment(),
new KeyphraseInSEOTitleAssessment(),
new PageTitleWidthAssessment(
{
scores: {
widthTooShort: 9,
},
}, true
),
new SlugKeywordAssessment(),
new FunctionWordsInKeyphrase(),
new SingleH1Assessment(),
];
};
this.type = "taxonomyAssessor";

inherits( TaxonomyAssessor, Assessor );
this._assessments = [
new IntroductionKeywordAssessment(),
new KeyphraseLengthAssessment(),
new KeyphraseDensityAssessment(),
new MetaDescriptionKeywordAssessment(),
new MetaDescriptionLengthAssessment(),
getTextLengthAssessment(),
new KeyphraseInSEOTitleAssessment(),
new PageTitleWidthAssessment(
{
scores: {
widthTooShort: 9,
},
}, true
),
new SlugKeywordAssessment(),
new FunctionWordsInKeyphrase(),
new SingleH1Assessment(),
];
}
}

export default TaxonomyAssessor;
Loading