43081j / 43081j/eslint-plugin-wc

Do not override author-set, global attributes

Aberta Para iniciantes
#4 0 comentários 0 reações 1 responsável Reivindicada por @43081j Ver no GitHub
new lint rule
Linguagem predominante
TypeScript
Estrelas
113
Forks
19
Merge médio
3h 14min
PRs com merge (30d)
2

Descrição

> Global attributes are those that are present on all HTML elements. Some examples include `tabindex` and `role`. A custom element may wish to set its initial `tabindex` to `0` so it will be keyboard focusable. But you should always check first to see if the developer using your element has set this to another value. If, for example, they've set `tabindex` to `-1`, it's a signal that they don't wish for the element to be interactive.

Ensure that there is a check for the attribute before altering (set/remove) the attribute in the `connectedCallback`.

```
if (!this.hasAttribute('foo')) this.setAttribute('foo', 'bar')
```

Resource:
https://developers.google.com/web/fundamentals/web-components/best-practices#do-not-override-author-set-global-attributes
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Direção de pesquisa

Veja as definições de regras do plugin ESLint, provavelmente no diretório lib/rules. Encontre regras que definem ou removem atributos em connectedCallback. Verifique cada uma em busca de uma condição de guarda como `if (!this.hasAttribute('foo'))`. Execute os testes existentes para ver quais regras falham e então adicione as verificações ausentes. Verifique fazendo lint de um custom element de exemplo.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
html, javascript
Domínio
tooling, web-dev
Tipo de issue
Bug
Dificuldade
2/5
Tempo estimado
1-3 horas
Status de atividade
Estagnada
Clareza
Claramente especificada
Facilidade para iniciantes
65/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.