Replace jshint by eslint

Closes #13087
(grafted from b2a2c9483562f6ae5430df5cc957148003ac3520)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier
2024-03-26 00:10:10 +01:00
parent 91ed58951b
commit 06c3363a30
8 changed files with 71 additions and 40 deletions
+15
View File
@@ -100,6 +100,21 @@ check-dist:
script:
- twine check packages/*
check-eslint:
extends: .check
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/node
variables:
NODE_CACHE_DIR: "$CI_PROJECT_DIR/.cache/npm"
cache:
paths:
- .cache/npm
before_script:
- sh .gitlab-scripts/bower_allow_root.sh
script:
- cd sao
- npm install --cache ${NODE_CACHE_DIR} --unsafe-perm --legacy-peer-deps
- npm run check
check-ci-modules:
extends: .check
script:
+4 -22
View File
@@ -74,23 +74,6 @@ module.exports = function(grunt) {
dest: 'dist/<%= pkg.name %>.js'
}
},
jshint: {
dist: {
options: {
jshintrc: 'src/.jshintrc'
},
src: ['dist/<%= pkg.name %>.js']
},
grunt: {
src: ['Gruntfile.js']
},
tests: {
options: {
jshintrc: 'tests/.jshintrc'
},
src: ['tests/*.js']
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %>-<%= pkg.version %> | GPL-3\n' +
@@ -126,7 +109,7 @@ module.exports = function(grunt) {
watch: {
scripts: {
files: ['src/**/*.js'],
tasks: ['concat', 'jshint']
tasks: ['concat']
},
styles: {
files: ['src/*.less'],
@@ -151,16 +134,15 @@ module.exports = function(grunt) {
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-po2json');
grunt.registerTask('default', 'Build for production.', function() {
grunt.task.run(['concat', 'jshint', 'uglify', 'less', 'po2json']);
grunt.task.run(['concat', 'uglify', 'less', 'po2json']);
});
grunt.registerTask('dev', 'Build for development.', function() {
grunt.task.run(['concat', 'jshint', 'less:dev']);
grunt.task.run(['concat', 'less:dev']);
});
grunt.registerTask('devwatch', 'Watch development', function() {
grunt.loadNpmTasks('grunt-contrib-watch');
@@ -176,7 +158,7 @@ module.exports = function(grunt) {
});
grunt.registerTask('test', 'Run tests', function() {
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.task.run(['concat', 'jshint', 'less:dev', 'qunit']);
grunt.task.run(['concat', 'less:dev', 'qunit']);
});
};
+44
View File
@@ -0,0 +1,44 @@
import js from "@eslint/js";
import globals from "globals";
export default [
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 6,
sourceType: "script",
globals: {
Mousetrap: "readonly",
Papa: "readonly",
QUnit: "readonly",
Sao: "readonly",
Sortable: "readonly",
c3: "readonly",
i18n: "readonly",
jQuery: "readonly",
moment: "readonly",
...globals.browser
},
},
rules: {
"getter-return": "off",
"no-constant-condition": "off",
"no-empty": "off",
"no-extra-boolean-cast": "off",
"no-prototype-builtins": "off",
"no-self-assign": "off",
"no-unexpected-multiline": "off",
"no-unused-vars": "off",
"no-useless-escape": "off",
"no-with": "off",
},
}, {
files: ['tests/**/*.js'],
languageOptions: {
globals: {
Sao: "readonly",
eval_pyson: "readonly",
},
},
},
];
+3 -1
View File
@@ -33,9 +33,12 @@
],
"scripts": {
"test": "npx grunt test",
"check": "npx eslint src tests",
"postinstall": "npx bower install"
},
"devDependencies": {
"eslint": "^8.57.0",
"globals": "^14.0.0",
"grunt-contrib-nodeunit": "^2.0",
"grunt-contrib-qunit": "^3.1",
"grunt-contrib-watch": "^1.1",
@@ -51,7 +54,6 @@
"grunt": "^1.0",
"grunt-cli": "^1.3",
"grunt-contrib-concat": "^1.0",
"grunt-contrib-jshint": "^2.1",
"grunt-contrib-less": "^2.0",
"grunt-contrib-uglify": "^4.0"
}
-5
View File
@@ -1,5 +0,0 @@
{
"browser": true,
"devel": true,
"jquery": true
}
+5 -2
View File
@@ -1,6 +1,9 @@
/* This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. */
/* eslint-disable no-redeclare */
var Sao = {};
/* eslint-enable no-redeclare */
(function() {
'use strict';
@@ -1105,7 +1108,7 @@ var Sao = {};
if (definition.id){
var current_tab = Sao.Tab.tabs.get_current();
if (current_tab) {
var focused = $(':focus');
var focused = jQuery(':focus');
focused.blur();
current_tab.el.find('a[id="' + definition.id + '"]').click();
focused.focus();
@@ -1177,7 +1180,7 @@ var Sao = {};
.on('hidden.bs.modal', '.modal', function(event) {
setModalsAndBackdropsOrder();
if (jQuery('.modal:visible').length) {
$(document.body).addClass('modal-open');
jQuery(document.body).addClass('modal-open');
}
});
-2
View File
@@ -1,7 +1,6 @@
/* This file is part of Tryton. The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. */
/* jshint ignore:start */
// Must be defined in non strict context otherwise is invalid
function eval_pyson(value){
with (Sao.PYSON.eval) {
@@ -9,7 +8,6 @@ function eval_pyson(value){
return eval('(' + value + ')');
}
}
/* jshint ignore:end */
(function() {
'use strict';
-8
View File
@@ -1,8 +0,0 @@
{
"browser": true,
"jquery": true,
"predef": [
"QUnit",
"Sao"
]
}