Skip to content

Commit

Permalink
Update eslint (#2092)
Browse files Browse the repository at this point in the history
* Update eslint and prettier

* Update linters again

* Remove vue-cli eslint, use vue/vue3-recommended plugin and enforce component names in PascalCase

* Lint (with prettier) json files

* Remove eslint prettier plugin and install typescript-eslint, not the vue-cli one

* using debugger statement in production set to throw an error

* replace legacy tslint ignores with eslint ignore

* Add eslintcache to gitignore

* Remove prettierrc for now

* Remove Nodejs global

* Add comments

* Fix version in package-lock

* Add tailwind eslint plugin

* Clean

* Package merge

* Add pretty-quick

* Eslint autofix

* Add prettier as eslint plugin, run pretty-quick only for md, json, yaml and html files

* Add prettier vue

* Autofix event name casing

* Fix or ignore vue/require-default-prop rule case by case

* Add prettier check back to package.json

* Fix other errors manually

* Lint pre-commit

* Update husky

* Add lint staged

* Try lint staged

* Add lint-staged

* Try with error

* Remove eslint cache and try again

* Try with error for real

* Try with error, don't allow warnings again

* Try with autofix

* Add prettier:fix script back

* prettier:fix inherits variables from prettier script

* Add --loglevel warn to prettier script

* Set better default props

* Make dependencies prop optional again

* Change vue/attribute-hyphenation rule from "always" to "never"
  • Loading branch information
simeonkerkola authored Aug 2, 2022
1 parent cc29c5a commit d2263dc
Show file tree
Hide file tree
Showing 214 changed files with 4,240 additions and 2,724 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
dist/
tokenlists.json
package-lock.json
51 changes: 32 additions & 19 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,15 @@ module.exports = {
node: true,
},

globals: {
NodeJS: true,
withDefaults: true,
defineProps: true,
defineEmits: true,
defineExpose: true,
},

extends: [
'plugin:vue/vue3-essential',
'eslint:recommended',
'@vue/typescript/recommended',
'@vue/typescript',
'plugin:tailwindcss/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:vue/vue3-recommended',
'plugin:prettier-vue/recommended',
],

plugins: ['simple-import-sort'],
plugins: ['simple-import-sort', 'tailwindcss'],

parserOptions: {
ecmaVersion: 2020,
Expand All @@ -29,17 +22,37 @@ module.exports = {

rules: {
'no-console': 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/no-undef': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'simple-import-sort/imports': 'warn',
'simple-import-sort/exports': 'warn',
'tailwindcss/no-custom-classname': 'off',

// Require passing prop names in camelCase
'vue/attribute-hyphenation': ['error', 'never'],

// Inserting html is a potential XSS risk. Consider disabling this rule case-by-case basis
'vue/no-v-html': 'off',

// Our component names are already written in PascalCase.
// And for consistency, it's now required too.
'vue/component-name-in-template-casing': ['error', 'PascalCase'],

// Vue recommends multi word component names, so they don't get mixed with
// regular html elements, but many component's names are already single
// word, so had to turn this off.
'vue/multi-word-component-names': 'off',

// Event names are written in kebab-case, as it's in plugin:vue/vue3-recommended.
// This just turns the autofix option on.
'vue/v-on-event-hyphenation': [
'error',
'always',
{
autofix: true,
},
],
},

overrides: [
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ node_modules
.env.local
.env.*.local

# cache files
.eslintcache

# Log files
npm-debug.log*
yarn-debug.log*
Expand Down
7 changes: 3 additions & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run prettier:fix
npm run lint:fix
npx lint-staged
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist/
build/
public/data/tokenlists.json
Loading

5 comments on commit d2263dc

@vercel
Copy link

@vercel vercel bot commented on d2263dc Aug 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on d2263dc Aug 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on d2263dc Aug 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on d2263dc Aug 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on d2263dc Aug 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.