Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds TypeScript flavor packages for ESLint #89

Merged
merged 6 commits into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# godaddy-style

Official GoDaddy JavaScript styleguide. It includes `eslint` packages for three use-cases and can be used as a standard in any new project.
Official GoDaddy JavaScript styleguide. It includes `eslint` packages for various use-cases and can be used as a standard in any new project.

- [`eslint-config-godaddy`]: Base configuration for _non-React_, ES6 JavaScript applications
- [`eslint-config-godaddy-react`]: Configuration for ES6 React JavaScript applications
- [`eslint-config-godaddy-es5`]: Configuration for React _and_ non-React ES5 JavaScript applications
- [`eslint-config-godaddy-typescript`]: Configuration for ES6 TypeScript applications
- [`eslint-config-godaddy-react-typescript`]: Configuration for ES6 React JavaScript applications
- [`eslint-config-godaddy-flow`]: Configuration for ES6 React JavaScript applications using Flow
andyfleming marked this conversation as resolved.
Show resolved Hide resolved
- [`eslint-config-godaddy-react-flow`]: Configuration for ES6 React JavaScript applications using Flow

There are many useful features:
Expand Down Expand Up @@ -36,6 +39,15 @@ npm i eslint-config-godaddy-react --save-dev
# OR (legacy ES5 with React rules)
npm i eslint-config-godaddy-es5 --save-dev

# OR (ES6 with TypeScript rules)
npm i eslint-config-godaddy-typescript --save-dev

# OR (ES6 with React and TypeScript rules)
npm i eslint-config-godaddy-react-typescript --save-dev

# OR (ES6 with Flow rules)
npm i eslint-config-godaddy-flow --save-dev

