mirror of
https://github.com/leon-ai/leon.git
synced 2024-09-11 10:25:40 +03:00
chore: clean up ESLint comments and new Prettier/ESLint script
This commit is contained in:
commit
cc317842d8
7
.github/ISSUE_TEMPLATE.md
vendored
7
.github/ISSUE_TEMPLATE.md
vendored
@ -1,7 +0,0 @@
|
||||
<!--
|
||||
|
||||
Thanks for your interest in Leon! ❤️
|
||||
|
||||
Please check if there is no similar issue before creating this one.
|
||||
|
||||
-->
|
@ -14,7 +14,7 @@ if (fs.existsSync(commitEditMsgFile)) {
|
||||
try {
|
||||
const commitMessage = fs.readFileSync(commitEditMsgFile, 'utf8')
|
||||
const regex =
|
||||
'(build|BREAKING|chore|ci|docs|feat|fix|perf|refactor|style|test)(\\((web app|docker|server|hotword|skill\\/([\\w-]+)))?\\)?: .{1,50}' // eslint-disable-line no-useless-escape
|
||||
'(build|BREAKING|chore|ci|docs|feat|fix|perf|refactor|style|test)(\\((web app|docker|server|hotword|skill\\/([\\w-]+)))?\\)?: .{1,50}'
|
||||
|
||||
if (commitMessage.match(regex) !== null) {
|
||||
LOG.success('Commit message validated')
|
||||
|
@ -98,7 +98,7 @@ export default () =>
|
||||
for (let k = 0; k < actionsKeys.length; k += 1) {
|
||||
const action = actionsKeys[k]
|
||||
const actionObj = actions[action]
|
||||
const { entities, http_api } = actionObj // eslint-disable-line camelcase
|
||||
const { entities, http_api } = actionObj
|
||||
let finalMethod = entities || http_api?.entities ? 'POST' : 'GET'
|
||||
|
||||
// Only generate this route if it is not disabled from the skill config
|
||||
|
@ -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()
|
||||
|
@ -37,7 +37,7 @@ export default (lang, nlp) =>
|
||||
const { actions, variables } = await SKILL_DOMAIN.getSkillConfig(
|
||||
configFilePath,
|
||||
lang
|
||||
) // eslint-disable-line no-await-in-loop
|
||||
)
|
||||
const actionsKeys = Object.keys(actions)
|
||||
|
||||
for (let k = 0; k < actionsKeys.length; k += 1) {
|
||||
|
@ -89,17 +89,13 @@ export default () =>
|
||||
const lang = shortLangs[h]
|
||||
|
||||
globalResolversNlp.addLanguage(lang)
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await trainGlobalResolvers(lang, globalResolversNlp)
|
||||
|
||||
skillsResolversNlp.addLanguage(lang)
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await trainSkillsResolvers(lang, skillsResolversNlp)
|
||||
|
||||
mainNlp.addLanguage(lang)
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await trainGlobalEntities(lang, mainNlp)
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await trainSkillsActions(lang, mainNlp)
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,6 @@ class Synchronizer {
|
||||
folderId = list.data.files[i].id
|
||||
return cb(null, true, folderId)
|
||||
} else if (i + 1 === list.data.files.length) {
|
||||
// eslint-disable-line no-else-return
|
||||
return cb(null, false, folderId)
|
||||
}
|
||||
// TODO: UI toolbox to reach this scope
|
||||
|
@ -53,7 +53,7 @@ class Stt {
|
||||
/* istanbul ignore if */
|
||||
if (!IS_TESTING_ENV) {
|
||||
// Dynamically attribute the parser
|
||||
this.parser = require(`${__dirname}/${this.provider}/parser`) // eslint-disable-line global-require
|
||||
this.parser = require(`${__dirname}/${this.provider}/parser`)
|
||||
this.parser.default.init(this.parser.default.conf)
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ class Tts {
|
||||
}
|
||||
|
||||
// Dynamically attribute the synthesizer
|
||||
this.synthesizer = require(`${__dirname}/${this.provider}/synthesizer`) // eslint-disable-line global-require
|
||||
this.synthesizer = require(`${__dirname}/${this.provider}/synthesizer`)
|
||||
this.synthesizer.default.init(LANG.getLongCode(this.lang))
|
||||
|
||||
this.onSaved()
|
||||
|
@ -28,7 +28,6 @@ describe('NLU modules', () => {
|
||||
)
|
||||
|
||||
for (let i = 0; i < langKeys.length; i += 1) {
|
||||
// eslint-disable-next-line no-loop-func
|
||||
describe(`${langKeys[i]} language`, () => {
|
||||
const lang = langs[langKeys[i]]
|
||||
const nlu = new Nlu()
|
||||
@ -52,7 +51,6 @@ describe('NLU modules', () => {
|
||||
})
|
||||
|
||||
for (let j = 0; j < packages.length; j += 1) {
|
||||
// eslint-disable-next-line no-loop-func
|
||||
describe(`${packages[j]} package`, () => {
|
||||
const utteranceSamplesFile = `${global.paths.packages}/${packages[j]}/data/expressions/${lang.short}.json`
|
||||
utteranceSamplesObj = JSON.parse(
|
||||
@ -64,7 +62,6 @@ describe('NLU modules', () => {
|
||||
const module = modules[k]
|
||||
const actions = Object.keys(utteranceSamplesObj[module])
|
||||
|
||||
// eslint-disable-next-line no-loop-func
|
||||
describe(`${module} module`, () => {
|
||||
for (let l = 0; l < actions.length; l += 1) {
|
||||
const action = actions[l]
|
||||
@ -72,7 +69,6 @@ describe('NLU modules', () => {
|
||||
utteranceSamplesObj[module][action].utterance_samples
|
||||
|
||||
for (let m = 0; m < exprs.length; m += 1) {
|
||||
// eslint-disable-next-line no-loop-func
|
||||
test(`"${exprs[m]}" queries this module`, async () => {
|
||||
// Need to redefine the NLU brain execution to update the mocking
|
||||
nlu.brain.execute = jest.fn()
|
||||
|
@ -16,7 +16,6 @@ describe('are JSON files valid', () => {
|
||||
const jsonFile = path.join(global.paths.root, dir, entities[i])
|
||||
test(`${jsonFile} has valid JSON syntax`, () => {
|
||||
try {
|
||||
// eslint-disable-line no-useless-catch
|
||||
JSON.parse(fs.readFileSync(jsonFile, 'utf8'))
|
||||
|
||||
expect(true).toBe(true)
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user