Skip to content

Commit

Permalink
feat: create sharable config
Browse files Browse the repository at this point in the history
  • Loading branch information
levibostian committed Apr 7, 2020
1 parent 79bb296 commit 720926d
Show file tree
Hide file tree
Showing 20 changed files with 18,502 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
example/
.releaserc
.travis.yml
.nvmrc
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/*
19 changes: 19 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"tagFormat": "${version}",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/changelog", {
"changelogFile": "CHANGELOG.md"
}],
"@semantic-release/npm",
"@semantic-release/github",
["@semantic-release/git", {
"assets": [
"CHANGELOG.md",
"package.json",
"package-lock.json"
]
}]
]
}
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: node_js

install:
- npm ci

cache:
npm: true

jobs:
include:
- stage: test
script:
- commitlint-travis
- stage: deploy
script:
- npx semantic-release

stages:
- name: test
if: type IN (push, pull_request) AND tag IS blank
- name: deploy
if: type IN (push) AND branch = master
Empty file added CHANGELOG.md
Empty file.
50 changes: 48 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,48 @@
# eslint-shareable-web
Sharable eslint config file we use on the web team
# @foundersclubsoftware/eslint-shareable-web

[Sharable eslint config file](https://eslint.org/docs/developer-guide/shareable-configs) we use on the web team.

# Mission of this project

This config file is not meant to replace the entire Vuejs eslint config file. It's meant to extend it with more functionality. On this team, we write tests with Jest, we use babel, and we use typescript. These rules are meant to add more rules to eslint to write more consistent and safe code.

Vuejs is changing all the time. It would be difficult to make 1 config file that worked for all vue projects all the time. If this was a vanilla typescript nodejs app, creating a single config file would be more possible. This project's sharable config file contains mostly typescript and jest rules but can also contain other rules as well.

# Getting started

1. Install your dependencies:

```bash
npm install -D @foundersclubsoftware/eslint-shareable-web

# These are modules that are required by the shareable config
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"
}
```

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.

# Development

* Setup

```
npm install
```

* Use the example project located in `example/` to test out your changes to the config project.

* This project follows a strict semantic versioning policy. The policy is enforced on the CI server where it will not allow you to merge your PR unless your commit messages are in the correct format. To learn more, check out [this doc](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines).

* Make a PR, the team will merge it in, the a release will be made.

# License

See [LICENSE](LICENSE.md)
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']}
16 changes: 16 additions & 0 deletions example/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
root: true,
env: {
node: true
},
extends: [
"plugin:vue/essential",
"../index.js",
"@vue/typescript/recommended",
"@vue/prettier",
"@vue/prettier/@typescript-eslint"
],
parserOptions: {
ecmaVersion: 2020
}
};
26 changes: 26 additions & 0 deletions example/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png" />
<HelloWorld msg="Welcome to Your Vue.js + TypeScript App" />
</div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
export default class App extends Vue {}
const foo: any = "";
console.log(foo);
</script>

<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
18 changes: 18 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Example project

This example vuejs application is meant to be a place that you can test out your changes to the sharable eslint config file.

This example project was generated using the vuejs CLI tool:

![options selected](cli_config.png)

Vuejs is changing all the time. This example project may need to be regenerated at some point.

# Getting started

```
npm install
npm run lint
```

You will probably see errors and warnings printed to the console. That's ok! We want that to happen because it shows that the eslint config is working.
Binary file added example/cli_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions example/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Vue from "vue";
import App from "./App.vue";

Vue.config.productionTip = false;

const foo: any = "";
console.log(foo);

new Vue({
render: h => h(App)
}).$mount("#app");
Loading

0 comments on commit 720926d

Please sign in to comment.