Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
Is it possible to create a custom esLint rule that would warn users on using a particular component?

We use Bootstrap-vue in our project, but we have a few files that extend the basic bootstrap component, e.g. <form-group> rather than Bootstrap-Vue's provided <b-form-group>.

I want to ensure that users use the <form-group> element only, and I don't want to have to read through PRs to see if they've accidentally forgotten. Is it possible to create an ES Lint rule that would flag up to a user that they should use <form-group> rather than <b-form-group>?

Thanks in advance!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You could overwrite the bootstrap component to throw when used?

import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'  
Vue.use(BootstrapVue);

const Base = Vue.options.components["b-form-group"];
const DeprecatedForm = Base.extend({
  methods: {
    beforeCreate() {
      throw new Error("[DEPRECATED] 'b-form-group' should not be used, prefer using 'form-group'");
    },
  })
}

Vue.component('b-form-group', DeprecatedForm );

Unfortunatly this does not answer the request of using ESLint for this. But it will ultimatly prevent the use of the component.

Another way could be to simply replace the bootstrap component with yours so that both can be used, but this may lead to confusion... You'd do this:

import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'  
Vue.use(BootstrapVue);

const Base = Vue.options.components["form-group"];
// I think we need to create a new component, maybe not?
const Form= Base.extend({});
Vue.component('b-form-group', DeprecatedForm );
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda