ESLint
Introduction
Unlike other Code Checkers, TICS will use the ESLint package from the project's workspace. The reason for this is:
- ESLint is part of Node Modules
- Project's dependencies also reside in Node Modules
- Node Modules are version specific
Therefore, to prevent version conflicts and ensure dependency completeness, ESLint needs to be installed and configured inside the project's workspace.
Prerequisites
In order to perform Coding Standard analysis for JavaScript and TypeScript, the following requirements have to be fulfilled:
- Runtime Environment
- Node.js: Installed globally on your machine to execute the JavaScript runtime environment.
- Package Manager NPM, available to manage project dependencies.
- Project Dependencies
- ESLint
- TypeScript Parser to allow ESLint to understand TypeScript syntax.
- TypeScript Plugin for specific TypeScript linting rules.
- TypeScript Core
- Configuration Files
- ESLint Config: A local configuration file (eslint.config.* for Flat Config, or .eslintrc* for legacy).
- TypeScript Config: A valid tsconfig.json file so the parser can resolve type-aware linting rules.
ESLint installation
Please follow this tutorial to get started with ESLint and setup all its necessities.
Also make sure to:
Troubleshooting
When transitioning from the legacy way of ESLint analysis where the ESLint package was provided by TIOBE or when ESLint was not used before,
the above mentioned prerequisites will not be fulfilled. When attempting to run TICS without these prerequisites, errors will be prompted.
The following errors are known and can likely be resolved:
ESLint couldn't find a configuration file
- Symptom:
[ERROR 5418] Runtime error while running 'eslint' for 'FILE': 'ESLint couldn't find a configuration file.
- Cause: There is no configuration prepared for ESLint.
- Solution: Set up an ESLint configuration.
The tool 'npx' is not available
- Symptom:
[ERROR 5424] Tool 'eslint' is not run for 'FILE': 'The tool 'npx' is not available.
- Cause: ESlint could not be executed because npx, the node package executor, appears to be missing.
- Solution: Install npm and npx.
SyntaxError: Unexpected token
- Symptom:
[ERROR 5418] Runtime error while running 'eslint' in combination with SyntaxError: Unexpected token.
- Cause: There is a mismatch of versions between Node, node.js and your project. Most likely, the node version is too old.
- Solution: Remove the node_modules directory and re-install Node.js and NPM.
Suspiciously low violation count
- Symptom: There are suspiciously few violations reported by TICS, where more violations were expected.
- Cause: Possibly, few or no checks have been configured in the ESLint documentation.
- Solution: Make sure ESLint Rules are configured.