-
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
25 changed files
with
815 additions
and
429 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
6 changes: 4 additions & 2 deletions
6
its/eslint-plugin-sonarjs/package.json → its/eslint8-plugin-sonarjs/package.json
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 |
---|---|---|
@@ -1,12 +1,14 @@ | ||
{ | ||
"name": "eslint-plugin-sonarjs-tests", | ||
"name": "eslint8-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" | ||
"eslint": "8.57.0", | ||
"typescript": "5.5.4", | ||
"typescript-eslint": "7.16.1" | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "NodeNext", | ||
"target": "es6", | ||
"allowJs": true, | ||
"moduleResolution": "NodeNext" | ||
}, | ||
"files": ["tseslint.config.mjs"] | ||
} |
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,8 @@ | ||
// @ts-check | ||
|
||
import plugin from 'eslint-plugin-sonarjs'; | ||
import tseslint from 'typescript-eslint'; | ||
|
||
console.log(`Loaded ${Object.keys(plugin.configs.recommended.rules).length} rules`); | ||
|
||
export default tseslint.config(plugin.configs.recommended); |
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,36 @@ | ||
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; | ||
console.log(output); | ||
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; | ||
console.log(output); | ||
const errorLines = output.split('\n').filter(line => line.includes('error')); | ||
assert(errorLines.length > 4); | ||
}); | ||
|
||
test('should work with TSESLint config', async t => { | ||
const result = spawn.sync('npx', ['eslint', '-c', 'tseslint.config.mjs', 'file.js'], { | ||
cwd: __dirname, | ||
encoding: 'utf-8', | ||
}); | ||
const output = result.stdout; | ||
console.log(output); | ||
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,14 @@ | ||
{ | ||
"name": "eslint9-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", | ||
"typescript": "5.5.4", | ||
"typescript-eslint": "7.16.1" | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "NodeNext", | ||
"target": "es6", | ||
"allowJs": true, | ||
"moduleResolution": "NodeNext" | ||
}, | ||
"files": ["tseslint.config.mjs"] | ||
} |
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,8 @@ | ||
// @ts-check | ||
|
||
import plugin from 'eslint-plugin-sonarjs'; | ||
import tseslint from 'typescript-eslint'; | ||
|
||
console.log(`Loaded ${Object.keys(plugin.configs.recommended.rules).length} rules`); | ||
|
||
export default tseslint.config(plugin.configs.recommended); |
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
Oops, something went wrong.