Skip to content

Instantly share code, notes, and snippets.

@maksimr
Last active May 19, 2025 22:53
Show Gist options
  • Save maksimr/768e380534374164793b76d1f9fbceec to your computer and use it in GitHub Desktop.
Save maksimr/768e380534374164793b76d1f9fbceec to your computer and use it in GitHub Desktop.
no-omit aslant
// @ts-check
/**@type {import('eslint').Rule.RuleModule}*/
module.exports = {
meta: {
type: 'problem',
docs: {
description: 'Disallow the use of Omit type',
}
},
create(context) {
return (
/**@type {import('@typescript-eslint/utils/eslint-utils').RuleListener}*/
({
'TSTypeReference'(node) {
if (node.typeName.type === 'Identifier' && node.typeName.name === 'Omit') {
context.report({
loc: node.loc,
message: 'Omit type is not allowed',
});
}
},
})
);
}
}
@maksimr
Copy link
Author

maksimr commented May 19, 2025

//@ts-check
...
import NoOmit from './rules/no-omit.js';

/**@type {import('eslint').Linter.Config}*/
const eslintConfig = {
  'plugins': {
    'custom': {
      rules: {
        'no-omit': NoOmit,
      }
    }
  },
  'rules': {
     ...,
    'custom/no-omit': 'error'
  },
  ...
};

export default eslintConfig;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment