All the Software developers of Netspective Communications LLC across all the projects
must have a consistent code linting process.
Controls
All developers are required to adhere to the linting tool that aligns with their respective development or runtime technology as listed below.
Runtime Language | Linting Tool | Remarks |
---|---|---|
Node.js | ESLint | The same can be used for Node.js, TypeScript, React, Angular, Astro Projects |
Node.js
All developers who use Node.js as a runtime for their programming language must use ESLint as the linting tool. [FII-CQI-070-CLP-01]
-
Ensure to execute the below command in the CLI to install eslint globally.
npm install -g eslint
[FII-CQI-070-CLP-01.01]
-
Ensure to run the following command in CLI to install the packages needed for eslint if you are using any of the javascript libraries or frameworks.
npm init @eslint/config
[FII-CQI-070-CLP-01.02]
-
For Angular, An alternative step for configuring eslint
ng add @angular-eslint/schematics
[FII-CQI-070-CLP-01.03]
-
Ensure to add the below provided content to package.json to lint the project using the ‘npm run lint’ command
"scripts": { "lint": "eslint \"src/**/*.{js,jsx,ts,tsx,astro,md}\" --quiet --fix", },
[FII-CQI-070-CLP-01.04]
-
Ensure
npm run lint
command will run to lint with ESLint in the whole project. [FII-CQI-070-CLP-01.05] -
Ensure to enable the extension “ESLint” v2.4.0 or later in Visual Studio Code. [FII-CQI-070-CLP-01.06]
-
Ensure to use
eslint --quiet --fix .
command to lint all files in the current directory and its subdirectories. [FII-CQI-070-CLP-01.07] -
Ensure to add proper packages are installed. [FII-CQI-070-CLP-01.08]
-
For Angular, Ensure the below given packages are installed.
"@angular-eslint/schematics": "^1.0.0", "@typescript-eslint/eslint-plugin": "^5.57.0", "@typescript-eslint/parser": "^5.57.0", "eslint": "^8.2.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-import": "^2.25.2", "eslint-plugin-prettier": "^4.2.1", "prettier-eslint": "^15.0.1", "typescript": "~4.7.2"
[FII-CQI-070-CLP-01.08.01]
-
For React, Ensure the below given packages are installed.
"@typescript-eslint/eslint-plugin": "^5.57.0", "@typescript-eslint/parser": "^5.55.0", "eslint": "^8.0.1", "eslint-config-prettier": "^8.7.0", "eslint-config-standard-with-typescript": "^34.0.1", "eslint-plugin-import": "^2.27.5", "eslint-plugin-jsx-a11y": "^6.7.1", "eslint-plugin-n": "^15.7.0", "eslint-plugin-prettier": "^4.2.1", "eslint-plugin-promise": "^6.1.1", "eslint-plugin-react": "^7.32.2", "prettier-eslint": "^15.0.1", "typescript": "^4.9.5",
[FII-CQI-070-CLP-01.08.02]
-
For Astro, Ensure the below given packages are installed.
"@typescript-eslint/eslint-plugin": "^5.55.0", "@typescript-eslint/parser": "^5.55.0", "eslint": "^8.36.0", "eslint-config-prettier": "^8.7.0", "eslint-plugin-astro": "^0.24.0", "eslint-plugin-jsx-a11y": "^6.7.1", "eslint-plugin-prettier": "^4.2.1", "prettier-eslint": "^15.0.1", "typescript": "^4.9.5",
[FII-CQI-070-CLP-01.08.03]
-
Ensure to add and modify the configuration file
.eslintrc.cjs
and ensure rules must matches Deno linting rule. [FII-CQI-070-CLP-01.09]- React ESLint Configuration
.eslintrc.cjs
[FII-CQI-070-CLP-01.09.01] - Angular ESLint Configuration
.eslintrc.cjs
[FII-CQI-070-CLP-01.09.02] - Astro ESLint Configuration
.eslintrc.cjs
[FII-CQI-070-CLP-01.09.03]
- React ESLint Configuration
-
All React developers must ensure they are following React reference Project for React code quality.
-
All Angular developers must ensure they are following Angular reference Project for Angular code quality.
Evidence
Node.js
-
[FII-CQI-070-CLP-01.08.01] For Angular,
- Execute the below duckdb query in a CLI to verify package.json contains all necessary plugins in dependencies and devDependencies.
duckdb -s "SELECT dependencies['@angular-eslint/schematics'], devDependencies['@typescript-eslint/eslint-plugin'], devDependencies['@typescript-eslint/parser'], devDependencies->'eslint',devDependencies->'eslint-config-prettier',devDependencies->'eslint-plugin-import',devDependencies->'eslint-plugin-prettier', devDependencies->'prettier-eslint',devDependencies->'typescript' FROM read_json_auto('package.json');"
-
[FII-CQI-070-CLP-01.08.02] For ReactJS,
- Execute the below duckdb query in a CLI to verify package.json contains all other required packages in devDependencies.
duckdb -s "SELECT devDependencies['@typescript-eslint/eslint-plugin'], devDependencies['@typescript-eslint/parser'], devDependencies->'eslint',devDependencies->'eslint-config-prettier', devDependencies->'eslint-config-standard-with-typescript', devDependencies->'eslint-plugin-import',devDependencies->'eslint-plugin-jsx-a11y', devDependencies->'eslint-plugin-n',devDependencies->'eslint-plugin-promise',devDependencies->'eslint-plugin-react',devDependencies->'eslint-plugin-prettier',devDependencies->'prettier-eslint',devDependencies->'typescript' FROM read_json_auto('package.json');"
-
[FII-CQI-070-CLP-01.08.03] For Astro,
- Execute the below duckdb query in a CLI to verify package.json contains all other required packages in devDependencies.
duckdb -s "SELECT devDependencies['@typescript-eslint/eslint-plugin'], devDependencies['@typescript-eslint/parser'], devDependencies->'eslint',devDependencies->'eslint-config-prettier',devDependencies->'eslint-plugin-astro', devDependencies->'eslint-plugin-jsx-a11y', devDependencies->'eslint-plugin-prettier', devDependencies->'prettier-eslint',devDependencies->'typescript' FROM read_json_auto('package.json');"
-
[FII-CQI-070-CLP-01.04] Execute the below duckdb query in a CLI to verify package.json contains
lint
command.duckdb -s "SELECT scripts->'lint' as 'Lint Script' FROM read_json_auto('package.json');"
-
[FII-CQI-070-CLP-01.05] Execute the below duckdb query in the CLI to run
lint
command and output linted result.duckdb -s "SELECT UNNEST(regexp_split_to_array('$(npm run lint )', '\n')) as 'Lint Result';"
ensure getting output as
-
if the linting encounters any problems,
// It will display all the errors and warnings grouped per files with count. ✖ (count) problems (count) errors and (count) warnings
-
otherwise console will be blank.
-
[FII-CQI-070-CLP-01.06] Execute the below duckddb query in the CLI to check whether eslint plugin for vscode is installed or not.
duckdb -s "SELECT COUNT(*) as 'dbaeumer.vscode-eslint' FROM (SELECT '$(code --list-extensions --show-versions)' as 'ext_res') WHERE ext_res LIKE '%dbaeumer.vscode-eslint%';"