Skip to content

Commit

Permalink
feat(init): first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
100terres committed Oct 16, 2022
0 parents commit 7d39009
Show file tree
Hide file tree
Showing 41 changed files with 789 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .czrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "@commitlint/cz-commitlint"
}
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.release-it.js
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: require.resolve("./js"),
};
16 changes: 16 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Lint commit messages

on:
pull_request:
push:
branches:
- main

jobs:
commitlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
18 changes: 18 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Lint codebase

on:
pull_request:
push:
branches:
- main

jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm run lint
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
node_modules
npm-debug.log
npm-shrinkwrap.json
package-lock.json
yarn-error.log
yarn.lock
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no -- commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm test
10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
.eslintrc.json
.gitignore
node_modules
npm-debug.log
npm-shrinkwrap.json
package-lock.json
samples
yarn-error.log
yarn.lock
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
87 changes: 87 additions & 0 deletions .release-it.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* eslint-disable no-template-curly-in-string */

module.exports = {
hooks: {
"before:init": ["npm test"],
},
git: {
commitMessage: "chore: release ${version}",
tagName: "v${version}",
},
npm: {
publish: true,
},
github: {
release: true,
},
plugins: {
"@release-it/conventional-changelog": {
infile: "CHANGELOG.md",
preset: {
name: "conventionalcommits",
types: [
{
type: "chore",
section: "Others 🔧",
hidden: false,
},
{
type: "revert",
section: "Reverts ◀",
hidden: false,
},
{
type: "feat",
section: "Features 🔥",
hidden: false,
},
{
type: "fix",
section: "Bug Fixes 🛠",
hidden: false,
},
{
type: "improvement",
section: "Feature Improvements 🛠",
hidden: false,
},
{
type: "docs",
section: "Docs 📃",
hidden: false,
},
{
type: "style",
section: "Styling 🎨",
hidden: false,
},
{
type: "refactor",
section: "Code Refactoring 🖌",
hidden: false,
},
{
type: "perf",
section: "Performance Improvements 🏎",
hidden: false,
},
{
type: "test",
section: "Tests 🧪",
hidden: false,
},
{
type: "build",
section: "Build System 🏗",
hidden: false,
},
{
type: "ci",
section: "CI 🛠",
hidden: false,
},
],
},
},
},
};
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) @100terres

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
94 changes: 94 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<h1 align="center">
easelint
</h1>

<p align="center">
A modern <a href="https://eslint.org/">ESlint</a> configuration for <a href="https://www.ecma-international.org/publications-and-standards/standards/ecma-262/">JavaScript</a>, <a href="https://www.typescriptlang.org/">TypeScript</a> and <a href="https://reactjs.org/">React</a> that includes the <a href="https://github.com/airbnb/javascript">Airbnb</a> style guide, <a href="https://github.com/jsx-eslint/eslint-plugin-jsx-a11y">jsx-a11y</a> to help with accessibility and <a href="https://www.npmjs.com/package/eslint-plugin-prettier">Pettier</a> to do some code formatting.
</p>

<p align="center">
<a href="LICENSE">
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="easelint is released under the MIT license." />
</a>

<a href="#how-to-contribute-">
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" alt="PRs welcome!" />
</a>
</p>

## A bit of context

It's always a bit time consuming to create or maintain different [ESlint](https://eslint.org/) configurations that works with different languages and libraries such as [TypeScript](https://www.typescriptlang.org/) and [React](https://reactjs.org/). The goal of this package is to have different configurations that just work out-of-the-box and that are constantly kept up-to-date.

## Getting Started 🚀

Installing this packge is has as easy has any other packages. Simply use your favorite package manager. You'll need to install the required peer dependencies and than this packge.

### Install ESlint and Prettier peer dependencies

