├── .husky └── commit-msg ├── .npmrc ├── eslint.config.js ├── commitlint.config.js ├── .github ├── eslint-config-cover.png ├── PULL_REQUEST_TEMPLATE.md ├── ISSUE_TEMPLATE │ ├── 3-question.md │ ├── 2-feature-request.md │ └── 1-bug-report.md ├── renovate.json ├── workflows │ └── ci.yml ├── release.sh ├── CONTRIBUTING.md └── CODE_OF_CONDUCT.md ├── rules ├── antfuOptions.js ├── sbConfigBase.js ├── sbConfigTailwind.js └── sbConfigVue.js ├── index.js ├── .gitignore ├── LICENSE ├── package.json ├── README.md └── CHANGELOG.md /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | pnpm dlx commitlint --edit $1 -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | shamefully-hoist=true 2 | strict-peer-dependencies=false 3 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import { stefanobartoletti } from './index.js' 2 | 3 | export default stefanobartoletti() 4 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | extends: [ 3 | '@commitlint/config-conventional', 4 | ], 5 | } 6 | -------------------------------------------------------------------------------- /.github/eslint-config-cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefanobartoletti/eslint-config/HEAD/.github/eslint-config-cover.png -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/3-question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F64B Generic question" 3 | about: A generic question about this project 4 | title: '' 5 | labels: question 6 | assignees: '' 7 | 8 | --- 9 | 10 | 14 | -------------------------------------------------------------------------------- /rules/antfuOptions.js: -------------------------------------------------------------------------------- 1 | const antfuOptions = { 2 | stylistic: true, 3 | // vue: true, // autodetected by @antfu/eslint-config, no need to set a default 4 | // typescript: true, // autodetected by @antfu/eslint-config, no need to set a default 5 | formatters: { 6 | css: true, 7 | html: true, 8 | }, 9 | } 10 | 11 | export default antfuOptions 12 | -------------------------------------------------------------------------------- /rules/sbConfigBase.js: -------------------------------------------------------------------------------- 1 | const sbConfigBase = [ 2 | 3 | { 4 | name: 'stefanobartoletti/base', 5 | rules: { 6 | 'antfu/top-level-function': 'off', 7 | 'curly': ['error', 'all'], 8 | 'node/prefer-global/process': 'off', 9 | 'style/function-call-spacing': ['error', 'never'], 10 | }, 11 | }, 12 | 13 | ] 14 | 15 | export default sbConfigBase 16 | -------------------------------------------------------------------------------- /rules/sbConfigTailwind.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/no-mutable-exports */ 2 | /* eslint-disable antfu/no-top-level-await */ 3 | 4 | let sbConfigTailwind = {} 5 | 6 | try { 7 | const tailwind = await import('eslint-plugin-tailwindcss') 8 | sbConfigTailwind = tailwind.default.configs['flat/recommended'] 9 | } 10 | catch { 11 | console.warn('eslint-plugin-tailwindcss not found, skipping Tailwind rules') 12 | } 13 | 14 | export default sbConfigTailwind 15 | -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:recommended" 5 | ], 6 | "rangeStrategy": "bump", 7 | "prHourlyLimit": 0, 8 | "labels": [ 9 | "dependencies" 10 | ], 11 | "vulnerabilityAlerts": { 12 | "labels": [ 13 | "security" 14 | ], 15 | "enabled": true 16 | }, 17 | "packageRules": [ 18 | { 19 | "groupName": "@commitlint", 20 | "matchPackageNames": [ 21 | "@commitlint/{/,}**" 22 | ] 23 | } 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /rules/sbConfigVue.js: -------------------------------------------------------------------------------- 1 | const sbConfigVue = [ 2 | { 3 | name: 'stefanobartoletti/vue', 4 | files: ['**/*.vue'], 5 | rules: { 6 | 'vue/block-order': ['error', { 7 | order: ['template', 'script', 'style'], 8 | }], 9 | 'vue/html-self-closing': ['warn', { 10 | html: { 11 | void: 'always', 12 | normal: 'never', 13 | }, 14 | }], 15 | 'vue/max-attributes-per-line': ['error', { 16 | singleline: { max: 10 }, 17 | multiline: { max: 1 }, 18 | }], 19 | 'vue/multi-word-component-names': 'warn', 20 | 'vue/singleline-html-element-content-newline': 'off', 21 | }, 22 | }, 23 | ] 24 | 25 | export default sbConfigVue 26 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import antfu from '@antfu/eslint-config' 2 | import antfuOptions from './rules/antfuOptions.js' 3 | import sbConfigBase from './rules/sbConfigBase.js' 4 | import sbConfigTailwind from './rules/sbConfigTailwind.js' 5 | import sbConfigVue from './rules/sbConfigVue.js' 6 | 7 | const stefanobartoletti = (options, ...configs) => { 8 | return antfu( 9 | // @antfu/eslint-config options, must be the first argument 10 | { 11 | ...antfuOptions, 12 | ...options, 13 | }, 14 | // Addtionals flat configs start from here 15 | sbConfigBase, 16 | ...configs, 17 | ) 18 | } 19 | 20 | const vue = sbConfigVue 21 | const tailwind = sbConfigTailwind 22 | 23 | export { 24 | stefanobartoletti, 25 | tailwind, 26 | vue, 27 | } 28 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | ci: 13 | runs-on: ${{ matrix.os }} 14 | 15 | strategy: 16 | matrix: 17 | os: [ubuntu-latest] 18 | node: [22] 19 | 20 | steps: 21 | - uses: actions/checkout@v5 22 | 23 | - uses: pnpm/action-setup@v4 24 | 25 | - uses: actions/setup-node@v6 26 | with: 27 | node-version: ${{ matrix.node }} 28 | cache: pnpm 29 | 30 | - name: 📦 Install dependencies 31 | run: pnpm install 32 | 33 | - name: ✅ Lint 34 | run: pnpm lint 35 | 36 | # - name: 🧪 Test project 37 | # run: pnpm test 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/2-feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F4A1 Feature request" 3 | about: Suggest an idea to help improve this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | 14 | 15 | ### Describe your suggestion 16 | 17 | 18 | 19 | ### Use cases 20 | 21 | 22 | 23 | ### Describe alternatives you've considered 24 | 25 | 26 | 27 | ### Additional context 28 | 29 | 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Dependencies 2 | node_modules 3 | 4 | # Logs 5 | *.log* 6 | 7 | # Temp directories 8 | .temp 9 | .tmp 10 | .cache 11 | 12 | # Yarn 13 | **/.yarn/cache 14 | **/.yarn/*state* 15 | 16 | # Generated dirs 17 | dist 18 | 19 | # Nuxt 20 | .nuxt 21 | .output 22 | .data 23 | .vercel_build_output 24 | .build-* 25 | .netlify 26 | 27 | # Env 28 | .env 29 | 30 | # Testing 31 | reports 32 | coverage 33 | *.lcov 34 | .nyc_output 35 | 36 | # VSCode 37 | .vscode/* 38 | !.vscode/settings.json 39 | !.vscode/tasks.json 40 | !.vscode/launch.json 41 | !.vscode/extensions.json 42 | !.vscode/*.code-snippets 43 | 44 | # Intellij idea 45 | *.iml 46 | .idea 47 | 48 | # OSX 49 | .DS_Store 50 | .AppleDouble 51 | .LSOverride 52 | .AppleDB 53 | .AppleDesktop 54 | Network Trash Folder 55 | Temporary Items 56 | .apdisk 57 | 58 | # Linux 59 | .directory 60 | 61 | # Archives 62 | *.zip 63 | *.tgz 64 | 65 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Stefano Bartoletti 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/1-bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F41B Bug report" 3 | about: Report a bug to help improve this project 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | 16 | 17 | ### Environment 18 | 19 | - eslint-config version: 20 | 21 | ### Reproduction Link 22 | 27 | 28 | ### Describe the bug 29 | 30 | 31 | ### Steps To Reproduce 32 | 38 | 39 | ### Expected behavior 40 | 41 | 42 | ### Additional context 43 | 44 | -------------------------------------------------------------------------------- /.github/release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check if we're on the main branch 4 | CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) 5 | if [ "$CURRENT_BRANCH" != "main" ]; then 6 | echo "❌ Releases can only be made from the 'main' branch" 7 | echo "Current branch: $CURRENT_BRANCH" 8 | echo "Please switch to the main branch first: git checkout main" 9 | exit 1 10 | fi 11 | 12 | # Run quality checks 13 | echo "🔍 Running linting..." 14 | pnpm lint || { 15 | echo "❌ Linting failed" 16 | exit 1 17 | } 18 | 19 | # Generate changelog and bump version 20 | echo "📝 Generating changelog and bumping version..." 21 | changelogen --release --hideAuthorEmail || { 22 | echo "❌ Changelog generation failed" 23 | exit 1 24 | } 25 | 26 | # Publish to npm 27 | echo "🚀 Publishing to npm..." 28 | echo "📱 Please enter your npm OTP (One-Time Password):" 29 | read -r OTP 30 | npm publish --otp="$OTP" || { 31 | echo "❌ Publishing failed" 32 | exit 1 33 | } 34 | 35 | # Push changes and tags 36 | echo "⬆️ Pushing changes and tags..." 37 | git push --follow-tags || { 38 | echo "❌ Failed to push changes" 39 | exit 1 40 | } 41 | 42 | # Create GitHub release using changelogen 43 | echo "🐙 Creating GitHub release..." 44 | changelogen gh release || { 45 | echo "❌ Failed to create GitHub release" 46 | exit 1 47 | } 48 | 49 | echo "✅ Release completed successfully!" -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 🎆 First of all, thank you for contributing! 🎆 2 | 3 | There are some guidelines that should be followed to ensure an easier management of this project and to make easier for contributors to help improve it. 4 | 5 | ## Reporting a bug 6 | 7 | To open a bug, open an issue in the "Bug Report" category, making sure to follow these steps: 8 | 9 | - make sure that you have correctly set and used the module and its functionalities according to th documentation in the readme 10 | - search on the existing issues, your problem may have already be answered or even solved 11 | - describe your issue in a clear and detailed way 12 | - use English in your reports 13 | 14 | ## Submitting a Pull Request 15 | 16 | To submit a pull request, make sure to follow these steps and requirements: 17 | 18 | - open a PR's for a single feature or bugfix, multiple modifications of different nature can be submitted with multiple PR's 19 | - if submitting a new feature, discuss it by opening an issue before even start working on it. This is required to make sure that the new feature is something that is really needed or wanted and thus having it green-lighted, and to receive some feedback and suggestions about how to properly implement it. 20 | - Issues labeled with [`Help Wanted`](https://github.com/stefanobartoletti/eslint-config/labels/help%20wanted), if present, are a good starting point to start cotributing to the project. 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@stefanobartoletti/eslint-config", 3 | "type": "module", 4 | "version": "4.0.3", 5 | "packageManager": "pnpm@10.19.0", 6 | "description": "", 7 | "author": "Stefano Bartoletti (https://github.com/stefanobartoletti/)", 8 | "license": "MIT", 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/stefanobartoletti/eslint-config.git" 12 | }, 13 | "keywords": [ 14 | "eslint", 15 | "eslint-config", 16 | "eslintconfig" 17 | ], 18 | "publishConfig": { 19 | "access": "public", 20 | "registry": "https://registry.npmjs.org" 21 | }, 22 | "main": "index.js", 23 | "scripts": { 24 | "lint": "eslint .", 25 | "lint:fix": "eslint . --fix", 26 | "preview": "config-inspector", 27 | "release": "./.github/release.sh", 28 | "commitlint": "commitlint --edit", 29 | "prepare": "husky" 30 | }, 31 | "peerDependencies": { 32 | "eslint": ">=9.38.0", 33 | "eslint-plugin-tailwindcss": "^3.18.2" 34 | }, 35 | "peerDependenciesMeta": { 36 | "eslint-plugin-tailwindcss": { 37 | "optional": true 38 | } 39 | }, 40 | "dependencies": { 41 | "@antfu/eslint-config": "^6.1.0", 42 | "eslint-plugin-format": "^1.0.2" 43 | }, 44 | "devDependencies": { 45 | "@commitlint/cli": "^20.1.0", 46 | "@commitlint/config-conventional": "^20.0.0", 47 | "@eslint/config-inspector": "^1.3.0", 48 | "changelogen": "^0.6.2", 49 | "eslint": "^9.38.0", 50 | "eslint-plugin-tailwindcss": "^3.18.2", 51 | "husky": "^9.1.7" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | bartoletti.stefano@gmail.com. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | [![npm version][npm-version-src]][npm-version-href] 6 | [![npm downloads][npm-downloads-src]][npm-downloads-href] 7 | [![License][license-src]][license-href] 8 | [![code style][antfu-src]][antfu-href] 9 | 10 | 11 | My ESlint configuration, based on `@antfu/eslint-config` with personal customizations. Nicely integrates with Nuxt and provides optional rules for Tailwind. 12 | 13 | [Release Notes](/CHANGELOG.md) 14 | 15 | --- 16 | 17 |
18 | 19 | ## 🌟 Features 20 | 21 | This is my personal ESlint configuration, based on the excellent [`@antfu/eslint-config`](https://github.com/antfu/eslint-config). It only deviates for some minor tweaks and personal preferences, since I agree almost completely with Anthony's style choices. 22 | 23 | This config integrates nicely with the [`Nuxt ESLint`](https://eslint.nuxt.com) module, and also adds optional rules for Tailwind, by using [`eslint-plugin-tailwindcss`](https://github.com/francoismassart/eslint-plugin-tailwindcss) 24 | 25 | Some of the main features, inherited directly from `@antfu/eslint-config`: 26 | 27 | - Vue and TypeScript support 28 | - Linting for Json, Yaml, Markdown 29 | - Uses the easily extensible [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new) 30 | - Includes [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic) to format code and enforce a preconfigured style (*Prettier not required and not officially supported*) 31 | - ... and many more (check its docs for the full list) 32 | 33 | My own customizations and preferences: 34 | 35 | - (General) Force use of curly braces on control statements 36 | - (General) Disable `antfu/top-level-function` to allow arrow syntax on top level functions 37 | - (Vue - *Optional*) Set maximum allowed attributes per line on HTML elements (`10` for singleline, `1` for multiline) 38 | - (Vue - *Optional*) Set block order to `