Skip to content

Commit

Permalink
Publishing latestest changes 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Maneesh Thareja committed Dec 24, 2024
1 parent 3799d90 commit 5578a74
Show file tree
Hide file tree
Showing 49 changed files with 6,398 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
package-lock.json
coverage
53 changes: 53 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#############################
# ENVIRONMENT VARIABLES
# UXP_LINTER_TEST_GITHUB_TOKEN - Personal Access Token created in Github Repo.....
# UXP_LINTER_TEST_PROJECT_DIR - Temporary workspace created through runner eg. /var/www/cicd
#############################
stages:
- deploy

image: node:latest
# Config cache
cache:
paths:
- node_modules/

# Deploy job
deploy:
# Docker image
#image: node:latest
stage: deploy
# Config to use GitLab Shared Runner with Executor Docker
tags:
- power-shell-runner
script:
- $srcDir = "$pwd\*"
- $destDir = "$UXP_LINTER_TEST_PROJECT_DIR"
- Copy-Item $srcDir $destDir -Exclude @("node_modules",".git") -Recurse -Force
- Set-Location -Path $UXP_LINTER_TEST_PROJECT_DIR
- $GIT_PATH = Join-Path -Path $UXP_LINTER_TEST_PROJECT_DIR -ChildPath .git
- $IS_GIT_INITIALISED = Test-Path -Path $GIT_PATH

- if (!$IS_GIT_INITIALISED) { git init }
- $IS_REF_PRESENT = git show-ref --heads $CI_COMMIT_REF_NAME; $?
- if (!$IS_REF_PRESENT) { git checkout -b $CI_COMMIT_REF_NAME } else { git checkout $CI_COMMIT_REF_NAME }
- git status
- git config user.email $GITLAB_USER_EMAIL
- git config user.name $GITLAB_USER_NAME
- Set-Location -Path "$UXP_LINTER_TEST_PROJECT_DIR\.git"
- Set-Location -Path $UXP_LINTER_TEST_PROJECT_DIR
- git add .
- $IS_VALID_COMMIT = git commit -m $CI_COMMIT_MESSAGE; $?
- if ($IS_VALID_COMMIT) {
$GIT_REMOTE = git config remote.origin.url; $?;
$GITHUB_URL = "https://ux-practice:$UXP_LINTER_TEST_GITHUB_TOKEN@github.com/ux-practice/iAnalyzer-test.git";
if ($GIT_REMOTE -AND !$GIT_REMOTE.Contains($UXP_LINTER_TEST_GITHUB_TOKEN)) { git remote remove origin };
$GIT_REMOTE = git config remote.origin.url; $?;
if (!$GIT_REMOTE) { git remote add origin $GITHUB_URL} ;
$GIT_REMOTE_REF = git ls-remote --exit-code --heads $GITHUB_URL $CI_COMMIT_REF_NAME ; $?;
if ($GIT_REMOTE_REF) { git pull origin $CI_COMMIT_REF_NAME --allow-unrelated-histories };
git push --set-upstream origin $CI_COMMIT_REF_NAME;
}
# Defines the names of branches and tags the job runs for
only:
- Linter_2.0_RELEASE_TEST_PIPELINE
160 changes: 158 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,158 @@
# iANALYZER
A versatile code analysis tool for JavaScript, HTML, CSS, Angular, React, Vue, and ES6. iAnalyzer ensures code quality through linting, integrates with Sonar for in-depth analysis, performs npm package security checks, assesses performance, and enhances accessibility. Your all-in-one solution for maintaining high-quality and secure code.
<p align="center">
<h1 align="center">iAnalyzer</h1>
</p>

<p align="center">A versatile code analysis tool for JavaScript, HTML, CSS, Angular, React, Vue, and ES6. iAnalyzer ensures code quality through ESLint rules linting with inbuilt profiles, integrates with Sonar for in-depth analysis, enforces a consistent code style across your entire codebase via Prettier. Your all-in-one solution for maintaining high-quality and efficient code.</p>

## Getting Started

### Installation

To install iAnalyzer locally in your project, you need to run the below command:

- Use npm to install the iAnalyzer

<pre><code>npm install ianalyzer</code></pre>

whereas for global installation, the user needs to add '-g' to the above command.

**Initialize iAnalyzer in your project**

- Open your project in a terminal and run following command to get multiple configuration options

<pre><code>npm run ianalyzer --init</code></pre>

### Execution

**Run iAnalyzer in your project**

- To perform linting on your project execute the below command.

<pre><code>npm run ianalyzer</code></pre>

**Fix Lint issues (auto fixable) in your project**

- To auto fix linting issues on your project execute the below command.

<pre><code>npm run ianalyzer-fix</code></pre>

The linting behavior can be modified through the below command, presented in .uxplinterrc file.

<pre><code>npm run ianalyzer --fix</code></pre>

### Reports

- To generate a linting report execute below command.

<pre><code>npm run ianalyzer-report</code></pre>

Once the above command gets executed, Users can opt for a report format. Default selected report format is `HTML`.

The linting report behavior can be modified through the below command, presented in .uxplinterrc file.