Install [ESlint](https://eslint.org/) and [Prettier](https://prettier.io/) either locally or globally. (Note that locally, per project, is strongly preferred)


```sh
npm install eslint@8 --save-dev
npm install prettier@2 --save-dev --save-exact
```

If you use [TypeScript](https://www.typescriptlang.org/) or [React](https://reactjs.org/) you'll also need to install them, but let's assume they're already installed. We'll only support most recent version. Have a look at the `peerDependencies` field in the package.json to know which one we support.

### Install easelint

```sh
npm install easelint --save-dev
```

### Setup the configuration file

Using any [file formats](https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats) supported by [ESlint](https://eslint.org/), youll need to add `"100terres"` in the `"extends"` value of the configuration. Here's an example using a `.eslintrc.js` file.

#### Using the full configuration with JavaScript, TypeScript and React

```js
module.exports = {
"extends": ["100terres"],
};
```
#### JavaScript config

```js
module.exports = {
"extends": ["100terres/js"],
};
```
#### JavaScript with React config

```js
module.exports = {
"extends": ["100terres/js", "100terres/jsx"],
};
```
#### TypeScript config

```js
module.exports = {
"extends": ["100terres/ts"],
};
```
#### TypeScript with React config

```js
module.exports = {
"extends": ["100terres/ts", "100terres/tsx"],
};
```

Voilà! Your project now uses a linter.


## How to Contribute 🤝

Pull requests are welcome. If you'd like to contribute to easelint, that's awesome. Simply open an issue explaining what we should change, improve or fix. If we decide that a change is required we can open a pull request and once everything looks good I'll approve and merge the PR.

## License

Licensed under the [MIT license](LICENSE).
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"] };
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
extends: ["./internal/base", "./js", "./jsx", "./ts", "./tsx"].map(
require.resolve
),
};
10 changes: 10 additions & 0 deletions internal/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
};
46 changes: 46 additions & 0 deletions internal/final.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// The ESLint browser environment defines all browser globals as valid,
// even though most people don't know some of them exist (e.g. `name` or `status`).
// This is dangerous as it hides accidentally undefined variables.
// We blacklist the globals that we deem potentially confusing.
// To use them, explicitly reference them, e.g. `window.name` or `window.status`.
const restrictedGlobals = require("confusing-browser-globals");

module.exports = {
extends: ["prettier"],
plugins: ["import", "prettier"],

rules: {
// https://github.com/prettier/eslint-plugin-prettier
"prettier/prettier": "error",
// Prettier recommend to turn off these two rules
// https://github.com/prettier/eslint-plugin-prettier/issues/65
"arrow-body-style": "off",
"prefer-arrow-callback": "off",

// https://github.com/benmosher/eslint-plugin-import/tree/master/docs/rules
"import/extensions": [
"error",
"ignorePackages",
{
js: "never",
mjs: "never",
jsx: "never",
ts: "never",
tsx: "never",
},
],

// http://eslint.org/docs/rules/
"no-console": "error",
// Overriding airbnb rule
// https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/es6.js#L63-L70
// https://github.com/airbnb/javascript/issues/2500
"no-restricted-exports": [
"error",
{
restrictedNamedExports: ["then"],
},
],
"no-restricted-globals": ["error"].concat(restrictedGlobals),
},
};
3 changes: 3 additions & 0 deletions internal/javascript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ["airbnb-base", require.resolve("./final")],
};
41 changes: 41 additions & 0 deletions internal/react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = {
extends: [
"airbnb",
"plugin:react/recommended",
"plugin:jsx-a11y/recommended",
require.resolve("./final"),
],
plugins: ["react", "react-hooks", "jsx-a11y"],

parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: "detect",
},
},
rules: {
// https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",

// https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules
"react/function-component-definition": [
"error",
{ namedComponents: ["arrow-function", "function-declaration"] },
],
"react/jsx-filename-extension": ["error", { extensions: [".jsx", ".tsx"] }],
"react/jsx-props-no-spreading": "off",
"react/jsx-sort-props": [
"error",
{
ignoreCase: true,
shorthandFirst: true,
multiline: "last",
},
],
},
};
Loading

0 comments on commit 7d39009

Please sign in to comment.