npm package: @quintaaa/eslint-plugin-starlims
Description: Eslint plugin to parse and lint starlims form code successfully
Author: Quentin Vauthier
Latest version: 1.3.1

# Starlims ESLint Plugin

This plugin provides custom rules for Starlims.

## How to use

### Installation

- 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:

```js
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](https://eslint.org/docs/user-guide/configuring).

You should now be able to use the plugin in your Starlims project.

### Usage

Use the following command to lint your Starlims project:

```bash
npx eslint .
```

You can also install the ESLint extension for Visual Studio Code to get real-time linting. [ESLint extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)

## List of customizations

- 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` and `lims.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 of `Starlims.navigator` or `window.navigator`)
  - starlims/remove-debugger --> Reports the usage of debugger statements and removes them on autofix

## Contributing

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.