Skip to content

Commit

Permalink
fix: eslint-config initial
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Sep 26, 2023
1 parent b99fd34 commit cdd43e3
Show file tree
Hide file tree
Showing 23 changed files with 872 additions and 0 deletions.
84 changes: 84 additions & 0 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"name": "@fission-codes/eslint-config",
"version": "0.0.1",
"description": "Fission eslint config.",
"author": "Hugo Dias <hugomrdias@gmail.com> (hugodias.me)",
"license": "(Apache-2.0 AND MIT)",
"homepage": "https://github.com/fission-codes/stack/tree/main/packages/eslint-config",
"repository": {
"url": "fission-codes/stack",
"directory": "packages/eslint-config"
},
"main": "src/index.js",
"types": "dist/src/index.d.ts",
"files": [
"src",
"dist/src/*.d.ts",
"dist/src/*.d.ts.map",
"prettier.config.js",
"tsconfig.json"
],
"scripts": {
"lint": "tsc --build && eslint . && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore",
"build": "tsc --build",
"test": "mocha 'test/**/*.test.js'"
},
"dependencies": {
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-standard": "^17.1.0",
"eslint-config-standard-with-typescript": "^39.1.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-etc": "^2.0.3",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jsdoc": "^46.8.2",
"eslint-plugin-jsonc": "^2.9.0",
"eslint-plugin-markdown": "^3.0.1",
"eslint-plugin-n": "^16.1.0",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-unicorn": "^48.0.1",
"eslint-plugin-yml": "^1.9.0",
"typescript": "^5.2.2"
},
"devDependencies": {
"@types/assert": "^1.5.7",
"@types/eslint": "^8.44.3",
"@types/mocha": "^10.0.1",
"@types/node": "^20.7.0",
"assert": "^2.1.0",
"mocha": "^10.2.0"
},
"publishConfig": {
"provenance": true
},
"eslintConfig": {
"extends": "./src/index.js",
"parserOptions": {
"sourceType": "script"
},
"rules": {
"unicorn/prefer-module": "off"
},
"env": {
"mocha": true
},
"ignorePatterns": [
"fixtures"
]
},
"depcheck": {
"specials": [
"bin"
],
"ignores": [
"@types/*",
"assert"
]
}
}
8 changes: 8 additions & 0 deletions packages/eslint-config/prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'

module.exports = {
trailingComma: 'es5',
tabWidth: 2,
semi: false,
singleQuote: true,
}
105 changes: 105 additions & 0 deletions packages/eslint-config/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# eslint-config

