diff options
| author | Markus Heiser <markus.heiser@darmarIT.de> | 2021-12-14 08:07:22 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-14 08:07:22 +0100 |
| commit | 4f22615259fc4a9fb80b47ad5b4bcd17f994bc68 (patch) | |
| tree | 15bcc625b749b3434576837414c66e7cab9d31b8 /searx/static/themes/simple/gruntfile.js | |
| parent | 5c7167cd5af2c18826595bfff877766dab4b44ca (diff) | |
| parent | f287787c44956a6584f78fdd9d6bf423384d1643 (diff) | |
Merge pull request #538 from return42/eslint
SearXNG JavaScript Style Guide
Diffstat (limited to 'searx/static/themes/simple/gruntfile.js')
| -rw-r--r-- | searx/static/themes/simple/gruntfile.js | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/searx/static/themes/simple/gruntfile.js b/searx/static/themes/simple/gruntfile.js index 84f051f23..46ab657e0 100644 --- a/searx/static/themes/simple/gruntfile.js +++ b/searx/static/themes/simple/gruntfile.js @@ -1,6 +1,6 @@ -/*jshint esversion: 6 */ +/* SPDX-License-Identifier: AGPL-3.0-or-later */ -module.exports = function(grunt) { +module.exports = function (grunt) { const eachAsync = require('each-async'); @@ -27,9 +27,11 @@ module.exports = function(grunt) { eslint: { options: { overrideConfigFile: '.eslintrc.json', - failOnError: false + failOnError: true, + fix: grunt.option('fix') }, target: [ + 'gruntfile.js', 'svg4web.svgo.js', 'src/js/main/*.js', 'src/js/head/*.js', @@ -111,7 +113,7 @@ module.exports = function(grunt) { new (require('less-plugin-clean-css'))() ], sourceMap: true, - sourceMapURL: (name) => { const s = name.split('/'); return s[s.length - 1] + '.map';}, + sourceMapURL: (name) => { const s = name.split('/'); return s[s.length - 1] + '.map'; }, outputSourceFiles: true, }, files: { @@ -176,37 +178,37 @@ module.exports = function(grunt) { }, }); - grunt.registerMultiTask('svg2jinja', 'Create Jinja2 macro', function() { + grunt.registerMultiTask('svg2jinja', 'Create Jinja2 macro', function () { const ejs = require('ejs'), svgo = require('svgo'); const icons = {} - for(const iconName in this.data.src) { - const svgFileName = this.data.src[iconName]; - try { - const svgContent = grunt.file.read(svgFileName, { encoding: 'utf8' }) - const svgoResult = svgo.optimize(svgContent, { - path: svgFileName, - multipass: true, - plugins: [ - { - name: "removeTitle", - }, - { - name: "removeXMLNS", - }, - { - name: "addAttributesToSVGElement", - params: { - attributes: [ - { "aria-hidden": "true" } - ] - } - } - ] - }); - icons[iconName] = svgoResult.data.replace("'", "\\'"); - } catch (err) { - grunt.log.error(err); - } + for (const iconName in this.data.src) { + const svgFileName = this.data.src[iconName]; + try { + const svgContent = grunt.file.read(svgFileName, { encoding: 'utf8' }) + const svgoResult = svgo.optimize(svgContent, { + path: svgFileName, + multipass: true, + plugins: [ + { + name: "removeTitle", + }, + { + name: "removeXMLNS", + }, + { + name: "addAttributesToSVGElement", + params: { + attributes: [ + { "aria-hidden": "true" } + ] + } + } + ] + }); + icons[iconName] = svgoResult.data.replace("'", "\\'"); + } catch (err) { + grunt.log.error(err); + } } const template = `{# this file was generated by searx/static/themes/simple/gruntfile.js #} {%- set icons = { @@ -266,13 +268,12 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-image'); - grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-less'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-stylelint'); grunt.loadNpmTasks('grunt-eslint'); - grunt.registerTask('test', ['jshint']); + grunt.registerTask('test', ['eslint']); grunt.registerTask('default', [ 'eslint', |