Skip to content

Commit

Permalink
Fix code scanning issues
Browse files Browse the repository at this point in the history
This resolves 30 occurrences of:

```ts
require(path.join(__dirname), './relative-path'))
```

By replacing them with the equivalent:

```
require('./relative-path')
```
  • Loading branch information
remcohaszing committed Jun 7, 2024
1 parent f039273 commit 228e879
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
40 changes: 20 additions & 20 deletions test/autoCompletion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ describe('Auto Completion Tests', () => {
});

it('Insert required attributes at correct level', (done) => {
const schema = require(path.join(__dirname, './fixtures/testRequiredProperties.json'));
const schema = require('./fixtures/testRequiredProperties.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = '- top:\n prop1: demo\n- ';
const completion = parseSetup(content, content.length);
Expand All @@ -804,7 +804,7 @@ describe('Auto Completion Tests', () => {
});

it('Insert required attributes at correct level even on first element', (done) => {
const schema = require(path.join(__dirname, './fixtures/testRequiredProperties.json'));
const schema = require('./fixtures/testRequiredProperties.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = '- ';
const completion = parseSetup(content, content.length);
Expand All @@ -822,7 +822,7 @@ describe('Auto Completion Tests', () => {
});

it('Provide the 3 types when none provided', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json'));
const schema = require('./fixtures/testArrayMaxProperties.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = '- ';
const completion = parseSetup(content, content.length);
Expand Down Expand Up @@ -852,7 +852,7 @@ describe('Auto Completion Tests', () => {
});

it('Provide the 2 types when one is provided', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json'));
const schema = require('./fixtures/testArrayMaxProperties.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = '- prop1:\n ';
const completion = parseSetup(content, content.length);
Expand All @@ -876,7 +876,7 @@ describe('Auto Completion Tests', () => {
});

it('Provide the 2 types when one is provided and the second is typed', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json'));
const schema = require('./fixtures/testArrayMaxProperties.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = '- prop1:\n p';
const completion = parseSetup(content, content.length);
Expand All @@ -900,7 +900,7 @@ describe('Auto Completion Tests', () => {
});

it('Provide no completion when maxProperties reached', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayMaxProperties.json'));
const schema = require('./fixtures/testArrayMaxProperties.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = '- prop1:\n prop2:\n ';
const completion = parseSetup(content, content.length);
Expand Down Expand Up @@ -1041,7 +1041,7 @@ describe('Auto Completion Tests', () => {

describe('Array Specific Tests', function () {
it('Should insert empty array item', (done) => {
const schema = require(path.join(__dirname, './fixtures/testStringArray.json'));
const schema = require('./fixtures/testStringArray.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'fooBa'; // len: 5
const completion = parseSetup(content, content.lastIndexOf('Ba') + 2); // pos: 3+2
Expand Down Expand Up @@ -1842,7 +1842,7 @@ describe('Auto Completion Tests', () => {

describe('Indentation Specific Tests', function () {
it('Indent should be considered with position relative to slash', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayIndent.json'));
const schema = require('./fixtures/testArrayIndent.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'install:\n - he'; // len: 15
const completion = parseSetup(content, content.lastIndexOf('he') + 2); // pos: 13+2
Expand All @@ -1860,7 +1860,7 @@ describe('Auto Completion Tests', () => {
});

it('Large indent should be considered with position relative to slash', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayIndent.json'));
const schema = require('./fixtures/testArrayIndent.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'install:\n - he'; // len: 25
const completion = parseSetup(content, content.lastIndexOf('he') + 2); // pos: 23+2
Expand All @@ -1878,7 +1878,7 @@ describe('Auto Completion Tests', () => {
});

it('Tab indent should be considered with position relative to slash', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayIndent.json'));
const schema = require('./fixtures/testArrayIndent.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'install:\n -\t he'; // len: 27
const completion = parseSetup(content, content.lastIndexOf('he') + 2); // pos: 25+2
Expand Down Expand Up @@ -2601,7 +2601,7 @@ describe('Auto Completion Tests', () => {

describe('Array completion', () => {
it('Simple array object completion with "-" without any item', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
const schema = require('./fixtures/testArrayCompletionSchema.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'test_simpleArrayObject:\n -';
const completion = parseSetup(content, content.length);
Expand All @@ -2615,7 +2615,7 @@ describe('Auto Completion Tests', () => {
});

it('Simple array object completion without "-" after array item', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
const schema = require('./fixtures/testArrayCompletionSchema.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'test_simpleArrayObject:\n - obj1:\n name: 1\n ';
const completion = parseSetup(content, content.length);
Expand All @@ -2628,7 +2628,7 @@ describe('Auto Completion Tests', () => {
});

it('Simple array object completion with "-" after array item', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
const schema = require('./fixtures/testArrayCompletionSchema.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'test_simpleArrayObject:\n - obj1:\n name: 1\n -';
const completion = parseSetup(content, content.length);
Expand All @@ -2642,7 +2642,7 @@ describe('Auto Completion Tests', () => {
});

it('Array anyOf two objects completion with "- " without any item', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
const schema = require('./fixtures/testArrayCompletionSchema.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'test_array_anyOf_2objects:\n - ';
const completion = parseSetup(content, content.length);
Expand All @@ -2658,7 +2658,7 @@ describe('Auto Completion Tests', () => {
});

it('Array anyOf two objects completion with "-" without any item', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
const schema = require('./fixtures/testArrayCompletionSchema.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'test_array_anyOf_2objects:\n -';
const completion = parseSetup(content, content.length);
Expand All @@ -2672,7 +2672,7 @@ describe('Auto Completion Tests', () => {
});

it('Simple array object completion without "-" befor array empty item', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
const schema = require('./fixtures/testArrayCompletionSchema.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'test_simpleArrayObject:\n |\n| -'; // len: 30, pos: 26
const completion = parseSetup(content);
Expand All @@ -2685,7 +2685,7 @@ describe('Auto Completion Tests', () => {
});

it('Array anyOf two objects completion without "-" after array item', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
const schema = require('./fixtures/testArrayCompletionSchema.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'test_array_anyOf_2objects:\n - obj1:\n name: 1\n ';
const completion = parseSetup(content, content.length);
Expand All @@ -2697,7 +2697,7 @@ describe('Auto Completion Tests', () => {
});

it('Array nested anyOf without "-" should return all array items', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
const schema = require('./fixtures/testArrayCompletionSchema.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'test_array_nested_anyOf:\n - obj1:\n name:1\n ';
const completion = parseSetup(content, content.length);
Expand All @@ -2709,7 +2709,7 @@ describe('Auto Completion Tests', () => {
});

it('Array anyOf two objects completion with "-" after array item', (done) => {
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
const schema = require('./fixtures/testArrayCompletionSchema.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'test_array_anyOf_2objects:\n - obj1:\n name: 1\n -';
const completion = parseSetup(content, content.length);
Expand All @@ -2723,7 +2723,7 @@ describe('Auto Completion Tests', () => {
});

it('Array anyOf two objects completion indentation', async () => {
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
const schema = require('./fixtures/testArrayCompletionSchema.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = 'test_array_anyOf_2objects:\n - obj';
const completion = await parseSetup(content, content.length);
Expand Down
4 changes: 2 additions & 2 deletions test/autoCompletionFix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ spec:

it('should complete array', async () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const schema = require(path.join(__dirname, './fixtures/test-nested-object-array.json'));
const schema = require('./fixtures/test-nested-object-array.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = `objA:
- name: nameA1
Expand All @@ -215,7 +215,7 @@ objB:

it('should complete array item for "oneOf" schema', async () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const schema = require(path.join(__dirname, './fixtures/test-completion-oneOf.json'));
const schema = require('./fixtures/test-completion-oneOf.json');
schemaProvider.addSchema(SCHEMA_ID, schema);
const content = `metadata:
Selector:
Expand Down
8 changes: 4 additions & 4 deletions test/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,15 +582,15 @@ describe('JSON Schema', () => {

describe('Test schema priority', function () {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const schemaAssociationSample = require(path.join(__dirname, './fixtures/sample-association.json'));
const schemaAssociationSample = require('./fixtures/sample-association.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const schemaStoreSample = require(path.join(__dirname, './fixtures/sample-schemastore.json'));
const schemaStoreSample = require('./fixtures/sample-schemastore.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const schemaSettingsSample = require(path.join(__dirname, './fixtures/sample-settings.json'));
const schemaSettingsSample = require('./fixtures/sample-settings.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const schemaModelineSample = path.join(__dirname, './fixtures/sample-modeline.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const schemaDefaultSnippetSample = require(path.join(__dirname, './fixtures/defaultSnippets-const-if-else.json'));
const schemaDefaultSnippetSample = require('./fixtures/defaultSnippets-const-if-else.json');
const languageSettingsSetup = new ServiceSetup().withCompletion();

it('Modeline Schema takes precendence over all other schema APIs', async () => {
Expand Down
8 changes: 4 additions & 4 deletions test/schemaValidation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ obj:
});
it('should distinguish types in error "Incorrect type (Expected "type1 | type2 | type3")"', async () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json'));
const schema = require('./fixtures/testMultipleSimilarSchema.json');
schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', schema.sharedSchema);
schemaProvider.addSchema(SCHEMA_ID, schema.schema);
const content = 'test_anyOf_objects:\n ';
Expand All @@ -1502,7 +1502,7 @@ obj:
});
it('should combine types in "Incorrect type error"', async () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json'));
const schema = require('./fixtures/testMultipleSimilarSchema.json');

schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', schema.sharedSchema);
schemaProvider.addSchema(SCHEMA_ID, schema.schema);
Expand All @@ -1515,7 +1515,7 @@ obj:
});
it('should combine const value', async () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json'));
const schema = require('./fixtures/testMultipleSimilarSchema.json');

schemaProvider.addSchemaWithUri(SCHEMA_ID, 'file:///sharedSchema.json', schema.sharedSchema);
schemaProvider.addSchema(SCHEMA_ID, schema.schema);
Expand All @@ -1528,7 +1528,7 @@ obj:
});
it('should distinguish types in error: "Missing property from multiple schemas"', async () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const schema = require(path.join(__dirname, './fixtures/testMultipleSimilarSchema.json'));
const schema = require('./fixtures/testMultipleSimilarSchema.json');

schemaProvider.addSchemaWithUri(sharedSchemaId, 'file:///sharedSchema.json', schema.sharedSchema);
schemaProvider.addSchema(SCHEMA_ID, schema.schema);
Expand Down

0 comments on commit 228e879

Please sign in to comment.