From 4ad53930eef335ab866bec6656760e2d40723f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=B4=8D=C9=AA=E1=B4=8D=C9=AA?= <1119186082@qq.com> Date: Thu, 1 Aug 2019 11:53:45 +0800 Subject: [PATCH] Refactor lint / tests / bower (#1041) --- .bowerrc | 3 - .editorconfig | 3 - .jshintrc | 3 - bower.json | 30 ---------- gulpfile.coffee | 11 ++-- package.json | 5 +- source/js/exturl.js | 4 +- source/js/scrollspy.js | 12 ++-- test/.jshintrc | 23 ------- test/helpers.js | 133 ----------------------------------------- test/intern.js | 65 -------------------- 11 files changed, 15 insertions(+), 277 deletions(-) delete mode 100644 .bowerrc delete mode 100644 .jshintrc delete mode 100644 bower.json delete mode 100644 test/.jshintrc delete mode 100644 test/helpers.js delete mode 100644 test/intern.js diff --git a/.bowerrc b/.bowerrc deleted file mode 100644 index 8013f263db..0000000000 --- a/.bowerrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "directory": "source/lib" -} diff --git a/.editorconfig b/.editorconfig index f0627b937b..2305854a4d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,6 +9,3 @@ insert_final_newline = true trim_trailing_whitespace = true indent_style = space indent_size = 2 - -[*.py] -indent_size = 4 diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 2b6f469f0c..0000000000 --- a/.jshintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "esversion": 6 -} diff --git a/bower.json b/bower.json deleted file mode 100644 index 8769e8e18c..0000000000 --- a/bower.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "theme-next", - "version": "7.3.0", - "homepage": "https://theme-next.org", - "authors": [ - "NexT (https://theme-next.org)" - ], - "description": "Elegant theme for Hexo", - "repository": "https://github.com/theme-next/hexo-theme-next", - "keywords": [ - "hexo", - "theme", - "next" - ], - "license": "AGPL", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "source/lib", - "test", - "tests", - "screenshots" - ], - "dependencies": { - "font-awesome": "fontawesome#*", - "jquery": "https://code.jquery.com/jquery-3.4.1.min.js", - "velocity": "~1.2.1" - } -} diff --git a/gulpfile.coffee b/gulpfile.coffee index fa16b09a96..e80865f978 100644 --- a/gulpfile.coffee +++ b/gulpfile.coffee @@ -1,9 +1,8 @@ fs = require('fs') path = require('path') gulp = require('gulp') -jshint = require('gulp-jshint') -stylish = require('jshint-stylish') -shell = require('gulp-shell') +eslint = require('gulp-eslint') +shell = require('gulp-shell') yaml = require('js-yaml') gulp.task 'lint', -> @@ -21,8 +20,8 @@ gulp.task 'lint', -> './source/js/utils.js', './source/js/schemes/muse.js', './source/js/schemes/pisces.js' - ]).pipe jshint() - .pipe jshint.reporter(stylish) + ]).pipe eslint() + .pipe eslint.format() gulp.task 'lint:stylus', shell.task [ '"./node_modules/.bin/stylint" ./source/css/' @@ -57,4 +56,4 @@ gulp.task 'validate:languages', (cb) -> cb(errors) -gulp.task 'default', gulp.parallel('lint', 'validate:config', 'validate:languages') +gulp.task 'default', gulp.series('lint', 'validate:config', 'validate:languages') diff --git a/package.json b/package.json index 2e7c604e45..19a31253d9 100644 --- a/package.json +++ b/package.json @@ -30,12 +30,11 @@ "all-contributors-cli": "^6.8.1", "coffeescript": "^2.4.1", "eslint": "^6.1.0", + "eslint-config-theme-next": "^1.1.0", "gulp": "^4.0.2", - "gulp-jshint": "^2.1.0", + "gulp-eslint": "^6.0.0", "gulp-shell": "^0.7.1", "js-yaml": "^3.13.1", - "jshint": "^2.10.2", - "jshint-stylish": "^2.2.1", "stylint": "^2.0.0" } } diff --git a/source/js/exturl.js b/source/js/exturl.js index 2f2f1fcff1..2397155480 100644 --- a/source/js/exturl.js +++ b/source/js/exturl.js @@ -1,9 +1,9 @@ +/* eslint-disable */ + $(document).ready(function() { // Create Base64 Object - /* jshint ignore:start*/ var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(e){var t="";var n,r,i,s,o,u,a;var f=0;e=Base64._utf8_encode(e);while(f>2;o=(n&3)<<4|r>>4;u=(r&15)<<2|i>>6;a=i&63;if(isNaN(r)){u=a=64}else if(isNaN(i)){a=64}t=t+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u)+this._keyStr.charAt(a)}return t},decode:function(e){var t="";var n,r,i;var s,o,u,a;var f=0;e=e.replace(/[^A-Za-z0-9+/=]/g,"");while(f>4;r=(o&15)<<4|u>>2;i=(u&3)<<6|a;t=t+String.fromCharCode(n);if(u!=64){t=t+String.fromCharCode(r)}if(a!=64){t=t+String.fromCharCode(i)}}t=Base64._utf8_decode(t);return t},_utf8_encode:function(e){e=e.replace(/rn/g,"n");var t="";for(var n=0;n127&&r<2048){t+=String.fromCharCode(r>>6|192);t+=String.fromCharCode(r&63|128)}else{t+=String.fromCharCode(r>>12|224);t+=String.fromCharCode(r>>6&63|128);t+=String.fromCharCode(r&63|128)}}return t},_utf8_decode:function(e){var t="";var n=0;var r=c1=c2=0;while(n191&&r<224){c2=e.charCodeAt(n+1);t+=String.fromCharCode((r&31)<<6|c2&63);n+=2}else{c2=e.charCodeAt(n+1);c3=e.charCodeAt(n+2);t+=String.fromCharCode((r&15)<<12|(c2&63)<<6|c3&63);n+=3}}return t}}; - /* jshint ignore:end */ $('.exturl').on('click', function() { var $exturl = $(this).attr('data-url'); var $decurl = Base64.decode($exturl); diff --git a/source/js/scrollspy.js b/source/js/scrollspy.js index be16bf0f8f..e6d7c53bcc 100644 --- a/source/js/scrollspy.js +++ b/source/js/scrollspy.js @@ -1,10 +1,10 @@ /* ======================================================================== -* Bootstrap: scrollspy.js v3.3.2 -* http://getbootstrap.com/javascript/#scrollspy -* ======================================================================== -* Copyright 2011-2015 Twitter, Inc. -* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) -* ======================================================================== */ + * Bootstrap: scrollspy.js v3.3.2 + * http://getbootstrap.com/javascript/#scrollspy + * ======================================================================== + * Copyright 2011-2015 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + * ======================================================================== */ /** * Customized by iissnan & Ivan.Nginx diff --git a/test/.jshintrc b/test/.jshintrc deleted file mode 100644 index 038a8b017f..0000000000 --- a/test/.jshintrc +++ /dev/null @@ -1,23 +0,0 @@ -{ - "curly": true, - "eqnull": true, - "eqeqeq": true, - "undef": true, - "newcap": true, - "unused": true, - "laxcomma": false, - "asi": false, - "expr": true, - "loopfunc": false, - "strict": false, - - "globals": { - "define": true, - "require": true, - "it": true, - "module": true, - "describe": true, - "window": true, - "$": true - } -} diff --git a/test/helpers.js b/test/helpers.js deleted file mode 100644 index 83f51d044c..0000000000 --- a/test/helpers.js +++ /dev/null @@ -1,133 +0,0 @@ -define([ - 'intern!object', - 'intern/chai!assert', - 'intern/order!source/js/helpers.js' -], function (registerSuite, assert) { - registerSuite({ - name: 'helpers', - - beforeEach: function () { - window = { - navigator: { - userAgent: '' - } - }; - screen = { - width: 0 - }; - - minic = { - desktop: function (screenWidth) { - window.navigator.userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36'; - screen.width = screenWidth || 992; - }, - tablet: function (screenWidth) { - window.navigator.userAgent = 'Mozilla/5.0 (iPad; CPU OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5'; - screen.width = screenWidth || 750; - }, - mobile: function (screenWidth) { - window.navigator.userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4'; - screen.width = screenWidth || 767; - } - }; - }, - - '#hasMobileUA': { - 'should be true': function () { - minic.mobile(); - assert.isTrue( hasMobileUA() ); - minic.tablet(); - assert.isTrue( hasMobileUA() ); - }, - - 'should be false': function () { - minic.desktop(); - assert.isFalse( hasMobileUA() ); - } - }, - - - '#isDesktop': { - 'should be true': function () { - minic.desktop(992); - assert.isTrue( isDesktop() ); - - minic.desktop(1200); - assert.isTrue( isDesktop() ); - }, - 'should be false': function () { - minic.mobile(); - assert.isFalse( isDesktop() ); - - minic.tablet(992); - assert.isFalse( isDesktop() ); - } - }, - - '#isTablet': { - 'should be true': function () { - minic.tablet(900); - assert.isTrue( isTablet() ); - - minic.tablet(780); - assert.isTrue( isTablet() ); - }, - 'should be false': function () { - minic.desktop(500); - assert.isFalse( isTablet() ); - - minic.tablet(1000); - assert.isFalse( isTablet() ); - - minic.tablet(500); - assert.isFalse( isTablet() ); - } - }, - - '#isMobile': { - 'should be true': function () { - minic.mobile(); - assert.isTrue( isMobile() ); - - minic.mobile(700); - assert.isTrue( isMobile() ); - }, - 'should be false': function () { - minic.desktop(); - assert.isFalse( isMobile() ); - - minic.tablet(); - assert.isFalse( isMobile() ); - - minic.mobile(1000); - assert.isFalse( isMobile() ); - } - }, - - '#escapeSelector': function () { - var selectors = ['(something', '.something', '$something']; - selectors.forEach(function (s) { - assert.equal( escapeSelector(s), '\\' + s ); - }); - }, - - '#displaySidebar': function () {}, - - '#isMist': { - beforeEach: function () { - CONFIG = { - scheme: '' - }; - }, - 'should be true': function () { - CONFIG.scheme = 'Mist'; - assert.isTrue( isMist() ); - }, - 'should be false': function () { - CONFIG.scheme = 'Minimal'; - assert.isFalse( isMist() ); - } - } - - }); -}); diff --git a/test/intern.js b/test/intern.js deleted file mode 100644 index db115c76ab..0000000000 --- a/test/intern.js +++ /dev/null @@ -1,65 +0,0 @@ -// Learn more about configuring this file at . -// These default settings work OK for most people. The options that *must* be changed below are the -// packages, suites, excludeInstrumentation, and (if you want functional tests) functionalSuites. -define({ - // The port on which the instrumenting proxy will listen - proxyPort: 9000, - - // A fully qualified URL to the Intern proxy - proxyUrl: 'http://localhost:9000/', - - // Default desired capabilities for all environments. Individual capabilities can be overridden by any of the - // specified browser environments in the `environments` array below as well. See - // https://code.google.com/p/selenium/wiki/DesiredCapabilities for standard Selenium capabilities and - // https://saucelabs.com/docs/additional-config#desired-capabilities for Sauce Labs capabilities. - // Note that the `build` capability will be filled in with the current commit ID from the Travis CI environment - // automatically - capabilities: { - 'selenium-version': '2.41.0' - }, - - // Browsers to run integration testing against. Note that version numbers must be strings if used with Sauce - // OnDemand. Options that will be permutated are browserName, version, platform, and platformVersion; any other - // capabilities options specified for an environment will be copied as-is - environments: [ - { browserName: 'internet explorer', version: '11', platform: 'Windows 8.1' }, - { browserName: 'internet explorer', version: '10', platform: 'Windows 8' }, - { browserName: 'internet explorer', version: '9', platform: 'Windows 7' }, - { browserName: 'firefox', version: '28', platform: [ 'OS X 10.9', 'Windows 7', 'Linux' ] }, - { browserName: 'chrome', version: '34', platform: [ 'OS X 10.9', 'Windows 7', 'Linux' ] }, - { browserName: 'safari', version: '6', platform: 'OS X 10.8' }, - { browserName: 'safari', version: '7', platform: 'OS X 10.9' } - ], - - // Maximum number of simultaneous integration tests that should be executed on the remote WebDriver service - maxConcurrency: 3, - - // Name of the tunnel class to use for WebDriver tests - tunnel: 'SauceLabsTunnel', - - // The desired AMD loader to use when running unit tests (client.html/client.js). Omit to use the default Dojo - // loader - useLoader: { - 'host-node': 'dojo/dojo', - 'host-browser': 'node_modules/dojo/dojo.js' - }, - - // Configuration options for the module loader; any AMD configuration options supported by the specified AMD loader - // can be used here - loader: { - // Packages that should be registered with the loader in each testing environment - packages: [ { name: 'next', location: '.' } ] - }, - - // Non-functional test suite(s) to run in each browser - suites: [ - /* 'myPackage/tests/foo', 'myPackage/tests/bar' */ - 'tests/helpers' - ], - - // Functional test suite(s) to run in each browser once non-functional tests are completed - functionalSuites: [ /* 'myPackage/tests/functional' */ ], - - // A regular expression matching URLs to files that should not be included in code coverage analysis - excludeInstrumentation: /^(?:tests|node_modules)\// -});