-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
588 changed files
with
8,369 additions
and
2,322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Release eslint-plugin-sonarjs | ||
|
||
# Workflow runs when manually triggered using the UI or API. | ||
on: | ||
workflow_dispatch: | ||
# Inputs the workflow accepts. | ||
inputs: | ||
release_version: | ||
description: 'Version (semver)' | ||
required: true | ||
|
||
jobs: | ||
publish: | ||
permissions: | ||
id-token: write # required for SonarSource/vault-action-wrapper | ||
runs-on: ubuntu-latest | ||
env: | ||
RELEASE_TAG: ${{ github.event.inputs.release_version }} | ||
NPM_REPOSITORY: "sonarsource-npm-public" | ||
SCOPE: "" | ||
PACKAGE: "eslint-plugin-sonarjs" | ||
steps: | ||
- name: Vault | ||
id: secrets | ||
uses: SonarSource/vault-action-wrapper@d1c1ab4ca5ad07fd9cdfe1eff038a39673dfca64 # tag=2.4.2-1 | ||
with: | ||
secrets: | ||
development/kv/data/repox url | repox_url; | ||
development/artifactory/token/SonarSource-eslint-plugin-sonarjs-qa-deployer access_token | qa_deployer_access_token; | ||
development/artifactory/token/SonarSource-eslint-plugin-sonarjs-promoter access_token | promoter_access_token; | ||
development/kv/data/npmjs sonartech_npm_token | npm_token; | ||
- name: Setup JFrog for deploy | ||
uses: SonarSource/jfrog-setup-wrapper@eb712d76540e5d1f3756303f30387657fb204e52 # tag=2.4.1-1 | ||
with: | ||
jfrogAccessToken: ${{ fromJSON(steps.secrets.outputs.vault).qa_deployer_access_token }} | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 18 | ||
- run: mv .github/workflows/.npmrc .npmrc | ||
- run: mv .github/workflows/.npmrc packages/jsts/src/rules/.npmrc | ||
- name: Publish npm package | ||
env: | ||
NPM_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).npm_token }} | ||
run: | | ||
jfrog rt npm-config --repo-resolve npm --repo-deploy sonarsource-npm-public-qa | ||
jfrog rt npm-ci | ||
cd packages/jsts/src/rules/ | ||
npm run build | ||
cd lib/ | ||
npm publish | ||
jfrog rt npm-publish --build-name=eslint-plugin-sonarjs --build-number=${{ github.event.inputs.release_version }} | ||
jfrog rt build-publish eslint-plugin-sonarjs ${{ github.event.inputs.release_version }} | ||
- name: Promote npm package | ||
env: | ||
PROMOTER_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).promoter_access_token }} | ||
REPOX_URL: ${{ fromJSON(steps.secrets.outputs.vault).repox_url }} | ||
run: | | ||
jfrog rt bpr --access-token $PROMOTER_TOKEN --url $REPOX_URL --status it-passed eslint-plugin-sonarjs ${{ github.event.inputs.release_version }} sonarsource-npm-public-builds | ||
jfrog rt bpr --access-token $PROMOTER_TOKEN --url $REPOX_URL --status released eslint-plugin-sonarjs ${{ github.event.inputs.release_version }} sonarsource-npm-public-releases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,6 @@ Desktop.ini | |
# ---- Sonar | ||
.sonar | ||
.scannerwork | ||
|
||
# eslint-plugin-sonarjs | ||
eslint-plugin-sonarjs-*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const plugin = require('eslint-plugin-sonarjs'); | ||
|
||
console.log(`Loaded ${Object.keys(plugin.configs.recommended.rules).length} rules`); | ||
|
||
module.exports = [ | ||
{ | ||
files: ['./*.js'], | ||
languageOptions: { sourceType: 'commonjs' }, | ||
}, | ||
plugin.configs.recommended, | ||
{ rules: { 'sonarjs/accessor-pairs': 'error' } }, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import plugin from 'eslint-plugin-sonarjs'; | ||
|
||
console.log(`Loaded ${Object.keys(plugin.configs.recommended.rules).length} rules`); | ||
|
||
export default [ | ||
{ | ||
files: ['./*.js'], | ||
languageOptions: { sourceType: 'commonjs' }, | ||
}, | ||
plugin.configs.recommended, | ||
{ rules: { 'sonarjs/accessor-pairs': 'error' } }, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
function S3776(foo) { | ||
if (foo.bar) { | ||
if (foo.baz) { | ||
if (foo.qux) { | ||
if (foo.fred) { | ||
if (foo.thud) { | ||
if (foo.abc) { | ||
foo.bcd(); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
function S2703(foo) { | ||
if (x == 0) { | ||
x = 42; | ||
} | ||
} | ||
|
||
function S2376() { | ||
class C { | ||
set m(a) { | ||
this.a = a; | ||
} | ||
} | ||
} | ||
|
||
/* | ||
function S125() { | ||
class C { | ||
set m(a) { | ||
this.a = a; | ||
} | ||
} | ||
} | ||
*/ | ||
|
||
// if (something) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { test } = require('node:test'); | ||
const assert = require('node:assert'); | ||
const spawn = require('cross-spawn'); | ||
|
||
test('should work with CommonJS config', async t => { | ||
const result = spawn.sync('npx', ['eslint', '-c', 'eslint.config.cjs', 'file.js'], { | ||
cwd: __dirname, | ||
encoding: 'utf-8', | ||
}); | ||
const output = result.stdout; | ||
const errorLines = output.split('\n').filter(line => line.includes('error')); | ||
assert(errorLines.length > 4); | ||
}); | ||
|
||
test('should work with ECMAScript modules config', async t => { | ||
const result = spawn.sync('npx', ['eslint', '-c', 'eslint.config.mjs', 'file.js'], { | ||
cwd: __dirname, | ||
encoding: 'utf-8', | ||
}); | ||
const output = result.stdout; | ||
const errorLines = output.split('\n').filter(line => line.includes('error')); | ||
assert(errorLines.length > 4); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "eslint-plugin-sonarjs-tests", | ||
"description": "Test suite for eslint-plugin-sonarjs", | ||
"scripts": { | ||
"build": "npm install && cp ../../packages/jsts/src/rules/lib/eslint-plugin-sonarjs-* ./plugin.tgz && npm i ./plugin.tgz --no-save && rm -f plugin.tgz", | ||
"test": "node index.test.js" | ||
}, | ||
"devDependencies": { | ||
"cross-spawn": "7.0.3", | ||
"eslint": "8.57.0" | ||
} | ||
} |
Oops, something went wrong.