Skip to content

run jslint/jshint/eslint on submitted source code #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pdawyndt opened this issue Aug 1, 2019 · 8 comments
Open

run jslint/jshint/eslint on submitted source code #20

pdawyndt opened this issue Aug 1, 2019 · 8 comments
Labels

Comments

@pdawyndt
Copy link
Contributor

pdawyndt commented Aug 1, 2019

Report on an evaluation of jslint/jshint of the submitted source code.

Original issue by @pdawyndt on Wed Apr 26 2017 at 22:12.

@bmesuere
Copy link
Member

bmesuere commented Aug 1, 2019

for modern JS code, I recommend ESlint: http://eslint.org/

Original comment by @bmesuere on Thu Apr 27 2017 at 10:45.

@pdawyndt
Copy link
Contributor Author

pdawyndt commented Aug 1, 2019

discussion on stackoverflow that also mentions bart's recommendation

Original comment by @pdawyndt on Thu Apr 27 2017 at 15:34.

@pdawyndt
Copy link
Contributor Author

pdawyndt commented Aug 1, 2019

ESLint support has been added to the JavaScript judge. This requires the ESLint API to be available in the runtime environment.

@dmouriss @ninewise Could any one install the ESLint API in the JavaScript docker. This should do it:

npm install eslint --save-dev

To check successful installation, you can execute the following JavaScript statement

var linter = require("eslint").linter;

Original comment by @pdawyndt on Sat Apr 29 2017 at 12:14.

@pdawyndt
Copy link
Contributor Author

pdawyndt commented Aug 1, 2019

ESLint might need some tweeking in the future, since it's rules are heavily configurable. See "Configuring ESLint" for more information about the configuration of ESLint. See Rules for a complete overview of all ESLint rules.

The configuration settings for ESLint are in the JSON file config.eslint.json.

Original comment by @pdawyndt on Sat Apr 29 2017 at 12:17.

@pdawyndt
Copy link
Contributor Author

pdawyndt commented Aug 1, 2019

Support for linting (based on ESLint) has been implemented. Awaits installation of the ESLint API in the JavaScript docker before being deployed.

Original comment by @pdawyndt on Sat Apr 29 2017 at 14:04.

@dmouriss
Copy link
Collaborator

dmouriss commented Aug 1, 2019

Eslint has been installed through npm in the docker, however it is possible an init script needs to be executed before it can be used. I will have to look into that.

Original comment by @dmouriss on Tue May 02 2017 at 16:20.

@dmouriss
Copy link
Collaborator

dmouriss commented Aug 1, 2019

The javascript statement to test the linter seems to work

Original comment by @dmouriss on Tue May 02 2017 at 16:23.

@pdawyndt
Copy link
Contributor Author

pdawyndt commented Aug 1, 2019

See ESLint documentation for the specs on the message object that reports on an issue with the code. Here's a sample message object:

{
    "ruleId": "no-unused-vars",
    "severity": 1,
    "message": "'Machine' is defined but never used.",
    "line": 18,
    "column": 7,
    "nodeType": "Identifier",
    "source": "class Machine{"
}

From the ESLint documentation:

The message object

  • ruleId: the id of the rule that produced the error or warning.
  • severity: the severity of the failure, 1 for warnings and 2 for errors.
  • message: the human readable description of the error.
  • line: the line where the issue is located.
  • column: the column where the issue is located.
  • nodeType: the type of the node in the AST
  • source: an extract of the code the line where the failure happened.

Please note: the source property will be removed from the message object in an upcoming breaking release. If you depend on this property, you should now use the source or output properties from the result object instead.

Note: the ruleID can be used to link the message to the documentation (example)

Original comment by @pdawyndt on Thu May 04 2017 at 15:51.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants