[mod] simple theme - add ESLint

[1] https://eslint.org/
[2] https://eslint.org/docs/user-guide/configuring/
[3] https://eslint.org/docs/user-guide/command-line-interface

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
Markus Heiser 2021-08-01 16:04:19 +02:00
parent 1e942435be
commit 2948a99b6e
5 changed files with 33 additions and 3 deletions

View file

@ -91,9 +91,9 @@
(js-mode (js-mode
. ((eval . (progn . ((eval . (progn
(setq-local js-indent-level 2) (setq-local js-indent-level 2)
;; flycheck should use the jshint checker from simple theme ;; flycheck should use the eslint checker from simple theme
(setq-local flycheck-javascript-jshint-executable (setq-local flycheck-javascript-eslint-executable
(expand-file-name "searx/static/themes/simple/node_modules/.bin/jshint" prj-root)) (expand-file-name "searx/static/themes/simple/node_modules/.bin/eslint" prj-root))
(flycheck-mode) (flycheck-mode)
)))) ))))

2
manage
View file

@ -665,6 +665,8 @@ themes.oscar() {
themes.simple() { themes.simple() {
build_msg GRUNT "theme: simple" build_msg GRUNT "theme: simple"
npm --prefix searx/static/themes/simple run build npm --prefix searx/static/themes/simple run build
# just report eslint issues but do not break the build (--force)
npm --prefix searx/static/themes/simple run eslint --force
dump_return $? dump_return $?
} }

View file

@ -0,0 +1,13 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
}
}

View file

@ -15,6 +15,16 @@ module.exports = function(grunt) {
jshint: { jshint: {
files: ['src/js/main/*.js', 'src/js/head/*.js', '../__common__/js/*.js'], files: ['src/js/main/*.js', 'src/js/head/*.js', '../__common__/js/*.js'],
}, },
eslint: {
options: {
configFile: '.eslintrc.json'
},
target: [
'src/js/main/*.js',
'src/js/head/*.js',
'../__common__/js/*.js'
],
},
stylelint: { stylelint: {
options: { options: {
formatter: 'unix', formatter: 'unix',
@ -189,10 +199,12 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-webfont'); grunt.loadNpmTasks('grunt-webfont');
grunt.loadNpmTasks('grunt-stylelint'); grunt.loadNpmTasks('grunt-stylelint');
grunt.loadNpmTasks('grunt-eslint');
grunt.registerTask('test', ['jshint']); grunt.registerTask('test', ['jshint']);
grunt.registerTask('default', [ grunt.registerTask('default', [
// 'eslint',
'jshint', 'jshint',
'stylelint', 'stylelint',
'copy', 'copy',

View file

@ -1,5 +1,6 @@
{ {
"devDependencies": { "devDependencies": {
"eslint": "^7.32.0",
"grunt-cli": "^1.4.3", "grunt-cli": "^1.4.3",
"grunt": "~1.4.1", "grunt": "~1.4.1",
"grunt-contrib-copy": "^1.0.0", "grunt-contrib-copy": "^1.0.0",
@ -10,6 +11,7 @@
"grunt-contrib-uglify": "~5.0.1", "grunt-contrib-uglify": "~5.0.1",
"grunt-contrib-watch": "~1.1.0", "grunt-contrib-watch": "~1.1.0",
"grunt-stylelint": "^0.16.0", "grunt-stylelint": "^0.16.0",
"grunt-eslint": "^23.0.0",
"grunt-webfont": "^1.7.2", "grunt-webfont": "^1.7.2",
"ionicons-npm": "^2.0.1", "ionicons-npm": "^2.0.1",
"jslint": "^0.12.1", "jslint": "^0.12.1",
@ -26,6 +28,7 @@
"scripts": { "scripts": {
"all": "npm install && grunt", "all": "npm install && grunt",
"build": "grunt", "build": "grunt",
"eslint": "grunt eslint",
"watch": "grunt watch", "watch": "grunt watch",
"webfont": "grunt webfont", "webfont": "grunt webfont",
"clean": "rm -Rf node_modules package-lock.json ion.less", "clean": "rm -Rf node_modules package-lock.json ion.less",