[![npm (scoped)](https://img.shields.io/npm/v/%40fission-codes/eslint-config)](https://www.npmjs.com/package/@fission-codes/eslint-config)
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/fission-codes/stack/eslint-config.yml)](https://github.com/fission-codes/stack/actions/workflows/eslint-config.yml)
[![Built by FISSION](https://img.shields.io/badge/built_by-⌘_Fission-purple.svg)](https://fission.codes)
[![Discord](https://img.shields.io/discord/478735028319158273?&color=mediumslateblue)](https://discord.gg/zAQBDEq)
[![Discourse users](<https://img.shields.io/discourse/users?server=https%3A%2F%2Ftalk.fission.codes&label=talk&color=rgb(14%2C%20118%2C%20178)>)](https://talk.fission.codes)

Fission eslint, ts and prettier config.

## Installation

```bash
pnpm install @fission-codes/eslint-config
```

## Usage

`package.json`

```json
{
"main": "src/index.js",
"types": "dist/src/index.d.ts",
"files": ["dist/src", "src", "index.js", "cli.js"],
"scripts": {
"lint": "eslint . && prettier --check **/*.{js,ts,yml,json} --ignore-path .gitignore && tsc"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
"lint-staged": {
"*.{js,ts,md,yml,json}": "prettier --write",
"*": "eslint --fix"
},
"eslintConfig": {
"extends": "@fission-codes",
"ignorePatterns": ["coverage", "dist", "docs"],
// for preact
"settings": {
"react": {
"pragma": "h",
"version": "18.0"
}
}
},
"prettier": "@fission-codes/eslint-config/prettier.config.js"
}
```

`tsconfig.json`

```json
{
"extends": "@fission-codes/eslint-config/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"emitDeclarationOnly": true
},
"include": ["src", "test.js", "cli.js", "package.json"]
}
```

For typescript code bases:

```json
{
"extends": "@fission-codes/eslint-config/tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"module": "NodeNext",
"moduleResolution": "NodeNext"
},
"include": ["src", "test.js", "cli.js", "package.json"]
}
```

In monorepos you can install `@fission-codes/eslint-config` only in the root and extends the root `tsconfig.json` in the packages.

## Contributing

Read contributing guidelines [here](.github/CONTRIBUTING.md).

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/fission-codes/stack)

## License

This project is licensed under either of

- Apache License, Version 2.0, ([LICENSE-APACHE](./LICENSE-APACHE) or
[http://www.apache.org/licenses/LICENSE-2.0][apache])
- MIT license ([LICENSE-MIT](./LICENSE-MIT) or
[http://opensource.org/licenses/MIT][mit])

at your option.

### Contribution

Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.

[apache]: https://www.apache.org/licenses/LICENSE-2.0
[mit]: http://opensource.org/licenses/MIT
91 changes: 91 additions & 0 deletions packages/eslint-config/src/configs/js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
'use strict'

/** @type {import('eslint').Linter.BaseConfig} */
const config = {
extends: [
'standard',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:eslint-comments/recommended',
'plugin:jsdoc/recommended-typescript-flavor',
'plugin:unicorn/recommended',
],
plugins: ['html', 'no-only-tests', 'jsdoc', 'unicorn'],
reportUnusedDisableDirectives: true,
env: {
es2022: true,
browser: true,
node: true,
},
rules: {
strict: ['error', 'safe'],
curly: 'error',
eqeqeq: ['error', 'smart'],
'no-implicit-coercion': 'error',
'no-nested-ternary': 'warn',
'no-warning-comments': 'warn',
'no-debugger': 'error',
'no-console': ['error', { allow: ['warn', 'error'] }],
'no-restricted-globals': [
'error',
{ name: 'global', message: 'Use `globalThis` instead.' },
{ name: 'self', message: 'Use `globalThis` instead.' },
],
'require-yield': 'error',
'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: false,
},
],

// plugins

// eslint-comments
'eslint-comments/disable-enable-pair': ['off'],

// jsdoc - change also in ts.js
'jsdoc/tag-lines': ['error', 'any', { startLines: 1 }],
'jsdoc/check-values': 'off',
'jsdoc/check-tag-names': 'off',
'jsdoc/no-undefined-types': 'off',
'jsdoc/require-returns': 'off',
'jsdoc/require-returns-type': 'off',
'jsdoc/require-throws': 'off',
'jsdoc/require-param-description': 'off',
'jsdoc/require-returns-description': 'off',
'jsdoc/valid-types': 'off',

// no-only-tests
'no-only-tests/no-only-tests': 'error',

// unicorn
'unicorn/prefer-node-protocol': 'off',
'unicorn/prevent-abbreviations': 'off',
'unicorn/no-for-loop': 'off',

// import
'import/extensions': ['error', 'ignorePackages'],
'import/order': 'error',
'import/first': 'error',
'import/no-mutable-exports': 'error',
'import/newline-after-import': [
'error',
{ count: 1, considerComments: true },
],
'import/no-self-import': 'error',
'import/namespace': ['error', { allowComputed: true }],
'import/no-unresolved': 'off',
},
settings: {
jsdoc: {
mode: 'typescript',
},
},
}

module.exports = config
Loading

0 comments on commit cdd43e3

Please sign in to comment.