<pre><code>"jsReportCommand": "eslint --quiet --ext js,jsx,snap,md,ts,tsx,vue $path"</code></pre>

The linting behavior can be modified through the below command, presented in .uxplinterrc file.

<pre><code>"jsLintCommand": "eslint --ext ts,tsx,js,jsx,vue $path"</code></pre>


### Profile

By default, the package provides an 'essential' profile for linting. This profile has a limited set of rules.
Users can run `ianalyzer-init` anytime for updating the profile.

### Uninstall iAnalyzer

To remove a partial or complete package, run the `ianalyzer-init` command and select an appropriate option.


## Requirements

**Node:**

iAnalyzer only supports maintenance and LTS versions of Node.js. Please refer to the <a href="https://nodejs.org/en/about/releases/">Node.js release schedule</a> for more information. NPM versions installed by default with Node.js are supported.

| iAnalyzer Version | Recommended | Minimum |
| --------------- | ----------- | ------- |
| 2.0 | 16.x | 14.x |

**ESLint:**

| iAnalyzer Version | Recommended | Minimum |
| --------------- | ----------- | ------- |
| 2.0 | >=6.x.x | 6.x.x |

**@babel/eslint-parser:**

| iAnalyzer Version | Recommended | Minimum |
| --------------- | ----------- | ------- |
| 2.0 | Latest | 7.19.1 |

**babel-eslint:**

| iAnalyzer Version | Recommended | Minimum |
| --------------- | ----------- | ------- |
| 2.0 | 10.1.0 | 10.1.0 |


## Features

- **Zero Configuration**

<i>Just install & it's ready to use!</i>

No hassle of adding the .eslintrc configuration file or adding the required scripts in package.json to set up the analyzer. Just install the iAnalyzer, and everything is automatically configured with the installation. With the zero config setup, iAnalyzer provides the easiest way to enforce consistent styles in the codebase.

- **Linting Support**

<i>Looking for linting support?</i>

iAnalyzer provides support for JavaScript, TypeScript,HTML and CSS linting.

![alt text](./assets/images/Linting%20Options.PNG)

Along with provides an option to choose the linter based on the project need. Just need to answer a question before installation and you are good to go.

![alt text](./assets/images/Framework%20Options.PNG)

- **Automatic code fixing**

<i>Need to automatically fix the linting errors?</i>

Just run the command ianalyzer-fix & save your time to fix the liting errors automatically.

![alt text](./assets/images/Auto%20Fix.PNG)

- **Automatic code formatting**

<i>Need to automatically format the code?</i>

Just install Prettier and execute ianalyzer-run command to apply code formatting in the code.

![alt text](./assets/images/Auto%20Format.PNG)

- **Linting Report**

<i>Want to see linting reports or need to share with the team?</i>

No worries! iAnalyzer provides the reports in different available formats, just a single update for the format in the scripts, and you get the linting report in the format of your choice.

![alt text](./assets/images/Report%20Options.PNG)

- **Linting Profile**

<i>Afraid of linting, due to thousands of linting errors?</i>

No worries! iAnalyzer offers the rules that define the best practices into namely 4 categories - Essential, Recommended, Sonar and Custom. It doesn’t enforce hundreds of rules on the codebase all at once, instead it offers us the flexibility to choose from the categories, and scale up as and when one feels comfortable with the existing category.

![alt text](./assets/images/Profile%20Options.PNG)

## Roadmap

- Staged file support for linting
- Performance testing
- Security testing
- Accessibility testing
- Frontend Dashboard
- VS code extension
Binary file added assets/images/Auto Fix.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/Auto Format.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/Framework Options.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/Linting Options.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/Profile Options.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/Report Options.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions bin/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Ignores mentioned files/folders

# compiled output
/dist

# dependencies
/node_modules

