Skip to content

Commit

Permalink
feat: add more typescript rules
Browse files Browse the repository at this point in the history
Add better docs on where to add shareable config
  • Loading branch information
levibostian committed Apr 7, 2020
1 parent 720926d commit c94523e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@ npm install -D @typescript-eslint/eslint-plugin @typescript-eslint/parser
2. Enable the config by adding to your existing `.eslintrc.js` file:

```
{
extends: "@foundersclubsoftware/eslint-shareable-web"
}
module.exports = {
parser: "vue-eslint-parser",
extends: [
"plugin:vue/essential",
"@vue/typescript/recommended",
# shareable needs to be the last config before prettier so it can override other rules defined in configs above.
"@foundersclubsoftware/eslint-shareable-web",
# Make sure prettier last to run prettier.
"@vue/prettier",
"@vue/prettier/@typescript-eslint"
]
};
```

3. Modify your project's lint script in `package.json`. Change `"lint": "vue-cli-service lint"` to `"lint": "vue-cli-service lint --ext .ts,.js,.vue ."`. This is needed because if you do not pass in arguments to `vue-cli-service lint`, it will [automatically lint only .js and .vue files in src/ and tests/](https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-eslint/README.md#injected-commands). We want to also enable `.ts` files.
Expand Down
8 changes: 5 additions & 3 deletions example/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ module.exports = {
env: {
node: true
},
extends: [
"plugin:vue/essential",
"../index.js",
parser: "vue-eslint-parser",
extends: [
"plugin:vue/essential",
"@vue/typescript/recommended",

"../index.js",
"@vue/prettier",
"@vue/prettier/@typescript-eslint"
],
Expand Down
4 changes: 4 additions & 0 deletions example/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export default class App extends Vue {}
const foo: any = "";
console.log(foo);
callFunctionBeforeDefine();
const callFunctionBeforeDefine = () => {};
</script>

<style>
Expand Down
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ module.exports = {
{
"args": "none"
}
]
],
"@typescript-eslint/no-use-before-define": [
"error",
{
"functions": true,
"classes": false
}
],
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-empty-function": "off"
}
};

0 comments on commit c94523e

Please sign in to comment.