mlflow/server/js/mlflow-eslint-plugin/README.md
This directory contains custom ESLint rules specific to the MLflow OSS UI codebase.
This package is a yarn workspace referenced by mlflow/server/js/package.json as @mlflow/eslint-plugin.
In mlflow/server/js/.eslintrc.js, we automatically load the recommended rules in index.js.
.js file in this directory (e.g., my-custom-rule.js)meta and create functions:module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Description of your rule',
category: 'Best Practices',
recommended: true,
},
messages: {
myMessage: 'Your error message here',
},
},
create(context) {
return {
// Your rule implementation
};
},
};
index.js, and add it to the rules sections of the export (add to the
top-level rules config as well as the one in recommended):const myCustomRule = require('./my-custom-rule');
module.exports = {
rules: {
// ...
'my-custom-rule': myCustomRule,
},
configs: {
recommended: {
plugins: ['@mlflow'],
rules: {
'@mlflow/my-custom-rule': 'error',
},
},
},
};
Run yarn install from mlflow/server/js to make sure the new rules are loaded
Run yarn lint from mlflow/server/js to make sure the new rule works as intended
Run yarn test to run all tests in the directory. We currently use ESlint's RuleTester util to
write unit tests for our rules. Alternatively you can spot-check by running yarn lint in
mlflow/server/js on files you expect to fail your rule.