Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspace configuration #62

Merged
merged 8 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test for configObject option
  • Loading branch information
joe-re committed Sep 8, 2020
commit 093864cec39f059c4f78f759a711737399d425d2
4 changes: 2 additions & 2 deletions packages/sqlint/src/cli/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export function lint (
let result: LintResult[] = text
? [{ filepath: 'text', diagnostics: execute(text, config) }]
: files.map(v => {
const diaglostics = execute(readFile(v), config)
return { filepath: v, diagnostics: diaglostics }
const diagnostics = execute(readFile(v), config)
return { filepath: v, diagnostics: diagnostics }
}).flat()

let output = ''
Expand Down
21 changes: 21 additions & 0 deletions packages/sqlint/test/cli/lint.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,27 @@ describe('lint', () => {
})
})

describe('configObject', () => {
it('should do lint according to configObject given', () => {
const before = JSON.parse(lint({
text: 'select * from bar',
formatType: 'json',
configPath: `${__dirname}/fixtures/lint`
}))
expect(before.length).toEqual(1)
expect(before[0].diagnostics.length).toEqual(2)

const result = lint({
text: 'select * from bar',
formatType: 'json',
configObject: { rules: { "reserved-word-case": "off" } }
})
const parsed = JSON.parse(result)
expect(parsed.length).toEqual(1)
expect(parsed[0].diagnostics.length).toEqual(0)
})
})

describe('fix', () => {
it('should be fixed correctly. case1', () => {
const sql = 'SELECT employees.first_name, employees.email, e.first_name, e.department_id, e.manager_id, e.hire_date' +
Expand Down