We use ESLint as the primary linting tool, and it's important that you adhere to the defined ruleset in the configuration.
Set up the ESLint plugin corresponding to the IDE/Code editor you are using. For more information, follow the instructions here.
Always keep an eye out for the inline warnings and errors given out by the plugin.
Execute the following commands based on the requirement to analyze the code with ESLint.
# Run this from the root.
npm run lint
cd apps/console
npm run lint
or
# From anywhere in the project.
npx lerna run lint --scope @wso2is/console --stream
cd modules/react-components
npm run lint
or
# From anywhere in the project.
npx lerna run lint --scope @wso2is/react-components --stream
The script lint:targeted
is meant to be used if you need to run the linter on a specific folder or file inside an app or a module.
cd apps/console
npm run lint:targeted -- src/features/applications
cd tests
npm run lint:targeted -- integration/applications/basic-application.spec.ts
ESLint has the ability to auto-fix certain warnings and errors.
This can be done using the CLI as well as via the IDE/Code Editor using the integrated ESLint Plugin.
Execute the following commands to auto-fix possible issues using the CLI.
# Run this from the root.
npm run lint:autofix
cd modules/core
npm run lint:autofix
or
# From anywhere in the project.
npx lerna run lint:autofix --scope @wso2is/core --stream
cd apps/myaccount
npm run lint:targeted -- src/api --fix
cd modules/core
npm run lint:targeted -- src/utils/url-utils.ts --fix