This plugin provides custom rules for Starlims.
- Create a new project with
npm init
in the root folder of your Starlims project - Install ESLint and the plugin with npm:
npm install eslint @quintaaa/eslint-plugin-starlims --save-dev
- Create a new file named
eslint.config.js
in the root folder of your Starlims project - Add the following content to the file:
const starlims = require('@quintaaa/eslint-plugin-starlims');
module.exports = [
starlims.configs.recommended,
{
rules: {
// Here is an example of the rules I use
'prefer-const': 'warn',
'no-var': 'warn',
'no-else-return': 'warn',
'no-mixed-spaces-and-tabs': 'off',
// Add your own rules here
// ...
// To edit the plugin default rules, use the following syntax
// The list of rules can be found in in the readme file of the plugin
'starlims/no-synchronous-requests': 'warn',
},
},
];
You can customize your ESLint configuration as you wish. For more information, please refer to the ESLint documentation.
You should now be able to use the plugin in your Starlims project.
Use the following command to lint your Starlims project:
npx eslint .
You can also install the ESLint extension for Visual Studio Code to get real-time linting. ESLint extension for Visual Studio Code
- Do not create parsing errors for
#include
statements - Do not report undefined variables for client script functions starting with
cs
(e.g.csLoadCrossTab
) - Do not report defined but unused variables for event handlers functions (e.g.
Form1_OnLoad
,Form1_OnClose
,dataGrid1_OnRowChange
,btnOk_OnClick
) - Allow usage of common Starlims global variables such as:
- form
- lims
- Shell
- Starlims
- Dialogs
- and more...
- Rules
- starlims/no-synchronous-requests --> Reports the usage of functions that are UI blocking and should be avoided (e.g.
lims.CallServer
,lims.GetDataSet
) - starlims/check-server-functions --> Checks the syntax of server functions such as
lims.CallServer
andlims.GetDataSet
etc. Also check the syntax of#include
statements - starlims/check-unconverted-functions --> Reports the usage of XFD functions that haven't been converted to html (e.g.
lims.AAdd
,Convert.ToInt32
) - starlims/requests-in-loop --> Reports the usage of requests in loops (e.g.
for
,while
,do...while
,foreach
etc.) - starlims/no-ambiguous-vars --> Reports the usage of ambiguous variables (e.g.
navigator
instead ofStarlims.navigator
orwindow.navigator
) - starlims/remove-debugger --> Reports the usage of debugger statements and removes them on autofix
- starlims/no-synchronous-requests --> Reports the usage of functions that are UI blocking and should be avoided (e.g.
Any contributions are welcome. Please follow the steps below to contribute:
- Fork the repository
- Create a new branch
- Make your changes
- Create a pull request
If you have any questions or suggestions, please contact me at quentin.vauthier@starlims.com or create an issue.