From 6c9d1111cc8540690eb44a4522515c1d288b334e Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Fri, 13 Oct 2023 17:32:20 +0200 Subject: [PATCH] Create an initial version 0.0.1-alpha.1 No idea if it'll work in a project, let's publish and test. --- .github/workflows/ci.yml | 21 ++++++++++++++++++++ .gitignore | 1 + .prettierrc | 7 +++++++ README.md | 1 + fix.sh | 3 +++ index.js | 42 ++++++++++++++++++++++++++++++++++++++++ lint.sh | 3 +++ package.json | 35 +++++++++++++++++++++++++++++++++ yarn.lock | 18 +++++++++++++++++ 9 files changed, 131 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 .prettierrc create mode 100644 README.md create mode 100755 fix.sh create mode 100644 index.js create mode 100755 lint.sh create mode 100644 package.json create mode 100644 yarn.lock diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a061b09 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + - run: yarn install + - run: yarn exec -- ./lint.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..d44ab51 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "trailingComma": "all", + "singleQuote": true, + "printWidth": 100, + "semi": false, + "tabWidth": 4 +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..459a2d5 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# The Lune Climate shared ESLint configuration diff --git a/fix.sh b/fix.sh new file mode 100755 index 0000000..59878c8 --- /dev/null +++ b/fix.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -euo pipefail +prettier --write *.js diff --git a/index.js b/index.js new file mode 100644 index 0000000..b6113bd --- /dev/null +++ b/index.js @@ -0,0 +1,42 @@ +module.exports = { + env: { + browser: true, + es2021: true, + }, + extends: ['standard', 'prettier', 'eslint:recommended'], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaVersion: 12, + sourceType: 'module', + + // These are needed for some of the typescript-eslint type-based linting rules + tsconfigRootDir: __dirname, + project: ['./tsconfig.json'], + }, + plugins: ['@typescript-eslint', 'simple-import-sort'], + rules: { + // Unnecessary with TS and generates false positives. + // https://github.com/typescript-eslint/typescript-eslint/blob/181e705887e9e07f0fa28195644cc94e5b4f039d/docs/linting/Troubleshooting.mdx#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors + 'no-undef': 'off', + 'no-use-before-define': 'off', // Unnecessary with TS and generates false positives. + 'comma-dangle': ['error', 'always-multiline'], + 'func-style': ['error', 'declaration'], + 'no-useless-constructor': 'off', + 'no-unused-vars': 'off', + 'no-extra-semi': 'off', + 'no-trailing-spaces': 'error', + '@typescript-eslint/no-useless-constructor': ['error'], + '@typescript-eslint/no-unnecessary-type-assertion': ['error'], + '@typescript-eslint/no-unused-vars': [ + 'error', + { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }, + ], + '@typescript-eslint/no-unnecessary-condition': ['error'], + 'simple-import-sort/imports': ['error'], + complexity: ['error', { max: 14 }], + // To support TS overloads + // https://github.com/typescript-eslint/typescript-eslint/blob/6fd476c32c4757cb9f4c442f0cd92875671eed30/packages/eslint-plugin/docs/rules/no-redeclare.md + 'no-redeclare': 'off', + '@typescript-eslint/no-redeclare': ['error'], + }, +} diff --git a/lint.sh b/lint.sh new file mode 100755 index 0000000..0d660fe --- /dev/null +++ b/lint.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +set -euo pipefail +prettier --check *.js diff --git a/package.json b/package.json new file mode 100644 index 0000000..ed03b0a --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "@lune-climate/eslint-config", + "private": false, + "version": "0.0.1-alpha.1", + "description": "The Lune Climate shared ESLint configuration", + "main": "index.js", + "repository": { + "type": "git", + "url": "git+https://github.com/lune-climate/shared-configs.git" + }, + "keywords": [ + "eslint", + "eslintconfig", + "luneclimate", + "lune" + ], + "author": "Lune Climate ", + "license": "MIT", + "bugs": { + "url": "https://github.com/lune-climate/shared-configs/issues" + }, + "homepage": "https://github.com/lune-climate/shared-configs#readme", + "devDependencies": { + "prettier": "^3.0.3" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^6.7.5", + "eslint": "^8.51.0", + "eslint-plugin-simple-import-sort": "^10.0.0" + }, + "dependencies": { + "eslint-config-prettier": "^9.0.0", + "eslint-config-standard": "^17.1.0" + } +} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..2fd5182 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,18 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +eslint-config-prettier@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.0.0.tgz#eb25485946dd0c66cd216a46232dc05451518d1f" + integrity sha512-IcJsTkJae2S35pRsRAwoCE+925rJJStOdkKnLVgtE+tEpqU0EVVM7OqrwxqgptKdX29NUwC82I5pXsGFIgSevw== + +eslint-config-standard@^17.1.0: + version "17.1.0" + resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-17.1.0.tgz#40ffb8595d47a6b242e07cbfd49dc211ed128975" + integrity sha512-IwHwmaBNtDK4zDHQukFDW5u/aTb8+meQWZvNFWkiGmbWjD6bqyuSSBxxXKkCftCUzc1zwCH2m/baCNDLGmuO5Q== + +prettier@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.3.tgz#432a51f7ba422d1469096c0fdc28e235db8f9643" + integrity sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg==