diff --git a/package.json b/package.json index 669f4a69102..aa0a2e43bb9 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "new-rule": "ts-node tools/newRule.ts", "generate-meta": "ts-node tools/generate-meta.ts && cd packages/jsts/src/rules && npm run eslint-docs", "ruling": "node tools/prepare-ruling.js && jest ./packages/ruling/tests/projects/*.ruling.test.ts", + "ruling-parametrized": "node tools/prepare-ruling.js && SONAR_RULING_SETTINGS=../settings.js jest ./packages/ruling/tests/projects/*.ruling.test.ts", "ruling-sync": "rsync -avh packages/ruling/tests/actual/jsts/ its/ruling/src/test/expected/jsts/ --delete", "update-ruling-data": "mvn -f sonar-plugin/sonar-javascript-plugin/pom.xml compile && ts-node packages/ruling/tests/tools/parseRulesData.ts", "bridge:compile": "tsc -b packages profiling && npm run _:bridge:copy-protofile", diff --git a/packages/ruling/tests/projects/Ghost.ruling.test.ts b/packages/ruling/tests/projects/Ghost.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/Ghost.ruling.test.ts +++ b/packages/ruling/tests/projects/Ghost.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/Joust.ruling.test.ts b/packages/ruling/tests/projects/Joust.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/Joust.ruling.test.ts +++ b/packages/ruling/tests/projects/Joust.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/TypeScript.ruling.test.ts b/packages/ruling/tests/projects/TypeScript.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/TypeScript.ruling.test.ts +++ b/packages/ruling/tests/projects/TypeScript.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/ace.ruling.test.ts b/packages/ruling/tests/projects/ace.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/ace.ruling.test.ts +++ b/packages/ruling/tests/projects/ace.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/ag-grid.ruling.test.ts b/packages/ruling/tests/projects/ag-grid.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/ag-grid.ruling.test.ts +++ b/packages/ruling/tests/projects/ag-grid.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/amplify.ruling.test.ts b/packages/ruling/tests/projects/amplify.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/amplify.ruling.test.ts +++ b/packages/ruling/tests/projects/amplify.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/angular.js.ruling.test.ts b/packages/ruling/tests/projects/angular.js.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/angular.js.ruling.test.ts +++ b/packages/ruling/tests/projects/angular.js.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/ant-design.ruling.test.ts b/packages/ruling/tests/projects/ant-design.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/ant-design.ruling.test.ts +++ b/packages/ruling/tests/projects/ant-design.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/backbone.ruling.test.ts b/packages/ruling/tests/projects/backbone.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/backbone.ruling.test.ts +++ b/packages/ruling/tests/projects/backbone.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/console.ruling.test.ts b/packages/ruling/tests/projects/console.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/console.ruling.test.ts +++ b/packages/ruling/tests/projects/console.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/courselit.ruling.test.ts b/packages/ruling/tests/projects/courselit.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/courselit.ruling.test.ts +++ b/packages/ruling/tests/projects/courselit.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/desktop.ruling.test.ts b/packages/ruling/tests/projects/desktop.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/desktop.ruling.test.ts +++ b/packages/ruling/tests/projects/desktop.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/ecmascript6-today.ruling.test.ts b/packages/ruling/tests/projects/ecmascript6-today.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/ecmascript6-today.ruling.test.ts +++ b/packages/ruling/tests/projects/ecmascript6-today.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/eigen.ruling.test.ts b/packages/ruling/tests/projects/eigen.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/eigen.ruling.test.ts +++ b/packages/ruling/tests/projects/eigen.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/es5-shim.ruling.test.ts b/packages/ruling/tests/projects/es5-shim.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/es5-shim.ruling.test.ts +++ b/packages/ruling/tests/projects/es5-shim.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/expressionist.js.ruling.test.ts b/packages/ruling/tests/projects/expressionist.js.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/expressionist.js.ruling.test.ts +++ b/packages/ruling/tests/projects/expressionist.js.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/file-for-rules.ruling.test.ts b/packages/ruling/tests/projects/file-for-rules.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/file-for-rules.ruling.test.ts +++ b/packages/ruling/tests/projects/file-for-rules.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/fireact.ruling.test.ts b/packages/ruling/tests/projects/fireact.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/fireact.ruling.test.ts +++ b/packages/ruling/tests/projects/fireact.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/fireface.ruling.test.ts b/packages/ruling/tests/projects/fireface.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/fireface.ruling.test.ts +++ b/packages/ruling/tests/projects/fireface.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/http.ruling.test.ts b/packages/ruling/tests/projects/http.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/http.ruling.test.ts +++ b/packages/ruling/tests/projects/http.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/ionic2-auth.ruling.test.ts b/packages/ruling/tests/projects/ionic2-auth.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/ionic2-auth.ruling.test.ts +++ b/packages/ruling/tests/projects/ionic2-auth.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/it-tools.ruling.test.ts b/packages/ruling/tests/projects/it-tools.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/it-tools.ruling.test.ts +++ b/packages/ruling/tests/projects/it-tools.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/jStorage.ruling.test.ts b/packages/ruling/tests/projects/jStorage.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/jStorage.ruling.test.ts +++ b/packages/ruling/tests/projects/jStorage.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/jira-clone.ruling.test.ts b/packages/ruling/tests/projects/jira-clone.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/jira-clone.ruling.test.ts +++ b/packages/ruling/tests/projects/jira-clone.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/jquery.ruling.test.ts b/packages/ruling/tests/projects/jquery.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/jquery.ruling.test.ts +++ b/packages/ruling/tests/projects/jquery.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/jshint.ruling.test.ts b/packages/ruling/tests/projects/jshint.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/jshint.ruling.test.ts +++ b/packages/ruling/tests/projects/jshint.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/knockout.ruling.test.ts b/packages/ruling/tests/projects/knockout.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/knockout.ruling.test.ts +++ b/packages/ruling/tests/projects/knockout.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/moose.ruling.test.ts b/packages/ruling/tests/projects/moose.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/moose.ruling.test.ts +++ b/packages/ruling/tests/projects/moose.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/mootools-core.ruling.test.ts b/packages/ruling/tests/projects/mootools-core.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/mootools-core.ruling.test.ts +++ b/packages/ruling/tests/projects/mootools-core.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/ocanvas.ruling.test.ts b/packages/ruling/tests/projects/ocanvas.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/ocanvas.ruling.test.ts +++ b/packages/ruling/tests/projects/ocanvas.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/p5.js.ruling.test.ts b/packages/ruling/tests/projects/p5.js.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/p5.js.ruling.test.ts +++ b/packages/ruling/tests/projects/p5.js.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/paper.js.ruling.test.ts b/packages/ruling/tests/projects/paper.js.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/paper.js.ruling.test.ts +++ b/packages/ruling/tests/projects/paper.js.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/postgraphql.ruling.test.ts b/packages/ruling/tests/projects/postgraphql.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/postgraphql.ruling.test.ts +++ b/packages/ruling/tests/projects/postgraphql.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/prettier-vscode.ruling.test.ts b/packages/ruling/tests/projects/prettier-vscode.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/prettier-vscode.ruling.test.ts +++ b/packages/ruling/tests/projects/prettier-vscode.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/prototype.ruling.test.ts b/packages/ruling/tests/projects/prototype.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/prototype.ruling.test.ts +++ b/packages/ruling/tests/projects/prototype.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/qunit.ruling.test.ts b/packages/ruling/tests/projects/qunit.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/qunit.ruling.test.ts +++ b/packages/ruling/tests/projects/qunit.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/react-cloud-music.ruling.test.ts b/packages/ruling/tests/projects/react-cloud-music.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/react-cloud-music.ruling.test.ts +++ b/packages/ruling/tests/projects/react-cloud-music.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/reddit-mobile.ruling.test.ts b/packages/ruling/tests/projects/reddit-mobile.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/reddit-mobile.ruling.test.ts +++ b/packages/ruling/tests/projects/reddit-mobile.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/redux.ruling.test.ts b/packages/ruling/tests/projects/redux.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/redux.ruling.test.ts +++ b/packages/ruling/tests/projects/redux.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/router.ruling.test.ts b/packages/ruling/tests/projects/router.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/router.ruling.test.ts +++ b/packages/ruling/tests/projects/router.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/rxjs.ruling.test.ts b/packages/ruling/tests/projects/rxjs.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/rxjs.ruling.test.ts +++ b/packages/ruling/tests/projects/rxjs.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/searchkit.ruling.test.ts b/packages/ruling/tests/projects/searchkit.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/searchkit.ruling.test.ts +++ b/packages/ruling/tests/projects/searchkit.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/sizzle.ruling.test.ts b/packages/ruling/tests/projects/sizzle.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/sizzle.ruling.test.ts +++ b/packages/ruling/tests/projects/sizzle.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/snoode.ruling.test.ts b/packages/ruling/tests/projects/snoode.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/snoode.ruling.test.ts +++ b/packages/ruling/tests/projects/snoode.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/sonar-web.ruling.test.ts b/packages/ruling/tests/projects/sonar-web.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/sonar-web.ruling.test.ts +++ b/packages/ruling/tests/projects/sonar-web.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/templating.ruling.test.ts b/packages/ruling/tests/projects/templating.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/templating.ruling.test.ts +++ b/packages/ruling/tests/projects/templating.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/underscore.ruling.test.ts b/packages/ruling/tests/projects/underscore.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/underscore.ruling.test.ts +++ b/packages/ruling/tests/projects/underscore.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/vuetify.ruling.test.ts b/packages/ruling/tests/projects/vuetify.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/vuetify.ruling.test.ts +++ b/packages/ruling/tests/projects/vuetify.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/watchtower.js.ruling.test.ts b/packages/ruling/tests/projects/watchtower.js.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/watchtower.js.ruling.test.ts +++ b/packages/ruling/tests/projects/watchtower.js.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/projects/yaml.ruling.test.ts b/packages/ruling/tests/projects/yaml.ruling.test.ts index ca0d5c68767..e2a4447795b 100644 --- a/packages/ruling/tests/projects/yaml.ruling.test.ts +++ b/packages/ruling/tests/projects/yaml.ruling.test.ts @@ -21,11 +21,11 @@ import { compareSync } from 'dir-compare'; import { setupBeforeAll, testProject } from '../tools/testProject'; describe('Ruling', () => { - const { project, expectedPath, actualPath } = setupBeforeAll(__filename); + const { project, expectedPath, actualPath, rules } = setupBeforeAll(__filename); it( project.name, async () => { - await testProject(project); + await testProject(project, actualPath, rules); expect( compareSync(expectedPath, actualPath, { compareContent: true, diff --git a/packages/ruling/tests/settings.js b/packages/ruling/tests/settings.js new file mode 100644 index 00000000000..e6c996cb989 --- /dev/null +++ b/packages/ruling/tests/settings.js @@ -0,0 +1,19 @@ +const path = require('path'); +const rules = require('./data/rules.json'); + +module.exports = { + actualPath: path.join(__dirname, 'actual', 'jsts'), + expectedPath: path.join( + __dirname, + '..', + '..', + '..', + 'its', + 'ruling', + 'src', + 'test', + 'expected', + 'jsts', + ), + rules, +}; diff --git a/packages/ruling/tests/tools/lits.ts b/packages/ruling/tests/tools/lits.ts index f48128b330e..88dd00b2584 100644 --- a/packages/ruling/tests/tools/lits.ts +++ b/packages/ruling/tests/tools/lits.ts @@ -50,7 +50,7 @@ export function writeResults( actualPath: string, ) { const eslintIdToSonarId = loadKeysMapping(); - const targetProjectPath = path.join(actualPath, projectName); + const targetProjectPath = path.join(actualPath); try { fs.rmSync(targetProjectPath, { recursive: true }); } catch {} diff --git a/packages/ruling/tests/tools/testProject.ts b/packages/ruling/tests/tools/testProject.ts index 65dcf163529..282a0c72573 100644 --- a/packages/ruling/tests/tools/testProject.ts +++ b/packages/ruling/tests/tools/testProject.ts @@ -37,6 +37,8 @@ import { RuleConfig, analyzeProject, initializeLinter, + getLinter, + CustomRule, } from '../../../jsts/src'; import { accept } from '../filter/JavaScriptExclusionsFilter'; import { writeResults } from './lits'; @@ -44,8 +46,7 @@ import { analyzeHTML } from '../../../html/src'; import { isHtmlFile, isJsFile, isTsFile, isYamlFile } from './languages'; import { analyzeYAML } from '../../../yaml/src'; import projects from '../data/projects.json'; - -let rules: RuleConfig[] = []; +import { loadCustomRules } from '../../../jsts/src/linter/bundle-loader'; const sourcesPath = path.join(__dirname, '..', '..', '..', '..', '..', 'sonarjs-ruling-sources'); const jsTsProjectsPath = path.join(sourcesPath, 'jsts', 'projects'); @@ -65,6 +66,7 @@ const expectedPath = path.join( ); const actualPath = path.join(__dirname, '..', 'actual', 'jsts'); +const SETTINGS_KEY = 'SONAR_RULING_SETTINGS'; const HTML_LINTER_ID = 'html'; type RulingInput = { @@ -85,10 +87,9 @@ const DEFAULT_EXCLUSIONS = [ '**/external/**', ].map(pattern => new Minimatch(pattern, { nocase: true })); -export function setupBeforeAll(projectFile: string) { - rules = loadRules(); - const projectName = getProjectName(toUnixPath(projectFile)); - const project = projects.find(p => p.name === projectName); +export function setupBeforeAll(projectFile: string, customRules?: CustomRule[]) { + const { project, rules, expectedPath, actualPath } = extractParameters(projectFile); + beforeAll(() => { setContext({ workDir: path.join(os.tmpdir(), 'sonarjs'), @@ -96,33 +97,71 @@ export function setupBeforeAll(projectFile: string) { sonarlint: false, bundles: [], }); - initializeLinter(rules as RuleConfig[], DEFAULT_ENVIRONMENTS, DEFAULT_GLOBALS); - const htmlRules = (rules as RuleConfig[]).filter(rule => rule.key !== 'no-var'); - initializeLinter(htmlRules, DEFAULT_ENVIRONMENTS, DEFAULT_GLOBALS, HTML_LINTER_ID); + initializeRules(rules, customRules); }); + return { project, - expectedPath: path.join(expectedPath, project.name), - actualPath: path.join(actualPath, project.name), + expectedPath, + actualPath, + rules, }; } +function initializeRules(rules: RuleConfig[], customRules?: CustomRule[]) { + if (customRules) { + const defaultLinter = getLinter(); + const htmlLinter = getLinter(HTML_LINTER_ID); + loadCustomRules(defaultLinter.linter, customRules); + loadCustomRules(htmlLinter.linter, customRules); + } + initializeLinter(rules, DEFAULT_ENVIRONMENTS, DEFAULT_GLOBALS); + const htmlRules = rules.filter(rule => rule.key !== 'no-var'); + initializeLinter(htmlRules, DEFAULT_ENVIRONMENTS, DEFAULT_GLOBALS, HTML_LINTER_ID); +} function getProjectName(testFilePath: string) { const SUFFIX = '.ruling.test.ts'; const filename = path.basename(testFilePath); return filename.substring(0, filename.length - SUFFIX.length); } +function extractParameters(projectFile: string) { + const settingsPath = process.env[SETTINGS_KEY]; + let params; + if (settingsPath) { + params = extractSettingsFromFile(settingsPath); + } + const projectName = getProjectName(toUnixPath(projectFile)); + const project = projects.find(p => p.name === projectName); + + return { + project, + rules: params?.rules || loadRules(), + expectedPath: params?.expectedPath + ? path.join(params?.expectedPath, project.name) + : path.join(expectedPath, project.name), + actualPath: params?.actualPath + ? path.join(params?.actualPath, project.name) + : path.join(actualPath, project.name), + }; +} +function extractSettingsFromFile(pathToSettings: string) { + return require(pathToSettings); +} /** * Load files and analyze project */ -export async function testProject(rulingInput: RulingInput) { +export async function testProject( + rulingInput: RulingInput, + actualPath: string, + rules: RuleConfig[], +) { const projectPath = path.join(jsTsProjectsPath, rulingInput.folder ?? rulingInput.name); const exclusions = setExclusions(rulingInput.exclusions, rulingInput.testDir); const { jsTsFiles, htmlFiles, yamlFiles } = getProjectFiles(rulingInput, projectPath, exclusions); const payload: ProjectAnalysisInput = { - rules: rules as RuleConfig[], + rules, baseDir: projectPath, files: jsTsFiles, };