# OR (ES6 with React and Flow rules)
npm i eslint-config-godaddy-react-flow --save-dev
```
Expand Down Expand Up @@ -142,4 +154,7 @@ No problem. Reach out to us by [opening an issue]
[`eslint-config-godaddy`]: /packages/eslint-config-godaddy
[`eslint-config-godaddy-react`]: /packages/eslint-config-godaddy-react
[`eslint-config-godaddy-es5`]: /packages/eslint-config-godaddy-es5
[`eslint-config-godaddy-typescript`]: /packages/eslint-config-godaddy-typescript
[`eslint-config-godaddy-react-typescript`]: /packages/eslint-config-godaddy-react-typescript
[`eslint-config-godaddy-flow`]: /packages/eslint-config-godaddy-react-flow
[`eslint-config-godaddy-react-flow`]: /packages/eslint-config-godaddy-react-flow
164 changes: 164 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@
"description": "The approach to JavaScript at GoDaddy. We think it's pretty decent.",
"scripts": {
"lint": "eslint -c .eslintrc.js packages/**/*.js",
"postinstall": "run-p install:config install:config:es5 install:config:react install:config:react-flow",
"postinstall": "run-p install:config install:config:es5 install:config:flow install:config:react install:config:react-flow install:config:typescript install:config:react-typescript",
"install:config": "cd packages/eslint-config-godaddy && npm install",
"install:config:es5": "cd packages/eslint-config-godaddy-es5 && npm install",
"install:config:flow": "cd packages/eslint-config-godaddy-flow && npm install",
"install:config:react": "cd packages/eslint-config-godaddy-react && npm install",
"install:config:react-flow": "cd packages/eslint-config-godaddy-react-flow && npm install",
"test": "run-p lint test:config test:config:es5 test:config:react test:config:react-flow",
"install:config:typescript": "cd packages/eslint-config-godaddy-typescript && npm install",
"install:config:react-typescript": "cd packages/eslint-config-godaddy-react-typescript && npm install",
"test": "run-p lint test:config test:config:es5 test:config:flow test:config:react test:config:react-flow test:config:typescript test:config:react-typescript",
"test:config": "cd packages/eslint-config-godaddy && npm test",
"test:config:es5": "cd packages/eslint-config-godaddy-es5 && npm test",
"test:config:flow": "cd packages/eslint-config-godaddy-flow && npm test",
"test:config:react": "cd packages/eslint-config-godaddy-react && npm test",
"test:config:react-flow": "cd packages/eslint-config-godaddy-react-flow && npm test",
"test:config:typescript": "cd packages/eslint-config-godaddy-typescript && npm test",
"test:config:react-typescript": "cd packages/eslint-config-godaddy-react-typescript && npm test",
"prepush": "npm test"
},
"prepush": {
Expand All @@ -28,6 +34,7 @@
"keywords": [
"godaddy",
"javascript",
"typescript",
"lint",
"styleguide",
"style-guide",
Expand All @@ -50,6 +57,8 @@
"godaddy-js-style-eslint": "./bin/eslint"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.3.1",
"@typescript-eslint/parser": "^2.3.1",
"babel-eslint": "^10.0.2",
"eslint": "^6.0.1",
"eslint-find-rules": "^3.3.1",
Expand All @@ -60,7 +69,8 @@
"eslint-plugin-mocha": "^5.3.0",
"eslint-plugin-react": "^7.14.2",
"prepush": "^3.1.11",
"react": "^16.8.6"
"react": "^16.8.6",
"typescript": "^3.0"
},
"dependencies": {
"npm-run-all": "^4.0.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-godaddy-flow/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions packages/eslint-config-godaddy-react-typescript/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./index.js"
}
2 changes: 2 additions & 0 deletions packages/eslint-config-godaddy-react-typescript/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
.eslintrc
55 changes: 55 additions & 0 deletions packages/eslint-config-godaddy-react-typescript/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# eslint-config-godaddy-react-typescript

Configuration for ES6 React JavaScript applications using React and TypeScript, officially used at GoDaddy. There are many useful features:

- **Standard. No configuration.** – Stop worrying about style and focus on your work.
- **Modern** – Uses modern linting tools like `eslint`.
- **Auto-fix** – Auto-fix is enabled by-default through in `eslint`. Many rules will fix themselves!

This styleguide is used by dozens of product teams at GoDaddy. Have a question or comment? [Open an issue!](https://github.com/godaddy/javascript/issues/new)

## Installation

``` sh
# ES6 (including React rules)
npm i eslint-config-godaddy-react-typescript --save-dev
```

## Usage

There are two ways to use this styleguide depending on your own tooling preference: directly using pre-included binaries or running `eslint` yourself with a custom `.eslintrc` config.

##### 1. Use the pre-included binaries.

These use _exactly_ the configuration defined in this package (`eslint-config-godaddy-react-typescript`) **with auto-fix enabled automatically.**

``` js
{
"scripts": {
"lint": "eslint-godaddy-react-typescript files/ you/ want-to/ lint/"
}
}
```

##### 2. Define your local `.eslintrc` and run `eslint` yourself:

``` js
module.exports = {
extends: 'godaddy-react-typescript',
rules: {
//
// Put any rules you wish to override here.
//
}
}
```

The `--fix` option in `eslint` is [**only** available as a CLI option](https://github.com/eslint/eslint/issues/8041). Auto-fix will *NOT be enabled* unless you run `eslint --fix` in your `package.json`.

``` js
{
"scripts": {
"lint": "eslint --fix files/ you/ want-to/ lint/"
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node
require('eslint-config-godaddy/cli')(
require('path').join(__dirname, '..', 'index')
);
17 changes: 17 additions & 0 deletions packages/eslint-config-godaddy-react-typescript/extends.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var path = require('path');

/**
* Helper function that attempts to resolve the specify named `config`
* locally before attempting to resolve it from `node_modules`. This
* tricks TravisCI into resolving correctly.
*
* @param {string} config Named `eslint-config-*` module
* @returns {string} Full path resolved locally or from `node_modules`.
*/
module.exports = function resolveLocal(config) {
try {
return require.resolve(path.resolve(__dirname, '..', config));
} catch (ex) {
return require.resolve(config);
}
};
Loading