Skip to content

Commit

Permalink
SALTO-5643: Cleaning up workspace before changes (#5863)
Browse files Browse the repository at this point in the history
Fixing typos and improving consistency.
  • Loading branch information
yelly committed May 6, 2024
1 parent adc37d1 commit acd699f
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
multipleAnnotationBlocks,
invalidNestedBlock,
invalidFieldAnnotationBlock,
multiplFieldDefinitions,
multipleFieldDefinitions,
invalidBlockItem,
} from '../errors'

Expand Down Expand Up @@ -152,7 +152,7 @@ export const consumeBlockBody = (
})
} else {
context.errors.push(
multiplFieldDefinitions(
multipleFieldDefinitions(
{
...consumedBlock.range,
filename: context.filename,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
invalidVarDefinition,
missingLabelsError,
missingBlockOpen,
ambigiousBlock,
ambiguousBlock,
} from '../errors'
import {
primitiveType,
Expand Down Expand Up @@ -291,7 +291,7 @@ export const consumeElement = (context: ParseContext): ConsumerReturnType<Elemen
start: consumedLabels.range.start,
end: blockToIgnore.range.end,
}
context.errors.push(ambigiousBlock({ ...range, filename: context.filename }))
context.errors.push(ambiguousBlock({ ...range, filename: context.filename }))
consumedElement = {
range,
value: undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/parser/src/parser/internal/native/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const invalidBlocksInInstance = (range: SourceRange): ParseError =>
'Unexpected field or annotation type definition(s) in a primitive type. Expected only values.',
)

export const ambigiousBlock = (range: SourceRange): ParseError => createError(range, 'Ambigious block definition')
export const ambiguousBlock = (range: SourceRange): ParseError => createError(range, 'Ambiguous block definition')

export const missingLabelsError = (range: SourceRange, token: string): ParseError =>
createError(range, 'Expected block labels', `Expected block labels, found ${token} instead.`)
Expand All @@ -70,7 +70,7 @@ export const multipleAnnotationBlocks = (range: SourceRange): ParseError =>
'Invalid annotations block, only one annotation block can be defined in a fragment.',
)

export const multiplFieldDefinitions = (range: SourceRange, fieldName: string): ParseError =>
export const multipleFieldDefinitions = (range: SourceRange, fieldName: string): ParseError =>
createError(
range,
'Duplicated field name',
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/parser/internal/native/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export async function parseBuffer(
}
}

// Adding the list types so they will be accesible during merge.
// Adding the list types so they will be accessible during merge.
elements.push(...Object.values(context.listTypes), ...Object.values(context.mapTypes))
await replaceValuePromises(context.valuePromiseWatchers)
return {
Expand Down
36 changes: 18 additions & 18 deletions packages/parser/test/parser/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ describe('parsing errors', () => {
})
expect(res.errors[0].summary).toBe('Expected block labels')
expect(res.errors[0].message).toBe('Expected block labels, found { instead.')
expect(res.errors[1].summary).toBe('Ambigious block definition')
expect(res.errors[1].summary).toBe('Ambiguous block definition')
})

it('should continue parsing other blocks and ignore the labeless block', async () => {
it('should continue parsing other blocks and ignore the unlabeled block', async () => {
expect(await awu(res.elements).toArray()).toHaveLength(1)
expect((await awu(res.elements).toArray())[0]).toEqual(new ObjectType({ elemID: new ElemID('nowhere', 'man') }))
})
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('parsing errors', () => {
describe('invalid primitive type error', () => {
describe('with unknown primitive type', () => {
const nacl = `
type helter.skater is amazing {
type helter.skelter is amazing {
}
`
let res: ParseResult
Expand All @@ -96,7 +96,7 @@ describe('parsing errors', () => {
it('should throw an error', () => {
expect(res.errors[0].subject).toEqual({
start: { byte: 13, col: 13, line: 2 },
end: { byte: 42, col: 42, line: 2 },
end: { byte: 43, col: 43, line: 2 },
filename: 'file.nacl',
})
expect(res.errors[0].message).toBe('Unknown primitive type amazing.')
Expand All @@ -110,7 +110,7 @@ describe('parsing errors', () => {
})
describe('with a missing primitive type', () => {
const nacl = `
type helter.skater is {
type helter.skelter is {
}
`
let res: ParseResult
Expand All @@ -123,7 +123,7 @@ describe('parsing errors', () => {
expect(res.errors[0].summary).toBe('unknown primitive type')
expect(await awu(res.elements).toArray()).toHaveLength(1)
})
it('should use unknown as the primitvie type primitive', async () => {
it('should use unknown as the primitive type primitive', async () => {
const element = (await awu(res.elements).toArray())[0] as PrimitiveType
expect(element.primitive).toBe(PrimitiveTypes.UNKNOWN)
})
Expand All @@ -132,7 +132,7 @@ describe('parsing errors', () => {
describe('invalid inheritance operator', () => {
describe('with missing inheritance operator', () => {
const nacl = `
type helter.skater tanananana {
type helter.skelter tanananana {
}
`
let res: ParseResult
Expand All @@ -143,14 +143,14 @@ describe('parsing errors', () => {
expect(res.errors).toHaveLength(2)
expect(res.errors[0].subject).toEqual({
start: { byte: 9, col: 9, line: 2 },
end: { byte: 38, col: 38, line: 2 },
end: { byte: 39, col: 39, line: 2 },
filename: 'file.nacl',
})
expect(res.errors[0].message).toBe("Expected inheritance operator 'is' found tanananana instead")
expect(res.errors[0].summary).toBe('invalid type definition')
expect(res.errors[1].subject).toEqual({
start: { byte: 9, col: 9, line: 2 },
end: { byte: 38, col: 38, line: 2 },
end: { byte: 39, col: 39, line: 2 },
filename: 'file.nacl',
})
expect(res.errors[1].message).toBe('Expected a primitive type definition.')
Expand All @@ -164,7 +164,7 @@ describe('parsing errors', () => {
})
describe('with invalid inheritance operator', () => {
const nacl = `
type helter.skater tanananana string {
type helter.skelter tanananana string {
}
`
let res: ParseResult
Expand All @@ -175,7 +175,7 @@ describe('parsing errors', () => {
expect(res.errors).toHaveLength(1)
expect(res.errors[0].subject).toEqual({
start: { byte: 11, col: 11, line: 2 },
end: { byte: 47, col: 47, line: 2 },
end: { byte: 48, col: 48, line: 2 },
filename: 'file.nacl',
})
expect(res.errors[0].message).toBe("Expected inheritance operator 'is' found tanananana instead")
Expand All @@ -190,7 +190,7 @@ describe('parsing errors', () => {
describe('invalid primitive type block structure', () => {
describe('when fields are defined in the primitive type', () => {
const nacl = `
type helter.skater is string {
type helter.skelter is string {
string tanananananana {
}
Expand All @@ -203,8 +203,8 @@ describe('parsing errors', () => {
it('should create an error', () => {
expect(res.errors).toHaveLength(1)
expect(res.errors[0].subject).toEqual({
start: { byte: 40, col: 40, line: 2 },
end: { byte: 108, col: 12, line: 6 },
start: { byte: 41, col: 41, line: 2 },
end: { byte: 109, col: 12, line: 6 },
filename: 'file.nacl',
})
expect(res.errors[0].message).toBe('Unexpected field definition(s) in a primitive type. Expected no fields.')
Expand All @@ -213,7 +213,7 @@ describe('parsing errors', () => {
it('should create the element without the fields', async () => {
const element = (await awu(res.elements).toArray())[0] as PrimitiveType
expect(element.primitive).toBe(PrimitiveTypes.STRING)
expect(element.elemID.getFullName()).toEqual('helter.skater')
expect(element.elemID.getFullName()).toEqual('helter.skelter')
})
})
})
Expand Down Expand Up @@ -856,7 +856,7 @@ describe('parsing errors', () => {
expect(res.errors[0].message).toBe('Expected a value')
expect(res.errors[0].summary).toBe('Expected a value')
})
it('parse the missing value as dynanmic value', async () => {
it('parse the missing value as dynamic value', async () => {
expect(await awu(res.elements).toArray()).toHaveLength(1)
const element = (await awu(res.elements).toArray())[0] as ObjectType
expect(element.elemID).toEqual(new ElemID('penny', 'lane'))
Expand Down Expand Up @@ -903,7 +903,7 @@ describe('parsing errors', () => {
})
})
describe('array definition errors', () => {
describe('when there is a missing comman', () => {
describe('when there is a missing comma', () => {
const nacl = `
type hey.jude {
dont = ["dont", "make" "it", "bad"]
Expand Down Expand Up @@ -1162,7 +1162,7 @@ describe('parsing errors', () => {
`
let res: ParseResult
beforeAll(async () => {
res = await parse(Buffer.from(nacl), 'warlus.nacl', {})
res = await parse(Buffer.from(nacl), 'walrus.nacl', {})
})

it('should throw an error', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ const buildMultiEnvSource = (
remoteMapCreator: RemoteMapCreator,
persistent: boolean,
initState?: MultiEnvState,
// The following is a workaound for SALTO-1428 - remove when fixed
// The following is a workaround for SALTO-1428 - remove when fixed
mergedRecoveryMode: MergedRecoveryMode = REBUILD_ON_RECOVERY,
): MultiEnvSource => {
const commonSource = (): NaclFilesSource => sources[commonSourceName]
Expand Down Expand Up @@ -689,15 +689,15 @@ export const multiEnvSource = (
commonSourceName: string,
remoteMapCreator: RemoteMapCreator,
persistent: boolean,
// The following is a workaound for SALTO-1428 - remove when fixed
// The following is a workaround for SALTO-1428 - remove when fixed
mergedRecoveryMode: MergedRecoveryMode = 'rebuild',
): MultiEnvSource =>
buildMultiEnvSource(
sources,
commonSourceName,
remoteMapCreator,
persistent,
// The following 2 arguments are a workaound for SALTO-1428 - remove when fixed
// The following 2 arguments are a workaround for SALTO-1428 - remove when fixed
undefined,
mergedRecoveryMode,
)
2 changes: 1 addition & 1 deletion packages/workspace/test/common/nacl_file_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ type salesforce.lead {
string base_field {}
}`,

'willbempty.nacl': 'type nonempty { a = 2 }',
'will_be_empty.nacl': 'type nonempty { a = 2 }',
'renamed_type.nacl': `type salesforce.RenamedType1 {
}`,
'fieldsWithHidden.nacl': `
Expand Down
4 changes: 2 additions & 2 deletions packages/workspace/test/path_index_fallbacks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('createPathIndexForElement', () => {
}
`

const redHeringFile = `
const redHerringFile = `
type salesforce.hearing {
salesforce.text multiDef {
Expand All @@ -53,7 +53,7 @@ describe('createPathIndexForElement', () => {
const naclFileStore = mockDirStore(undefined, undefined, {
'firstFile.nacl': firstFile,
'secondFile.nacl': secondFile,
'redHeringFile.nacl': redHeringFile,
'redHerringFile.nacl': redHerringFile,
})

const expected = [
Expand Down

0 comments on commit acd699f

Please sign in to comment.