diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..6313b56 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text=auto eol=lf diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..ef530ea --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,29 @@ +name: Publish + +on: + push: + branches: + - main + - alpha + - beta + - next + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - run: npm install + + - run: npm run lint + + - run: npx semantic-release + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..e1f773f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,23 @@ +name: Test + +on: + push: + branches-ignore: + - main + - alpha + - beta + - next + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - run: npm install + + - run: npm run lint 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/.npmrc b/.npmrc new file mode 100644 index 0000000..0ca8d2a --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +package-lock=false +save-exact=true diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..bb599e3 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,12 @@ +{ + "useTabs": true, + "overrides": [ + { + "files": ["*.yml", "*.json"], + "options": { + "tabWidth": 2, + "useTabs": false + } + } + ] +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..80949a0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,11 @@ +# Contributing + +Thank you for showing an interest in contributing to Eik 🧡 + +This module is a [shared config for ESLint](https://eslint.org/docs/latest/extend/shareable-configs). We accept changes that should apply to all repositories in the [eik-lib origanisation](https://github.com/eik-lib). + +Commits should follow the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) format. + +A change in configuration is considered a `patch` in [semantic versioning](https://semver.org/). A new export would be a `minor`. Updating the `peerDependency` to a higher version would be a `major`. + +This repo uses [semantic release](https://github.com/semantic-release/semantic-release) to automate releases whenever changes are merged to the default branch. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3a004e1 --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# @eik/eslint-config + +Shared config for ESLint used in Eik projects. + +## Install + +``` +npm install --save-dev eslint @eik/eslint-config +``` + +## Usage + +The default config should cover most needs, but you can extend or override if you need to. + +```js +// eslint.config.js + +import config from "@eik/eslint-config"; + +export default [ + ...config, + /* Your customisations */ +]; +``` + +If you do need to change the config, consider whether that change should happen here in the shared config so it applies to all repos. diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..c7f7922 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,3 @@ +import eikEslintConfig from "./lib/default.js"; + +export default [...eikEslintConfig]; diff --git a/lib/base.js b/lib/base.js new file mode 100644 index 0000000..bab0d49 --- /dev/null +++ b/lib/base.js @@ -0,0 +1,12 @@ +import prettierConfig from "eslint-config-prettier"; +import prettierPlugin from "eslint-plugin-prettier/recommended"; +import js from "@eslint/js"; + +export default [ + js.configs.recommended, + prettierConfig, + prettierPlugin, + { + ignores: ["coverage/*", "node_modules/*", "tap-snapshots/*"], + }, +]; diff --git a/lib/default.js b/lib/default.js new file mode 100644 index 0000000..a8fe04c --- /dev/null +++ b/lib/default.js @@ -0,0 +1,14 @@ +import globals from "globals"; +import base from "./base.js"; + +export default [ + ...base, + { + languageOptions: { + globals: { + ...globals.node, + ...globals.browser, + }, + }, + }, +]; diff --git a/package.json b/package.json new file mode 100644 index 0000000..3fbec7c --- /dev/null +++ b/package.json @@ -0,0 +1,47 @@ +{ + "name": "@eik/eslint-config", + "version": "1.0.0", + "description": "Shared ESLint config for Eik modules", + "type": "module", + "exports": { + ".": { + "default": "./lib/default.js" + } + }, + "files": [ + "lib" + ], + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/eik-lib/eslint-config.git" + }, + "publishConfig": { + "access": "public" + }, + "bugs": { + "url": "https://github.com/eik-lib/eslint-config/issues" + }, + "homepage": "https://github.com/eik-lib/eslint-config#readme", + "scripts": { + "lint": "eslint .", + "lint:fix": "npm run lint -- --fix", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [ + "eslint", + "eslintconfig" + ], + "author": "", + "license": "ISC", + "peerDependencies": { + "eslint": ">= 9" + }, + "dependencies": { + "eslint-config-prettier": "9.1.0", + "eslint-plugin-prettier": "5.2.1", + "globals": "15.8.0" + }, + "devDependencies": { + "eslint": "9.8.0" + } +}