Skip to content

Commit

Permalink
Merge pull request #922 from 3YOURMIND/place-rule-into-requiring-types
Browse files Browse the repository at this point in the history
fix(eslint): put restrict-template-expressions into rules for which types are required
  • Loading branch information
Isokaeder authored May 15, 2024
2 parents c0407c7 + 8ea4714 commit 620e3ec
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 34 deletions.
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@
},
"type": "module",
"types": "./dist/mjs/index.d.ts",
"version": "0.0.2"
"version": "0.0.3"
}
37 changes: 19 additions & 18 deletions packages/eslint-config/source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,6 @@ const baseConfig = tseslint.config({
{ argsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_' },
],
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowAny: false,
allowBoolean: false,
allowNullish: false,
allowNumber: true,
allowRegExp: false,
allowNever: false,
},
],

// Eslint
'dot-notation': 'warn',
Expand Down Expand Up @@ -274,6 +263,17 @@ const rulesRequiringTypes = {
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/restrict-template-expressions': [
'error',
{
allowAny: false,
allowBoolean: false,
allowNullish: false,
allowNumber: true,
allowRegExp: false,
allowNever: false,
},
],
'@typescript-eslint/switch-exhaustiveness-check': 'error',
} satisfies SharedConfig.RulesRecord

Expand Down Expand Up @@ -375,11 +375,6 @@ export default {
plugins: { vitest },
extends: [vitest.configs.recommended, ...baseConfig],
rules: {
'no-console': 'off',
'no-magic-numbers': 'off',
'vitest/no-disabled-tests': 'error',
'vitest/no-identical-title': 'error',
'vue/one-component-per-file': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/naming-convention': 'off',
Expand All @@ -388,9 +383,15 @@ export default {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'no-console': 'off',
'no-magic-numbers': 'off',
'vitest/no-disabled-tests': 'error',
'vitest/no-identical-title': 'error',
'vue/one-component-per-file': 'off',
},
}),
/**
Expand Down Expand Up @@ -447,7 +448,7 @@ export default {
'vue/no-empty-component-block': 'error',
'vue/no-mutating-props': 'error',
'vue/no-ref-as-operand': 'error',
'vue/no-setup-props-destructure': 'error',
'vue/no-setup-props-reactivity-loss': 'error',
'vue/no-unused-properties': 'error',
'vue/no-unused-refs': 'error',
'vue/no-useless-mustaches': ['warn', { ignoreIncludesComment: true }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ export default createRule({
},
],
},
definitions: {
nestedObject: {
type: 'object',
additionalProperties: {
anyOf: [
{ type: 'string' },
{
$ref: '#/definitions/nestedObject',
},
],
},
},
definitions: {
nestedObject: {
type: 'object',
additionalProperties: {
anyOf: [
{ type: 'string' },
{
$ref: '#/definitions/nestedObject',
},
],
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/kotti-ui/source/kotti-comment/KtCommentInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default defineComponent({
},
props: makeProps(KottiCommentInput.propsSchema),
setup(props, { emit }) {
// eslint-disable-next-line vue/no-setup-props-destructure
// eslint-disable-next-line vue/no-setup-props-reactivity-loss
const localIsInternal = ref<KottiComment.PropsInternal['isInternal']>(
props.isInternal,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default defineComponent({
},
},
setup(props, { emit }) {
/* eslint-disable vue/no-setup-props-destructure */
/* eslint-disable vue/no-setup-props-reactivity-loss */
/**
* FIXME: This is not reactive and will likely cause issues. Fixing this
* would require adjusting types in KottiForm.Context to support computed
Expand All @@ -46,7 +46,6 @@ export default defineComponent({
validators: props.context.validators,
values: computed(() => props.values),
})
/* eslint-enable vue/no-setup-props-destructure */
},
})
</script>
1 change: 0 additions & 1 deletion packages/kotti-ui/source/make-props.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ expect.extend({
return {
message: () => {
if (!passNoDefault)
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
return `Expected “prop.default” to be “undefined”. Was “${prop.default}”`
if (!passRequired)
return `Expected “prop.required” to be “true”. Was “${String(prop.required)}”`
Expand Down

0 comments on commit 620e3ec

Please sign in to comment.