diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml deleted file mode 100644 index d529766..0000000 --- a/.github/workflows/autofix.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: autofix.ci - -on: - pull_request: - push: - branches: - - main - -permissions: - contents: read - -jobs: - autofix: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: corepack enable - - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: pnpm - - run: pnpm install - - name: Fix lint issues - run: pnpm run lint:fix - - uses: autofix-ci/action@2891949f3779a1cafafae1523058501de3d4e944 - with: - commit-message: 'chore: apply automated updates' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e17bb2d..1e5147b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,6 +7,7 @@ on: jobs: release: + name: 'release: ubuntu-latest (node@lts/*)' permissions: id-token: write contents: write diff --git a/.gitignore b/.gitignore index d67fe44..b881c55 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -packages/eslint-config/src/typegen.d.ts +packages/eslint-config/src/types/typegen.d.ts packages/eslint-config/.eslint-config-inspector packages/eslint-config/_fixtures @@ -230,10 +230,3 @@ dist # .pnp.* # End of https://www.toptal.com/developers/gitignore/api/node,yarn,git,macos,visualstudiocode - - -# petal generated files -cjs/ -esm/ -types/ -build/ diff --git a/changelogithub.config.ts b/changelogithub.config.ts index b47f715..ea9b0d0 100644 --- a/changelogithub.config.ts +++ b/changelogithub.config.ts @@ -1,7 +1,4 @@ -import { defineConfig } from 'changelogithub'; - -export default defineConfig({ - scopeMap: {}, +export default { types: { chore: { title: '🔨 Chores' }, feature: { title: '✨ Features' }, @@ -15,10 +12,5 @@ export default defineConfig({ deploy: { title: '🚀 Deployments' }, wip: { title: '🚧 Experiments' }, }, - titles: { - breakingChanges: '🚨 Breaking Changes', - }, - contributors: true, - capitalize: true, - group: true, -}); + capitalize: false, +}; diff --git a/eslint.config.ts b/eslint.config.ts index 470c815..13f39a6 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -1,15 +1,13 @@ -// @ts-expect-error missing types -import styleMigrate from '@stylistic/eslint-plugin-migrate'; -import { petal } from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal( +export default defineConfig( { typescript: true, astro: false, type: 'lib', }, { - name: 'ignores', + name: 'user/ignores/fixtures', ignores: [ 'fixtures', '_fixtures', @@ -18,24 +16,14 @@ export default petal( ], }, { - name: 'sort/objects', + name: 'user/perfectionist/sort', files: ['packages/eslint-config/src/**/*.ts'], rules: { 'perfectionist/sort-objects': 'error', }, }, { - name: 'style/migrate', - files: ['packages/eslint-config/src/configs/*.ts'], - plugins: { - 'style-migrate': styleMigrate, - }, - rules: { - 'style-migrate/migrate': ['error', { namespaceTo: 'style' }], - }, - }, - { - name: 'tests', + name: 'user/test/indent', files: ['packages/eslint-plugin/src/rules/**/*.test.ts'], rules: { 'petal/indent-unindent': 'error', diff --git a/package.json b/package.json index 3d9c88a..32c520e 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "type": "module", "version": "3.9.1", "private": true, - "packageManager": "pnpm@9.5.0", + "packageManager": "pnpm@9.6.0", "engineStrict": true, "author": "Petal Contributors", "license": "MIT", @@ -39,19 +39,17 @@ "devDependencies": { "@flowr/eslint-config": "workspace:^", "@flowr/tsconfig": "workspace:^", - "@stylistic/eslint-plugin-migrate": "^2.6.0-beta.0", - "@types/node": "^20.14.11", + "@types/node": "^20.14.12", "bumpp": "^9.4.1", - "changelogithub": "^0.13.9", "esbuild": "^0.23.0", "eslint": "npm:eslint-ts-patch@9.5.0-0", "eslint-ts-patch": "9.5.0-0", - "tsup": "^8.2.0", + "tsup": "^8.2.2", "tsx": "~4.16.2", - "typescript": "^5.5.3", + "typescript": "^5.5.4", "unbuild": "^2.0.0", "vite": "^5.3.4", - "vitest": "^2.0.3" + "vitest": "^2.0.4" }, "resolutions": { "tsx": "~4.16.2" diff --git a/packages/eslint-config/README.md b/packages/eslint-config/README.md index f4920c4..4a9d99c 100644 --- a/packages/eslint-config/README.md +++ b/packages/eslint-config/README.md @@ -27,9 +27,9 @@ pnpm i -D eslint @flowr/eslint-config ```js // eslint.config.mjs -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal(); +export default defineConfig(); ```
@@ -41,12 +41,12 @@ if you still use some configuration from the legacy eslintrc format, you can use ```js // eslint.config.mjs -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; import { FlatCompat } from '@eslint/eslintrc'; const compat = new FlatCompat(); -export default petal( +export default defineConfig( { ignores: [], }, @@ -79,7 +79,7 @@ export default petal( ## ide integration -### vscode support (auto fix on save) +### vscode support install the [vscode eslint extension][vscode] and add the following settings to your `.vscode/settings.json`: @@ -134,24 +134,66 @@ install the [vscode eslint extension][vscode] and add the following settings to } ``` +### neovim support + +```lua +local customizations = { + { rule = 'style/*', severity = 'off', fixable = true }, + { rule = 'format/*', severity = 'off', fixable = true }, + { rule = '*-indent', severity = 'off', fixable = true }, + { rule = '*-spacing', severity = 'off', fixable = true }, + { rule = '*-spaces', severity = 'off', fixable = true }, + { rule = '*-order', severity = 'off', fixable = true }, + { rule = '*-dangle', severity = 'off', fixable = true }, + { rule = '*-newline', severity = 'off', fixable = true }, + { rule = '*quotes', severity = 'off', fixable = true }, + { rule = '*semi', severity = 'off', fixable = true }, +} + +local lspconfig = require('lspconfig') +-- enable eslint for all supported languages +lspconfig.eslint.setup({ + filetypes = { + "", + }, + settings = { + -- silence the stylistic rules in neovim, but still autofix them + rulesCustomizations = customizations, + }, + -- nvim-lspconfig has an EslintFixAll command predefined. you can create an `autocmd` to call this command upon saving a file + on_attach = function(client, bufnr) + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + command = "EslintFixAll", + }) + end, +}) +``` + +there are some preexisting libraries for eslint nvim support as well, which you can use for auto-fixing too: + +- use [`conform.nvim`](https://github.com/stevearc/conform.nvim) +- use [`none-ls.nvim`](https://github.com/nvimtools/none-ls.nvim) +- use [`nvim-lint`](https://github.com/mfussenegger/nvim-lint) + ## customization we use [eslint's flat config feature][eslint-flat]. it provides much better orginzation and composition. normally you only need to import and use the `petal` preset: ```js // eslint.config.js -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal(); +export default defineConfig(); ``` alternatively, you can confgure each integration individually, for example: ```js // eslint.config.js -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal({ +export default defineConfig({ // type of the project type: 'lib', // 'lib' or 'app', default is 'app' @@ -179,13 +221,13 @@ export default petal({ }); ``` -the `petal` factory function also accepts any number of arbitrary custom config overrides: +the `defineConfig` factory function also accepts any number of arbitrary custom config overrides: ```js // eslint.config.js -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal( +export default defineConfig( { // configures for `petal` preset }, @@ -286,9 +328,9 @@ if you really want to use the original prefix, you can revert the plugin renamin ```ts // eslint.config.js -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal() +export default defineConfig() .renamePlugins({ ts: '@typescript-eslint', yaml: 'yml', @@ -304,9 +346,9 @@ certain rules would only be enabled in specific files, for example `ts/*` rules ```js // eslint.config.js -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal( +export default defineConfig( { vue: true, typescript: true @@ -331,9 +373,9 @@ we also provide the `overrides` option for each integration to use our default g ```js // eslint.config.js -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal({ +export default defineConfig({ vue: { overrides: { 'vue/operator-linebreak': ['error', 'before'], @@ -354,13 +396,13 @@ export default petal({ ### composer -the factory function `petal()` returns a [`FlatConfigComposer` object from `eslint-flat-config-utils`](https://github.com/antfu/eslint-flat-config-utils#composer) where you can chain the methods to compose the config even more flexibly. +the factory function `defineConfig()` returns a [`FlatConfigComposer` object from `eslint-flat-config-utils`](https://github.com/antfu/eslint-flat-config-utils#composer) where you can chain the methods to compose the config even more flexibly. ```js // eslint.config.ks -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal() +export default defineConfig() .prepend( // some configs before the main config ) @@ -389,9 +431,9 @@ vue support is auto-detected based on the `vue` dependency. you can also explici ```js // eslint.config.js -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal({ +export default defineConfig({ vue: true, }); ``` @@ -400,9 +442,9 @@ we also support additional options, such as `accessibility` for a11y rules, and ```js // eslint.config.js -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal({ +export default defineConfig({ vue: { sfcBlocks: true, // default is `true`, requires `eslint-processor-vue-blocks` accessibility: true, // default is `false`, requires `eslint-plugin-vuejs-accessibility` @@ -422,9 +464,9 @@ we have limited support for vue 2 (as it's already [reached eol](https://v2.vuej ```js // eslint.config.js -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal({ +export default defineConfig({ vue: { vueVersion: 2, }, @@ -439,9 +481,9 @@ use external formatters to format files that eslint cannot handle yet (`.css`, ` ```js // eslint.config.js -import petal from '@flowr/eslint-config'; +import { defineConfig } from '@flowr/eslint-config'; -export default petal({ +export default defineConfig({ formatters: { css: true, // format CSS, LESS, SCSS files, also the `