Skip to content

Commit

Permalink
Merge pull request #157 from lishaduck/optional-astro
Browse files Browse the repository at this point in the history
Make Astro Optional
  • Loading branch information
AndreaPontrandolfo authored Jul 21, 2024
2 parents 96c3bae + d308d56 commit 12158ee
Show file tree
Hide file tree
Showing 24 changed files with 1,161 additions and 274 deletions.
7 changes: 7 additions & 0 deletions .changeset/brown-singers-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"eslint-config-sheriff": major
"@sherifforg/constants": patch
"@sherifforg/types": patch
---

feat!: make astro support optional
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
"markdown",
"astro"
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
"json.schemas": [
{
"url": "https://cdn.jsdelivr.net/npm/tsup/schema.json",
Expand Down
2 changes: 1 addition & 1 deletion apps/config-validation-playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"validate-config": "eslint . --max-warnings=0 --cache --cache-location=node_modules/.cache/.eslintcache"
},
"dependencies": {
"astro": "^4.0.8",
"astro": "^4.11.5",
"lodash": "^4.17.21",
"next": "^14.0.4",
"playwright": "^1.40.1",
Expand Down
18 changes: 18 additions & 0 deletions apps/docs-website/docs/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand All @@ -56,6 +57,7 @@ const { defineFlatConfig } = require("eslint-define-config");
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -85,6 +87,7 @@ import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -112,6 +115,7 @@ const { defineFlatConfig } = require("eslint-define-config");
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -144,6 +148,7 @@ import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -171,6 +176,7 @@ const { defineFlatConfig } = require("eslint-define-config");
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -232,6 +238,7 @@ import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand All @@ -256,6 +263,7 @@ const { defineFlatConfig } = require("eslint-define-config");
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -289,6 +297,7 @@ import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand All @@ -313,6 +322,7 @@ const { defineFlatConfig } = require("eslint-define-config");
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -361,6 +371,7 @@ import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand All @@ -384,6 +395,7 @@ const { defineFlatConfig } = require("eslint-define-config");
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -424,6 +436,7 @@ import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -452,6 +465,7 @@ const { defineFlatConfig } = require("eslint-define-config");
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -510,6 +524,7 @@ import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -550,6 +565,7 @@ const { defineFlatConfig } = require("eslint-define-config");
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -600,6 +616,7 @@ import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -628,6 +645,7 @@ const { defineFlatConfig } = require("eslint-define-config");
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down
2 changes: 2 additions & 0 deletions apps/docs-website/docs/migration-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const sheriffOptions = {
files: ["./src/**/*"], // Only the files in the /src directory will be linted.
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand All @@ -55,6 +56,7 @@ const sheriffOptions = {
files: ["./src/**/*"], // Only the files in the /src directory will be linted.
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down
2 changes: 2 additions & 0 deletions apps/docs-website/docs/performance-considerations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { defineFlatConfig } from "eslint-define-config";
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -81,6 +82,7 @@ const { defineFlatConfig } = require("eslint-define-config");
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down
11 changes: 8 additions & 3 deletions apps/docs-website/docs/setup/manual-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Follow these steps:
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand All @@ -47,6 +48,7 @@ Follow these steps:
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -77,6 +79,7 @@ Follow these steps:
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down Expand Up @@ -106,6 +109,7 @@ Follow these steps:
const sheriffOptions = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand All @@ -124,10 +128,10 @@ Follow these steps:

</Tabs>

1. Adopt `eslint.config.ts` (_optional_).
1. Adopt `eslint.config.ts` (_optional_).

If you want to have a `.ts` configuration file instead of the default `.js` file, follow these steps:

-
```bash npm2yarn
npm install -D eslint-ts-patch eslint@npm:eslint-ts-patch @sherifforg/types
Expand All @@ -143,6 +147,7 @@ Follow these steps:
const sheriffOptions: SheriffSettings = {
react: false,
next: false,
astro: false,
lodash: false,
playwright: false,
jest: false,
Expand Down
2 changes: 1 addition & 1 deletion apps/docs-website/docs/techs.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sidebar_position: 4
- [Prettier](https://prettier.io/)
- [Typescript](https://www.typescriptlang.org/) (_out of the box support_)
- [Storybook](https://storybook.js.org/) (_out of the box support_)
- [Astro](https://astro.build/) (_out of the box support_)
- [Astro](https://astro.build/) (_opt-in_)
- [React](https://reactjs.org/) (_opt-in_)
- [Next](https://nextjs.org/) (_opt-in_)
- [Lodash](https://lodash.com/) (_opt-in_)
Expand Down
12 changes: 10 additions & 2 deletions apps/docs-website/docs/vscode-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,18 @@ For [Astro](https://astro.build/) projects, add the astro extension too:

## Avoid "source.organizeImports"

Sheriff already handle imports sorting, so you have to disable thew VSCode automatic import sorting feature to avoid conflicts:
Sheriff already handles imports sorting, so if you happen to have enabled the VSCode automatic import sorting feature, you should disable it to avoid conflicts:

```JSONC title=".vscode/settings.json"
"editor.codeActionsOnSave": {
"source.organizeImports": false
"source.organizeImports": "never"
}
```

If you wish, you can automatically fix some ESLint violations on save, including sorting imports:

```JSONC title=".vscode/settings.json"
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
```
1 change: 1 addition & 0 deletions apps/docs-website/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const sheriffOptions = {
react: true,
lodash: true,
next: false,
astro: false,
playwright: false,
jest: false,
vitest: false,
Expand Down
1 change: 1 addition & 0 deletions apps/sheriff-webservices/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const sheriffOptions = {
react: false,
lodash: true,
next: false,
astro: false,
playwright: false,
jest: false,
vitest: false,
Expand Down
2 changes: 1 addition & 1 deletion apps/sheriff-webservices/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"eslint": "^8.57.0",
"eslint-config-sheriff": "workspace:*",
"eslint-plugin-arrow-return-style": "^1.3.0",
"eslint-plugin-astro": "^0.31.4",
"eslint-plugin-astro": "^1.2.3",
"eslint-plugin-fp": "^2.3.0",
"eslint-plugin-fsecond": "^1.1.1",
"eslint-plugin-import": "^2.27.5",
Expand Down
1 change: 1 addition & 0 deletions packages/create-sheriff-config/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const sheriffOptions = {
react: false,
lodash: true,
next: false,
astro: false,
playwright: false,
jest: false,
vitest: false,
Expand Down
1 change: 1 addition & 0 deletions packages/create-sheriff-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"devDependencies": {
"@sherifforg/constants": "workspace:*",
"@sherifforg/types": "workspace:*",
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.10.6",
"@types/yargs": "^17.0.32",
Expand Down
10 changes: 9 additions & 1 deletion packages/create-sheriff-config/src/utils/setSheriffConfig.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { highlight } from 'cli-highlight';
import { consola } from 'consola';
import { sheriffStartingOptions } from '@sherifforg/constants';
import type { SheriffConfigurablePlugins } from '@sherifforg/types';
import { getPackageJsonContents } from './getPackageJsonContents';
import { throwError } from './throwError';

export const setSheriffConfig = async (
customProjectRootPath: string | null,
): Promise<typeof sheriffStartingOptions> => {
): Promise<SheriffConfigurablePlugins> => {
const finalPluginsConfigurationSetup = sheriffStartingOptions;
const root = await getPackageJsonContents(customProjectRootPath);

Expand Down Expand Up @@ -48,6 +49,13 @@ export const setSheriffConfig = async (
finalPluginsConfigurationSetup.next = true;
}

if (userProjectDependencies.astro) {
consola.start(
"'Astro' package found in the project. Setting up support for it...",
);
finalPluginsConfigurationSetup.astro = true;
}

if (userProjectDependencies.lodash || userProjectDependencies['lodash-es']) {
consola.start(
"'Lodash' package found in the project. Setting up support for it...",
Expand Down
3 changes: 1 addition & 2 deletions packages/eslint-config-sheriff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,11 @@
"@next/eslint-plugin-next": "^13.2.3",
"@regru/eslint-plugin-prefer-early-return": "^1.0.0",
"@stylistic/eslint-plugin": "^1.5.1",
"astro-eslint-parser": "^0.16.3",
"eslint-config-flat-gitignore": "^0.1.3",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-arrow-return-style": "^1.3.0",
"eslint-plugin-astro": "^0.31.4",
"eslint-plugin-astro": "^1.2.3",
"eslint-plugin-fp": "^2.3.0",
"eslint-plugin-fsecond": "^1.1.1",
"eslint-plugin-import": "^2.27.5",
Expand Down
Loading

0 comments on commit 12158ee

Please sign in to comment.