Skip to content

Commit

Permalink
more eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
sadiqkhoja committed Apr 16, 2024
1 parent f64c161 commit fd3c755
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 66 deletions.
5 changes: 2 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
"editor.formatOnSave": true
},
"[vue]": {
// Vue files are ignored in Prettier. Some formatting **will** be applied
// on save by ESLint (via `editor.codeActionsOnSave` settings above)
"editor.formatOnSave": false
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.formatOnSave": true
},
// This corresponds to the `lib` we're using everywhere. Setting it here
// helps to address editor-only type errors in tooling files, where VSCode
Expand Down
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ export default tseslint.config(
// should be based on the printWidth
'vue/max-attributes-per-line': 'off',
'vue/no-undef-components': 'error',
'vue/html-comment-indent': ['error', 'tab'],
'vue/script-indent': ['error', 'tab'],
'vue/no-empty-component-block': 'error',
},
},

Expand Down
15 changes: 5 additions & 10 deletions packages/ui-vue/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,21 @@ onErrorCaptured((error) => {
});

const formFixtureGlobImports = import.meta.glob<true, 'raw', string>('../../ui-solid/fixtures/xforms/**/*.xml', {
query: '?raw',
import: 'default',
eager: true,
query: '?raw',
import: 'default',
eager: true,
});
const demoForms = Object.entries(formFixtureGlobImports);

demoForms.forEach(f => {
f[0] = f[0].replace('../../ui-solid/fixtures/xforms/', '')
f[0] = f[0].replace('../../ui-solid/fixtures/xforms/', '')
})


const selectForm = ref<[string, string] | null>(null);

const handleSubmit = (data: string) => {
alert(`Submit button was pressed. Data: ${data}`); // eslint-disable-line no-undef -- alert is defined globally
alert(`Submit button was pressed. Data: ${data}`); // eslint-disable-line no-undef -- alert is defined globally
}

</script>


<style>

</style>
4 changes: 0 additions & 4 deletions packages/ui-vue/src/components/OdkControlLabel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@
import type { AnyLeafNode } from '@odk-web-forms/xforms-engine';
const props = defineProps<{question: AnyLeafNode}>();
</script>

<style scoped>

</style>
18 changes: 7 additions & 11 deletions packages/ui-vue/src/components/OdkForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ const odkForm = ref<RootNode>();
const emit = defineEmits(['submit']);

initializeForm(props.formXml, {
config: {
stateFactory: reactive
},
}).then((f) => {
odkForm.value = f;
// TODO/sk: remove once dust settles
// eslint-disable-next-line -- temporary code
config: {
stateFactory: reactive
},
}).then((f) => {
odkForm.value = f;
// TODO/sk: remove once dust settles
// eslint-disable-next-line -- temporary code
console.log((f as any).childrenState.getChildren());
}).catch(() => {}); // eslint-disable-line -- noop

Expand All @@ -57,7 +57,3 @@ const handleSubmit = () => {
emit('submit', (odkForm as any).value.contextNode.outerHTML); // eslint-disable-line
}
</script>

<style>

</style>
4 changes: 0 additions & 4 deletions packages/ui-vue/src/components/OdkGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,3 @@ defineProps<{ question: GroupNode }>();


</script>

<style scoped>

</style>
6 changes: 3 additions & 3 deletions packages/ui-vue/src/components/OdkPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const props = withDefaults(defineProps<{title?: string, menuItems?: MenuItem[],
});

const panelClass = computed(() => [
'with-title',
props.menuItems && props.menuItems.length > 0 ? 'with-context-menu' : 'no-context-menu',
'with-title',
props.menuItems && props.menuItems.length > 0 ? 'with-context-menu' : 'no-context-menu',
props.class
]);

Expand All @@ -51,7 +51,7 @@ const toggle = () => {
const menu = ref<Menu & MenuState>();

const toggleMenu = (event: Event) => {
menu.value?.toggle(event);
menu.value?.toggle(event);
};

</script>
4 changes: 0 additions & 4 deletions packages/ui-vue/src/components/OdkQuestionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,3 @@ const isRepeatRangeNode = (n: GeneralChildNode) : n is RepeatRangeNode => n.defi


</script>

<style scoped>

</style>
6 changes: 1 addition & 5 deletions packages/ui-vue/src/components/OdkRepeat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,4 @@ const props = defineProps<{ question: RepeatRangeNode}>();

const label = computed(() => props.question.currentState.label?.asString);

</script>

<style scoped>

</style>
</script>
22 changes: 9 additions & 13 deletions packages/ui-vue/src/components/OdkRepeatInstance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ const emit = defineEmits(['remove']);

const isGroup = (child: GeneralChildNode) => {
return (
child.definition.bodyElement?.type === 'logical-group' ||
child.definition.bodyElement?.type === 'presentation-group'
);
child.definition.bodyElement?.type === 'logical-group' ||
child.definition.bodyElement?.type === 'presentation-group'
);
}

const label = computed(() => {
// It has just one child and that is a group with label
// then we use label of that group
if( props.instance.currentState.children.length === 1 &&
isGroup(props.instance.currentState.children[0]) &&
props.instance.currentState.children[0].currentState.label
if( props.instance.currentState.children.length === 1 &&
isGroup(props.instance.currentState.children[0]) &&
props.instance.currentState.children[0].currentState.label
) {
return props.instance.currentState.children[0].currentState.label?.asString
}

// Use RepeatRangeNode label if it's there
// TODO/sk: use state.label.asString
if(props.instance.parent.definition.bodyElement.label?.children[0]?.stringValue){
if(props.instance.parent.definition.bodyElement.label?.children[0]?.stringValue){
return `${props.instance.parent.definition.bodyElement.label?.children[0].stringValue} ${props.instanceIndex + 1}`;
}

Expand All @@ -44,7 +44,7 @@ const label = computed(() => {
const children = computed(() => {
// It has just one child and that is a group
// then we use its children - essentially coalesce RepeatInstance and Group into one.
if(props.instance.currentState.children.length === 1 && isGroup(props.instance.currentState.children[0])){
if(props.instance.currentState.children.length === 1 && isGroup(props.instance.currentState.children[0])){
return (props.instance.currentState.children[0] as GroupNode).currentState.children;
}
else{
Expand All @@ -56,8 +56,4 @@ const menuItems: MenuItem[] = [
{label: 'Remove', icon: 'icon-delete', command: () => emit("remove")}
];

</script>

<style scoped>

</style>
</script>
4 changes: 0 additions & 4 deletions packages/ui-vue/src/components/controls/InputText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,3 @@ const setValue = (e:Event) => {
}

</script>

<style scoped>

</style>
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,4 @@ defineProps<{question: AnyLeafNode}>();
const isDev = () => {
return import.meta.env.DEV;
}
</script>

<style scoped>

</style>
</script>

0 comments on commit fd3c755

Please sign in to comment.