1
1
mirror of https://github.com/leon-ai/leon.git synced 2025-01-04 15:55:58 +03:00

perf: improve scripts/lint

This commit is contained in:
Divlo 2022-09-16 22:36:45 +02:00
parent dabd657acf
commit ef8374d03b
No known key found for this signature in database
GPG Key ID: 8F9478F220CE65E9

View File

@ -3,6 +3,32 @@ import { command } from 'execa'
import log from '@/helpers/log'
import loader from '@/helpers/loader'
const globs = [
'"app/src/js/*.{ts,js}"',
// TODO: deal with it once handling new hotword
// '"hotword/index.{ts,js}"',
// TODO: put it back once tests have been reintroduced into skills
// '"skills/**/*.js"',
'"scripts/**/*.{ts,js}"',
'"server/src/**/*.{ts,js}"'
// TODO: put it back once tests need to be written
/*'"test/!*.js"',
'"test/e2e/!**!/!*.js"',
'"test/json/!**!/!*.js"',
'"test/unit/!**!/!*.js"'*/
]
const src = globs.join(' ')
async function prettier() {
await command('prettier --write . --ignore-path .gitignore', {
shell: true
})
await command(`prettier --check ${src} --ignore-path .gitignore`, {
shell: true,
stdio: 'inherit'
})
}
/**
* This script ensures the correct coding syntax of the whole project
*/
@ -11,26 +37,13 @@ import loader from '@/helpers/loader'
log.info('Linting...')
try {
const globs = [
'"app/src/js/*.{ts,js}"',
// TODO: deal with it once handling new hotword
// '"hotword/index.{ts,js}"',
// TODO: put it back once tests have been reintroduced into skills
// '"skills/**/*.js"',
'"scripts/**/*.{ts,js}"',
'"server/src/**/*.{ts,js}"'
// TODO: put it back once tests need to be written
/*'"test/!*.js"',
'"test/e2e/!**!/!*.js"',
'"test/json/!**!/!*.js"',
'"test/unit/!**!/!*.js"'*/
]
const src = globs.join(' ')
await command(
`prettier --write . --ignore-path .gitignore && eslint ${src} --ignore-path .gitignore && prettier --check ${src} --ignore-path .gitignore`,
{ shell: true }
)
await Promise.all([
prettier(),
command(`eslint ${src} --ignore-path .gitignore`, {
shell: true,
stdio: 'inherit'
})
])
log.success('Looks great')
loader.stop()