Skip to content

Commit

Permalink
chore(deps-dev): update eslint requirement from ^5.9.0 to ^6.0.1 (#3606)
Browse files Browse the repository at this point in the history
* 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 c2e4672
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/hexo/render.js
Expand Up @@ -112,7 +112,7 @@ Render.prototype.renderSync = function(data, options) {
}; };


function toString(result, 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') { if (typeof options.toString === 'function') {
return options.toString(result); return options.toString(result);
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/filter/post_permalink.js
Expand Up @@ -35,7 +35,7 @@ function postPermalinkFilter(data) {


for (let i = 0, len = keys.length; i < len; i++) { for (let i = 0, len = keys.length; i < len; i++) {
const key = keys[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 // Use Object.getOwnPropertyDescriptor to copy getters to avoid "Maximum call
// stack size exceeded" error // stack size exceeded" error
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/helper/list_archives.js
Expand Up @@ -8,7 +8,7 @@ function listArchivesHelper(options = {}) {
let { format } = options; let { format } = options;
const type = options.type || 'monthly'; const type = options.type || 'monthly';
const { style = 'list', transform, separator = ', ' } = options; 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 className = options.class || 'archive';
const order = options.order || -1; const order = options.order || -1;
let result = ''; let result = '';
Expand Down
6 changes: 3 additions & 3 deletions lib/plugins/helper/list_categories.js
@@ -1,7 +1,7 @@
'use strict'; 'use strict';


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


const { style = 'list', transform, separator = ', ', suffix = '' } = 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 className = options.class || 'category';
const depth = options.depth ? parseInt(options.depth, 10) : 0; const depth = options.depth ? parseInt(options.depth, 10) : 0;
const orderby = options.orderby || 'name'; const orderby = options.orderby || 'name';
const order = options.order || 1; const order = options.order || 1;
const showCurrent = options.show_current || false; 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 prepareQuery = parent => {
const query = {}; const query = {};
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/helper/list_posts.js
@@ -1,7 +1,7 @@
'use strict'; 'use strict';


function listPostsHelper(posts, options) { function listPostsHelper(posts, options) {
if (!options && (!posts || !posts.hasOwnProperty('length'))) { if (!options && (!posts || !Object.prototype.hasOwnProperty.call(posts, 'length'))) {
options = posts; options = posts;
posts = this.site.posts; posts = this.site.posts;
} }
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/helper/list_tags.js
@@ -1,7 +1,7 @@
'use strict'; 'use strict';


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


const { style = 'list', transform, separator = ', ', suffix = '' } = 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 className = options.class || 'tag';
const orderby = options.orderby || 'name'; const orderby = options.orderby || 'name';
const order = options.order || 1; const order = options.order || 1;
Expand Down
6 changes: 3 additions & 3 deletions lib/plugins/helper/paginator.js
Expand Up @@ -3,14 +3,14 @@
function paginatorHelper(options = {}) { function paginatorHelper(options = {}) {
const current = options.current || this.page.current || 0; const current = options.current || this.page.current || 0;
const total = options.total || this.page.total || 1; const total = options.total || this.page.total || 1;
const endSize = options.hasOwnProperty('end_size') ? +options.end_size : 1; const endSize = Object.prototype.hasOwnProperty.call(options, 'end_size') ? +options.end_size : 1;
const midSize = options.hasOwnProperty('mid_size') ? +options.mid_size : 2; const midSize = Object.prototype.hasOwnProperty.call(options, 'mid_size') ? +options.mid_size : 2;
const { space = '&hellip;', transform } = options; const { space = '&hellip;', transform } = options;
const base = options.base || this.page.base || ''; const base = options.base || this.page.base || '';
const format = options.format || `${this.config.pagination_dir}/%d/`; const format = options.format || `${this.config.pagination_dir}/%d/`;
const prevText = options.prev_text || 'Prev'; const prevText = options.prev_text || 'Prev';
const nextText = options.next_text || 'Next'; 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 ''; if (!current) return '';


Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/helper/tagcloud.js
Expand Up @@ -158,7 +158,7 @@ const colorNames = {
}; };


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


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


this.r = obj.r; this.r = obj.r;
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/helper/toc.js
Expand Up @@ -7,14 +7,14 @@ function tocHelper(str, options = {}) {
if (!cheerio) cheerio = require('cheerio'); if (!cheerio) cheerio = require('cheerio');


const $ = cheerio.load(str); 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 headingsSelector = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].slice(0, headingsMaxDepth).join(',');
const headings = $(headingsSelector); const headings = $(headingsSelector);


if (!headings.length) return ''; if (!headings.length) return '';


const className = options.class || 'toc'; 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}">`; let result = `<ol class="${className}">`;
const lastNumber = [0, 0, 0, 0, 0, 0]; const lastNumber = [0, 0, 0, 0, 0, 0];
let firstLevel = 0; let firstLevel = 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/processor/post.js
Expand Up @@ -54,7 +54,7 @@ module.exports = ctx => {
data.slug = info.title; data.slug = info.title;


if (file.params.published) { if (file.params.published) {
if (!data.hasOwnProperty('published')) data.published = true; if (!Object.prototype.hasOwnProperty.call(data, 'published')) data.published = true;
} else { } else {
data.published = false; data.published = false;
} }
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -67,7 +67,7 @@
"@easyops/git-exec-and-restage": "^1.0.4", "@easyops/git-exec-and-restage": "^1.0.4",
"chai": "^4.1.2", "chai": "^4.1.2",
"chai-as-promised": "^7.1.1", "chai-as-promised": "^7.1.1",
"eslint": "^5.9.0", "eslint": "^6.0.1",
"eslint-ci": "^1.0.0", "eslint-ci": "^1.0.0",
"eslint-config-hexo": "^3.0.0", "eslint-config-hexo": "^3.0.0",
"hexo-renderer-marked": "^1.0.1", "hexo-renderer-marked": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion test/scripts/helpers/paginator.js
Expand Up @@ -27,7 +27,7 @@ describe('paginator', () => {
const total = data.total; const total = data.total;
const pages = data.pages; const pages = data.pages;
const space = data.space || '&hellip;'; 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; let num;


if (prevNext && current > 1) { if (prevNext && current > 1) {
Expand Down

0 comments on commit c2e4672

Please sign in to comment.