Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ module.exports = class extends Base {
return prompts.reduce((result, item) => {
const name = item.name;

if (name == 'themeName') {
if (name === 'themeName') {
item.default = 'My Liferay Themelet';
item.message = 'What would you like to call your themelet?';
}
else if (name == 'themeId') {
else if (name === 'themeId') {
item.message = 'Would you like to use this as the themeletId?';
}
else if (name == 'liferayVersion') {
else if (name === 'liferayVersion') {
item.choices = ['7.1', '7.0', 'All'];
item.message = 'Which version of Liferay is this themelet for?';
}
Expand All @@ -107,7 +107,7 @@ module.exports = class extends Base {
}

_promptCallback(props) {
if (props.liferayVersion == 'All') {
if (props.liferayVersion === 'All') {
props.liferayVersion = '*';
}
super._promptCallback.call(this, props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ describe('LayoutCreator', () => {
_.forEach(choices, (choice, index) => {
index = index + 1;

if (index % 2 == 0) {
if (index % 2 === 0) {
assert.equal(choice.type, 'separator');
assert.equal(
stripAnsi(choice.line),
Expand All @@ -527,7 +527,7 @@ describe('LayoutCreator', () => {
}
});

assert(choices[choices.length - 1].type != 'separator');
assert(choices[choices.length - 1].type !== 'separator');

while (prototype.rows.length < 7) {
prototype.rows.push({
Expand Down Expand Up @@ -569,7 +569,7 @@ describe('LayoutCreator', () => {
_.forEach(choices, (choice, index) => {
index = index + 1;

if (index % 2 == 0) {
if (index % 2 === 0) {
assert.equal(choice.value, choiceValue);
assert.equal(
stripAnsi(choice.name),
Expand All @@ -587,7 +587,7 @@ describe('LayoutCreator', () => {
}
});

assert(choices[choices.length - 1].type == 'separator');
assert(choices[choices.length - 1].type === 'separator');

while (prototype.rows.length < 7) {
prototype.rows.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ inquirer.prompt.prompts.list.prototype.render = function () {
var choices = _.reduce(
this.opt.choices.choices,
(result, item) => {
if (item.type != 'separator') {
if (item.type !== 'separator') {
result.push(item);
}

Expand Down Expand Up @@ -113,16 +113,16 @@ LayoutCreator.prototype = {
_afterPromptFinishRow(answers, cb) {
var finish = answers.finish;

if (finish == 'add') {
if (finish === 'add') {
this._promptRow(cb);
}
else if (finish == 'insert') {
else if (finish === 'insert') {
this._promptInsertRow(cb);
}
else if (answers.finish == 'finish') {
else if (answers.finish === 'finish') {
cb(null);
}
else if (finish == 'remove') {
else if (finish === 'remove') {
this._promptRemoveRow(cb);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function register(options) {
store.set('changedFile');

globby.sync([path.resolve(__dirname, 'tasks/**/*')]).forEach((item) => {
if (item.indexOf('__tests__') == -1) {
if (item.indexOf('__tests__') === -1) {
// eslint-disable-next-line @liferay/no-dynamic-require
require(item)(options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function isLanguage(version) {

function printWarnings(version) {
return function (generator, {templateLanguage}) {
if (templateLanguage == 'vm') {
if (templateLanguage === 'vm') {
if (version === '7.0') {
generator.log(
chalk.yellow(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ it('formatThemeletSelection should format themelet selection retrieved from getM
it('getListType should get listType based on environment', () => {
const listType = promptUtil.getListType();

expect(listType == 'list' || listType == 'rawlist').toBe(true);
expect(listType === 'list' || listType === 'rawlist').toBe(true);
});

it('getModuleChoices should get module choices that are appropriate for extend type', () => {
Expand All @@ -80,7 +80,7 @@ it('getModuleChoices should get module choices that are appropriate for extend t
const number = index + 1;
const name = 'themelet-' + number;

if (number == 1) {
if (number === 1) {
expect(item.name).toBe(name + ' (selected)');
}

Expand Down Expand Up @@ -108,7 +108,7 @@ it('getModuleChoices should get module choices that are appropriate for extend t
const number = index + 1;
const name = 'themelet-' + number;

if (number == 1) {
if (number === 1) {
expect(item.checked).toBe(true);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ expect.extend({
pass = false;
message = `Path '${path}' is not a folder`;
}
else if (fs.readdirSync(path).length == 0) {
else if (fs.readdirSync(path).length === 0) {
pass = false;
message = `Folder '${path}' is empty`;
}
Expand All @@ -70,7 +70,7 @@ expect.extend({
pass = false;
message = `Path '${path}' is not a folder`;
}
else if (fs.readdirSync(path).length != 0) {
else if (fs.readdirSync(path).length !== 0) {
pass = false;
message = `Folder '${path}' is not empty`;
}
Expand Down Expand Up @@ -321,7 +321,7 @@ function cleanTempTheme(themeName, version, component, initCwd) {

cleanDirectory(tempPath);

if (initCwd != null) {
if (initCwd !== null && initCwd !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we express this as if (initCwd) . I find if (initCwd !== null && initCwd !== undefined) a bit too complex to use it in every place of the code...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My goal with using initCwd !== null && initCwd !== undefined is that it is safer for a wide refactor since initCwd != null is equal to initCwd !== null && initCwd !== undefined

If I was writing new code, I would likely use if (initCwd), but I can't totally be sure that this bit of code would work with that unless I tested it thoroughly(which I didn't since I touched lots of code).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is only for this PR, it's OK and we may refactor them when we come back to the code. But if it is going to be our usual pattern, I find it a bit too much for my refined taste

Just saw this from below. Yep, this is just for this PR and not something I intend for us to do. Only made that change for some safety in refactoring.

process.chdir(initCwd);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ inquirer.prompt.prompts.list.prototype.render = function () {
var choices = _.reduce(
this.opt.choices.choices,
(result, item) => {
if (item.type != 'separator') {
if (item.type !== 'separator') {
result.push(item);
}

Expand Down Expand Up @@ -106,16 +106,16 @@ LayoutCreator.prototype = {
_afterPromptFinishRow(answers, cb) {
var finish = answers.finish;

if (finish == 'add') {
if (finish === 'add') {
this._promptRow(cb);
}
else if (finish == 'insert') {
else if (finish === 'insert') {
this._promptInsertRow(cb);
}
else if (answers.finish == 'finish') {
else if (answers.finish === 'finish') {
cb(null);
}
else if (finish == 'remove') {
else if (finish === 'remove') {
this._promptRemoveRow(cb);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ describe('LayoutCreator', () => {
_.forEach(choices, (choice, index) => {
index = index + 1;

if (index % 2 == 0) {
if (index % 2 === 0) {
assert.equal(choice.type, 'separator');
assert.equal(
stripAnsi(choice.line),
Expand All @@ -518,7 +518,7 @@ describe('LayoutCreator', () => {
}
});

assert(choices[choices.length - 1].type != 'separator');
assert(choices[choices.length - 1].type !== 'separator');

while (prototype.rows.length < 7) {
prototype.rows.push({
Expand Down Expand Up @@ -560,7 +560,7 @@ describe('LayoutCreator', () => {
_.forEach(choices, (choice, index) => {
index = index + 1;

if (index % 2 == 0) {
if (index % 2 === 0) {
assert.equal(choice.value, choiceValue);
assert.equal(
stripAnsi(choice.name),
Expand All @@ -578,7 +578,7 @@ describe('LayoutCreator', () => {
}
});

assert(choices[choices.length - 1].type == 'separator');
assert(choices[choices.length - 1].type === 'separator');

while (prototype.rows.length < 7) {
prototype.rows.push({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function register(options) {
store.set('changedFile');

globby.sync([path.resolve(__dirname, 'tasks/**/*')]).forEach((item) => {
if (item.indexOf('__tests__') == -1) {
if (item.indexOf('__tests__') === -1) {
// eslint-disable-next-line @liferay/no-dynamic-require
require(item)(options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ it('formatThemeletSelection should format themelet selection retrieved from getM
it('getListType should get listType based on environment', () => {
const listType = promptUtil.getListType();

expect(listType == 'list' || listType == 'rawlist').toBe(true);
expect(listType === 'list' || listType === 'rawlist').toBe(true);
});

it('getModuleChoices should get module choices that are appropriate for extend type', () => {
Expand All @@ -80,7 +80,7 @@ it('getModuleChoices should get module choices that are appropriate for extend t
const number = index + 1;
const name = 'themelet-' + number;

if (number == 1) {
if (number === 1) {
expect(item.name).toBe(name + ' (selected)');
}

Expand Down Expand Up @@ -108,7 +108,7 @@ it('getModuleChoices should get module choices that are appropriate for extend t
const number = index + 1;
const name = 'themelet-' + number;

if (number == 1) {
if (number === 1) {
expect(item.checked).toBe(true);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ module.exports = function (css, options) {
comments(rules);
while (
css.length &&
css.charAt(0) != '}' &&
css.charAt(0) !== '}' &&
(node = atrule() || rule())
) {
rules.push(node);
Expand Down Expand Up @@ -180,14 +180,14 @@ module.exports = function (css, options) {

function comment() {
var pos = position();
if ('/' != css.charAt(0) || '*' != css.charAt(1)) {
if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
return;
}

var i = 2;
while (
null != css.charAt(i) &&
('*' != css.charAt(i) || '/' != css.charAt(i + 1))
null !== css.charAt(i) &&
('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))
) {
++i;
}
Expand Down Expand Up @@ -599,7 +599,7 @@ module.exports = function (css, options) {
*/

function atrule() {
if (css[0] != '@') {
if (css[0] !== '@') {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function quad(v, m) {

// 1px 2px 3px 4px => 1px 4px 3px 2px

if ((m = v.trim().split(/\s+(?=[^)]*(?:[(]|$))/)) && m.length == 4) {
if ((m = v.trim().split(/\s+(?=[^)]*(?:[(]|$))/)) && m.length === 4) {
return [m[0], m[3], m[2], m[1]].join(' ');
}

Expand All @@ -29,10 +29,10 @@ function quad_radius(v) {
// since border-radius: top-left top-right bottom-right bottom-left
// will be border-radius: top-right top-left bottom-left bottom-right

if (m && m.length == 4) {
if (m && m.length === 4) {
return [m[1], m[0], m[3], m[2]].join(' ');
}
else if (m && m.length == 3) {
else if (m && m.length === 3) {

// super odd how this works
// 5px 10px 20px => 10px 5px 10px 20px
Expand Down Expand Up @@ -67,10 +67,10 @@ function bgPosition(v) {
v = v.replace(/\bright\b/, 'left');
}
var m = v.trim().split(/\s+/);
if (m && m.length == 1 && v.match(/(\d+)([a-z]{2}|%)/)) {
if (m && m.length === 1 && v.match(/(\d+)([a-z]{2}|%)/)) {
v = 'right ' + v;
}
if (m && m.length == 2 && m[0].match(/\d+%/)) {
if (m && m.length === 2 && m[0].match(/\d+%/)) {

// 30% => 70% (100 - x)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ InitPrompt.prototype = {
if (appServerPath) {
var baseName = path.basename(appServerPath);

if (baseName != 'webapps') {
if (baseName !== 'webapps') {
appServerPath = getPath(answers).join(appServerPath, 'webapps');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ RegisterHooks.prototype = {
var when = data[0];
var taskName = data[1];

if (when != 'after' && when != 'before') {
if (when !== 'after' && when !== 'before') {
return taskHookMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = function (options) {

var moduleVersion = result.match(REGEX_MODULE_VERSION);

if (moduleVersion && moduleVersion[1] != npmPackageVersion) {
if (moduleVersion && moduleVersion[1] !== npmPackageVersion) {
result = result.replace(
REGEX_MODULE_VERSION,
(_match, _g1) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ expect.extend({
pass = false;
message = `Path '${path}' is not a folder`;
}
else if (fs.readdirSync(path).length == 0) {
else if (fs.readdirSync(path).length === 0) {
pass = false;
message = `Folder '${path}' is empty`;
}
Expand All @@ -50,7 +50,7 @@ expect.extend({
pass = false;
message = `Path '${path}' is not a folder`;
}
else if (fs.readdirSync(path).length != 0) {
else if (fs.readdirSync(path).length !== 0) {
pass = false;
message = `Folder '${path}' is not empty`;
}
Expand Down Expand Up @@ -303,7 +303,7 @@ function cleanTempTheme(themeName, version, component, initCwd) {

cleanDirectory(tempPath);

if (initCwd != null) {
if (initCwd !== null && initCwd !== undefined) {
process.chdir(initCwd);
}
}
Expand Down
Loading