# misc
/public
/coverage
/reports
/typings
16 changes: 16 additions & 0 deletions bin/.eslintrc-html.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": [
"eslint:recommended"
],
"plugins": [
"html"
],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2015
},
"settings": {
"html/indent": "+2",
"html/report-bad-indent": "error"
}
}
24 changes: 24 additions & 0 deletions bin/.stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": [
"stylelint-config-standard",
"stylelint-rscss/config"
],
"rules": {
"no-empty-source": null,
"at-rule-no-unknown": null,
"at-rule-empty-line-before": null,
"declaration-empty-line-before": null,
"no-descending-specificity": null,
"no-duplicate-selectors": null,
"rscss/class-format": [
true,
{
"maxDepth": 4,
"componentWhitelist": [
"btn",
"container"
]
}
]
}
}
97 changes: 97 additions & 0 deletions bin/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
exports.rules_category = [
{ category: 'essential', option: 0, label: 'Essential', description: 'to prevent uninteded behavior' },
{ category: 'recommended', option: 1, label: 'Recommended', description: 'to further improve code quality' },
{ category: 'custom', option: 2, label: 'Custom', description: 'reads rules from user-defined file' },
{ category: 'sonar', option: 3, label: 'Sonar', description: 'shows errors which sonarqube captures' }
];
const cssLinterPackageName = ['stylelint@13.13.1', 'stylelint-config-standard@22.0.0', 'stylelint-rscss'];
exports.cssUninstallPackageName = ['stylelint', 'stylelint-config-standard', 'stylelint-rscss'];
const htmlLinterPackageName = ['w3c-html-validator'];
const prettierPackageName = ['prettier'];
const sonarScannerPackageName = ['sonarqube-scanner@3.3.0'];
exports.cssLinterPackageName = cssLinterPackageName;
exports.htmlLinterPackageName = htmlLinterPackageName;
exports.prettierPackageName = prettierPackageName;
exports.sonarScannerPackageName = sonarScannerPackageName;
exports.fileTypeArray = [".eslintrc.js", ".eslintrc.cjs", ".eslintrc.yaml", ".eslintrc.yml", ".eslintrc.json", ".eslintrc"];
exports.prettierTypeArray = [".prettierrc", ".prettierignore"];
exports.allowedFormats = [
{ type: 'html', ext: 'html' },
{ type: 'checkstyle', ext: 'xml' },
{ type: 'compact', ext: 'txt' },
{ type: 'jslint-xml', ext: 'xml' },
{ type: 'json-with-metadata', ext: 'json' },
{ type: 'json', ext: 'json' },
{ type: 'junit', ext: 'xml' },
{ type: 'stylish', ext: 'txt' },
{ type: 'tap', ext: 'txt' },
{ type: 'unix', ext: 'txt' },
{ type: 'visualstudio', ext: 'txt' },
{ type: 'sonar', ext: 'json' },
];
exports.outputDirectory = './reports';
exports.allOptions = [
{ option: 0, text: 'JS Linter.', type: 'js' },
{ option: 1, text: 'HTML Linter.', type: 'html' },
{ option: 2, text: 'CSS Linter.', type: 'css' },
{ option: 3, text: 'Prettier', type: 'prettier' },
];
exports.allLinterOptions = [
{ option: 0, text: 'Install JS Linter.' },
{ option: 1, text: 'Install HTML Linter.' },
{ option: 2, text: 'Install CSS Linter.' },
{ option: 3, text: 'Install Prettier.' },
{ option: 4, text: 'Install Sonarqube Scanner.' },
{ option: 5, text: 'Uninstall iAnalyzer completely.' },
{ option: 6, text: 'Uninstall JS Linter.' },
{ option: 7, text: 'Uninstall HTML Linter.' },
{ option: 8, text: 'Uninstall CSS Linter.' },
{ option: 9, text: 'Uninstall Prettier.' },
{ option: 10, text: 'Uninstall Sonarqube Scanner.' },
{ option: 11, text: 'Select JS Linter Rules Profile.' },
{ option: 12, text: 'Change Linter Path.' },
// { 'option': 11, 'text': 'Initialize Sonar Properties file' },
// { 'option': 12, 'text': 'Remove Sonar Properties file' },
];
exports.allowedCSSFormats = [
{ type: 'compact', ext: 'txt' },
{ type: 'json', ext: 'json' },
{ type: 'string', ext: 'txt' },
{ type: 'tap', ext: 'txt' },
{ type: 'unix', ext: 'txt' },
{ type: 'verbose', ext: 'txt' },
];
exports.defaultRule = 'advance';
exports.eslintPrefix = 'eslint-config-impetus-basetest';
exports.ianalyzerrcInitialConfig = {
'js-linter': false,
'html-linter': false,
'css-linter': false,
prettier: false,
'sonar-scanner': false,
path: '',
projectType: '',
languageType: '',
linterProfile: 'Essential',
// "sonar-properties-initialized": false
};
exports.noPackageJson = {
scripts: {}
};
exports.jsLintCommand = 'eslint --ext ts,tsx,js,jsx,vue $path';
exports.jsHtmlLintCommand = 'eslint --ext ts,tsx,js,jsx,vue,html $path';
exports.jsReportCommand = 'eslint --quiet --ext js,jsx,snap,md,ts,tsx,vue $path';
exports.htmlLintCommand = 'html-validator $path';
exports.cssLintCommand = 'stylelint $path**/**.{css,scss,sass}';
exports.cssReportCommand = 'stylelint $path**/**.{css,scss,sass}';
exports.prettierLintCommand = 'npx prettier $path';
exports.defaultLinterPath = './';
exports.safeNodeVersionForPeerDeps = '16';
exports.sonarScannerVersion = '3.3.0';
exports.sonarProperties = '{"serverUrl":"","login":"","default":{"sonar.projectName":"","sonar.projectDescription":"","sonar.sources":"","sonar.tests":""}}'
exports.packagesToInstall = {
'html-linter' : htmlLinterPackageName[0]?.split('@')[0] || 'w3c-html-validator',
'css-linter' : cssLinterPackageName[0]?.split('@')[0] || 'stylelint@13.13.1',
'prettier' : prettierPackageName[0]?.split('@')[0] || 'prettier',
'sonar-scanner' : sonarScannerPackageName[0]?.split('@')[0] || 'sonarqube-scanner@3.3.0',
}
Loading

0 comments on commit 5578a74

Please sign in to comment.