Skip to content
Permalink
Browse files

chore(deps-dev): update eslint requirement from ^5.9.0 to ^6.0.1 (#3606)

* chore(deps-dev): update eslint requirement from ^5.9.0 to ^6.0.1

* refactor: call hasOwnProperty from Object.prototype

https://eslint.org/docs/6.0.0/rules/no-prototype-builtins
  • Loading branch information
curbengh authored and YoshinoriN committed Jul 6, 2019
1 parent b470d81 commit c2e4672e86a573d528a24b96fab63977172c0d64
@@ -112,7 +112,7 @@ Render.prototype.renderSync = function(data, options) {
};

function toString(result, options) {
if (!options.hasOwnProperty('toString') || typeof result === 'string') return result;
if (!Object.prototype.hasOwnProperty.call(options, 'toString') || typeof result === 'string') return result;

if (typeof options.toString === 'function') {
return options.toString(result);
@@ -35,7 +35,7 @@ function postPermalinkFilter(data) {

for (let i = 0, len = keys.length; i < len; i++) {
const key = keys[i];
if (meta.hasOwnProperty(key)) continue;
if (Object.prototype.hasOwnProperty.call(meta, key)) continue;

// Use Object.getOwnPropertyDescriptor to copy getters to avoid "Maximum call
// stack size exceeded" error
@@ -8,7 +8,7 @@ function listArchivesHelper(options = {}) {
let { format } = options;
const type = options.type || 'monthly';
const { style = 'list', transform, separator = ', ' } = options;
const showCount = options.hasOwnProperty('show_count') ? options.show_count : true;
const showCount = Object.prototype.hasOwnProperty.call(options, 'show_count') ? options.show_count : true;
const className = options.class || 'archive';
const order = options.order || -1;
let result = '';
@@ -1,7 +1,7 @@
'use strict';

function listCategoriesHelper(categories, options) {
if (!options && (!categories || !categories.hasOwnProperty('length'))) {
if (!options && (!categories || !Object.prototype.hasOwnProperty.call(categories, 'length'))) {
options = categories;
categories = this.site.categories;
}
@@ -10,13 +10,13 @@ function listCategoriesHelper(categories, options) {
options = options || {};

const { style = 'list', transform, separator = ', ', suffix = '' } = options;
const showCount = options.hasOwnProperty('show_count') ? options.show_count : true;
const showCount = Object.prototype.hasOwnProperty.call(options, 'show_count') ? options.show_count : true;
const className = options.class || 'category';
const depth = options.depth ? parseInt(options.depth, 10) : 0;
const orderby = options.orderby || 'name';
const order = options.order || 1;
const showCurrent = options.show_current || false;
const childrenIndicator = options.hasOwnProperty('children_indicator') ? options.children_indicator : false;
const childrenIndicator = Object.prototype.hasOwnProperty.call(options, 'children_indicator') ? options.children_indicator : false;

const prepareQuery = parent => {
const query = {};
@@ -1,7 +1,7 @@
'use strict';

function listPostsHelper(posts, options) {
if (!options && (!posts || !posts.hasOwnProperty('length'))) {
if (!options && (!posts || !Object.prototype.hasOwnProperty.call(posts, 'length'))) {
options = posts;
posts = this.site.posts;
}
@@ -1,7 +1,7 @@
'use strict';

function listTagsHelper(tags, options) {
if (!options && (!tags || !tags.hasOwnProperty('length'))) {
if (!options && (!tags || !Object.prototype.hasOwnProperty.call(tags, 'length'))) {
options = tags;
tags = this.site.tags;
}
@@ -10,7 +10,7 @@ function listTagsHelper(tags, options) {
options = options || {};

const { style = 'list', transform, separator = ', ', suffix = '' } = options;
const showCount = options.hasOwnProperty('show_count') ? options.show_count : true;
const showCount = Object.prototype.hasOwnProperty.call(options, 'show_count') ? options.show_count : true;
const className = options.class || 'tag';
const orderby = options.orderby || 'name';
const order = options.order || 1;
@@ -3,14 +3,14 @@
function paginatorHelper(options = {}) {
const current = options.current || this.page.current || 0;
const total = options.total || this.page.total || 1;
const endSize = options.hasOwnProperty('end_size') ? +options.end_size : 1;
const midSize = options.hasOwnProperty('mid_size') ? +options.mid_size : 2;
const endSize = Object.prototype.hasOwnProperty.call(options, 'end_size') ? +options.end_size : 1;
const midSize = Object.prototype.hasOwnProperty.call(options, 'mid_size') ? +options.mid_size : 2;
const { space = '&hellip;', transform } = options;
const base = options.base || this.page.base || '';
const format = options.format || `${this.config.pagination_dir}/%d/`;
const prevText = options.prev_text || 'Prev';
const nextText = options.next_text || 'Next';
const prevNext = options.hasOwnProperty('prev_next') ? options.prev_next : true;
const prevNext = Object.prototype.hasOwnProperty.call(options, 'prev_next') ? options.prev_next : true;

if (!current) return '';

@@ -158,7 +158,7 @@ const colorNames = {
};

function tagcloudHelper(tags, options) {
if (!options && (!tags || !tags.hasOwnProperty('length'))) {
if (!options && (!tags || !Object.prototype.hasOwnProperty.call(tags, 'length'))) {
options = tags;
tags = this.site.tags;
}
@@ -251,7 +251,7 @@ function Color(color) {
Color.prototype.parse = function(color) {
color = color.toLowerCase();

if (colorNames.hasOwnProperty(color)) {
if (Object.prototype.hasOwnProperty.call(colorNames, color)) {
const obj = colorNames[color];

this.r = obj.r;
@@ -7,14 +7,14 @@ function tocHelper(str, options = {}) {
if (!cheerio) cheerio = require('cheerio');

const $ = cheerio.load(str);
const headingsMaxDepth = options.hasOwnProperty('max_depth') ? options.max_depth : 6;
const headingsMaxDepth = Object.prototype.hasOwnProperty.call(options, 'max_depth') ? options.max_depth : 6;
const headingsSelector = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].slice(0, headingsMaxDepth).join(',');
const headings = $(headingsSelector);

if (!headings.length) return '';

const className = options.class || 'toc';
const listNumber = options.hasOwnProperty('list_number') ? options.list_number : true;
const listNumber = Object.prototype.hasOwnProperty.call(options, 'list_number') ? options.list_number : true;
let result = `<ol class="${className}">`;
const lastNumber = [0, 0, 0, 0, 0, 0];
let firstLevel = 0;
@@ -54,7 +54,7 @@ module.exports = ctx => {
data.slug = info.title;

if (file.params.published) {
if (!data.hasOwnProperty('published')) data.published = true;
if (!Object.prototype.hasOwnProperty.call(data, 'published')) data.published = true;
} else {
data.published = false;
}
@@ -67,7 +67,7 @@
"@easyops/git-exec-and-restage": "^1.0.4",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"eslint": "^5.9.0",
"eslint": "^6.0.1",
"eslint-ci": "^1.0.0",
"eslint-config-hexo": "^3.0.0",
"hexo-renderer-marked": "^1.0.1",
@@ -27,7 +27,7 @@ describe('paginator', () => {
const total = data.total;
const pages = data.pages;
const space = data.space || '&hellip;';
const prevNext = data.hasOwnProperty('prev_next') ? data.prev_next : true;
const prevNext = Object.prototype.hasOwnProperty.call(data, 'prev_next') ? data.prev_next : true;
let num;

if (prevNext && current > 1) {

0 comments on commit c2e4672

Please sign in to comment.
You can’t perform that action at this time.