--- a/src/eric7/Plugins/PluginSyntaxChecker.py Fri Nov 24 14:59:26 2023 +0100 +++ b/src/eric7/Plugins/PluginSyntaxChecker.py Sat Nov 25 18:19:21 2023 +0100 @@ -30,8 +30,8 @@ "packageName": "__core__", "shortDescription": "Show the Syntax Checker dialog.", "longDescription": ( - """This plugin implements the Syntax Checker dialog.""" - """ Syntax Checker is used to check Python source files for correct""" + """This plugin implements the Syntax Checker dialog. Syntax Checker is used""" + """ to check Python, JavaScript, JSON, TOML and YAML files for correct""" """ syntax.""" ), "pyqtApi": 2, @@ -50,7 +50,8 @@ """ Constructor - @param ui reference to the user interface object (UI.UserInterface) + @param ui reference to the user interface object + @type UI.UserInterface """ from eric7.Plugins.CheckerPlugins.SyntaxChecker.SyntaxCheckService import ( SyntaxCheckService, @@ -120,6 +121,20 @@ self.syntaxCheckService.serviceErrorTOML, ) + # JavaScript syntax check via Python3 + self.syntaxCheckService.addLanguage( + "JavaScript", + "Python3", + path, + "jsCheckSyntax", + lambda: [], # No options + lambda: [".js"], + lambda fn, problems: self.syntaxCheckService.syntaxChecked.emit( + fn, problems + ), + self.syntaxCheckService.serviceErrorJavaScript, + ) + def __initialize(self): """ Private slot to (re)initialize the plugin. @@ -155,11 +170,15 @@ the warnings (marker, file name, line number, message) The values are only valid, if nok is False. - @param fn filename of the checked file (str) - @param problems dictionary with the keys 'error' and 'warnings' which - hold a list containing details about the error/ warnings - (file name, line number, column, codestring (only at syntax - errors), the message, a list with arguments for the message) + @param fn filename of the checked file + @type str + @param problems list of dictionaries with the keys 'error', 'py_warnings' and + 'warnings' which contain a tuple with details about the syntax error or a + list of tuples with details about Python warnings and PyFlakes warnings. + Each tuple contains the file name, line number, column, code string (only + for syntax errors), the message and an optional list with arguments for + the message. + @type list of dict """ from eric7.Plugins.CheckerPlugins.SyntaxChecker.pyflakes.translations import ( getTranslatedFlakesMessage, @@ -178,7 +197,8 @@ """ Public method to activate this plugin. - @return tuple of None and activation status (boolean) + @return tuple of None and activation status + @rtype bool """ menu = ericApp().getObject("Project").getMenu("Checks") if menu: @@ -259,8 +279,10 @@ Private slot called, when the the project menu or a submenu is about to be shown. - @param menuName name of the menu to be shown (string) - @param menu reference to the menu (QMenu) + @param menuName name of the menu to be shown + @type str + @param menu reference to the menu + @type QMenu """ if menuName == "Checks" and self.__projectAct is not None: self.__projectAct.setEnabled( @@ -273,8 +295,10 @@ Private slot called, when the the project browser menu or a submenu is about to be shown. - @param menuName name of the menu to be shown (string) - @param menu reference to the menu (QMenu) + @param menuName name of the menu to be shown + @type str + @param menu reference to the menu + @type QMenu """ if ( menuName == "Checks" @@ -350,7 +374,8 @@ """ Private slot called, when a new editor was opened. - @param editor reference to the new editor (QScintilla.Editor) + @param editor reference to the new editor + @type QScintilla.Editor """ menu = editor.getMenu("Checks") if menu is not None: @@ -362,7 +387,8 @@ """ Private slot called, when an editor was closed. - @param editor reference to the editor (QScintilla.Editor) + @param editor reference to the editor + @type QScintilla.Editor """ with contextlib.suppress(ValueError): self.__editors.remove(editor) @@ -372,9 +398,12 @@ Private slot called, when the the editor context menu or a submenu is about to be shown. - @param menuName name of the menu to be shown (string) - @param menu reference to the menu (QMenu) + @param menuName name of the menu to be shown + @type str + @param menu reference to the menu + @type QMenu @param editor reference to the editor + @type QScintilla.Editor """ if menuName == "Checks": if self.__editorAct not in menu.actions():