Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions packages/eslint-config/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# @prefabs.tech/eslint-config

Custom ESLint configuration for streamlined linting across projects.

## Supported configurations:

- `@prefabs.tech/eslint-config/fastify` fastify apis and libraries
- `@prefabs.tech/eslint-config/react` for react libraries
- `@prefabs.tech/eslint-config/react-app` for react apps
Expand All @@ -12,7 +14,7 @@ Custom ESLint configuration for streamlined linting across projects.

**Note:** For CommonJS projects, use `eslint.config.mjs` instead of `eslint.config.js`.

* ### For fastify apis and libraries:
- ### For fastify apis and libraries:

In the root directory of your app or package:

Expand All @@ -30,7 +32,7 @@ Custom ESLint configuration for streamlined linting across projects.
export default fastifyConfig;
```

* ### For react libraries:
- ### For react libraries:

In the root directory of your the react package:

Expand All @@ -48,7 +50,7 @@ Custom ESLint configuration for streamlined linting across projects.
export default reactConfig;
```

* ### For react apps:
- ### For react apps:

In the root directory of the react app:

Expand All @@ -60,13 +62,13 @@ Custom ESLint configuration for streamlined linting across projects.

Create a `eslint.config.js` file:

```js
import reactConfig from "@prefabs.tech/eslint-config/react-app.js";
```js
import reactConfig from "@prefabs.tech/eslint-config/react-app.js";

export default reactConfig;
```
export default reactConfig;
```

* ### For vue apps and libraries:
- ### For vue apps and libraries:

In the root directory of your app or package:

Expand Down Expand Up @@ -94,12 +96,13 @@ Custom ESLint configuration for streamlined linting across projects.
{
rules: {
"vue/no-reserved-component-names": "off",
}
}
},
},
];
```

* ### For general typescript projects:
- ### For general typescript projects:

In the root directory of your app or package:

Install dependencies:
Expand All @@ -117,15 +120,18 @@ Custom ESLint configuration for streamlined linting across projects.
```

## Adding linting scripts

In your `package.json`, add the following commands to the `scripts` section:

* For typescript or react projects:
- For typescript or react projects:

```json
"lint": "eslint .",
"lint:fix": "eslint . --fix"
```

## Running linting

Run the following command to lint your code:

```bash
Expand Down
5 changes: 5 additions & 0 deletions packages/eslint-config/fastify.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ import baseConfig from "./index.js";

export default [
...baseConfig,
{
rules: {
"@typescript-eslint/no-explicit-any": "error",
},
},
];
26 changes: 7 additions & 19 deletions packages/eslint-config/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import js from "@eslint/js";
import importPlugin from "eslint-plugin-import";
import nodePlugin from "eslint-plugin-n";
import perfectionistPlugin from "eslint-plugin-perfectionist";
import prettierPluginRecommened from "eslint-plugin-prettier/recommended";
import promisePlugin from "eslint-plugin-promise";
import unicornPlugin from "eslint-plugin-unicorn";
Expand All @@ -26,6 +27,7 @@ export default [
plugins: {
n: nodePlugin,
import: importPlugin,
perfectionist: perfectionistPlugin,
promise: promisePlugin,
unicorn: unicornPlugin,
},
Expand Down Expand Up @@ -55,25 +57,11 @@ export default [
// Import rules
...importPlugin.configs.recommended.rules,
...importPlugin.configs.typescript.rules,
"import/order": [
"error",
{
alphabetize: {
order: "asc",
caseInsensitive: true,
},
groups: [
"builtin",
"external",
"internal",
["parent", "sibling"],
"index",
"object",
"type",
],
"newlines-between": "always",
},
],
"import/order": "off",
"sort-imports": "off",

// Perfectionist rules
...perfectionistPlugin.configs["recommended-natural"].rules,

// Unicorn rules
...unicornPlugin.configs.recommended.rules,
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"eslint-plugin-import": "2.32.0",
"eslint-plugin-jsx-a11y": "6.10.2",
"eslint-plugin-n": "17.20.0",
"eslint-plugin-perfectionist": "5.9.0",
"eslint-plugin-prettier": "5.5.5",
"eslint-plugin-promise": "7.2.1",
"eslint-plugin-react": "7.37.5",
Expand Down
28 changes: 8 additions & 20 deletions packages/eslint-config/react.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import js from "@eslint/js";
import prettierConfig from "eslint-config-prettier";
import importPlugin from "eslint-plugin-import";
import unicornPlugin from "eslint-plugin-unicorn";
import perfectionistPlugin from "eslint-plugin-perfectionist";
import prettierPlugin from "eslint-plugin-prettier";
import unicornPlugin from "eslint-plugin-unicorn";
import globals from "globals";
import tseslint from "typescript-eslint";

Expand Down Expand Up @@ -35,6 +36,7 @@ export default [
plugins: {
"@typescript-eslint": tseslint.plugin,
import: importPlugin,
perfectionist: perfectionistPlugin,
prettier: prettierPlugin,
unicorn: unicornPlugin,
},
Expand All @@ -44,25 +46,11 @@ export default [
curly: ["error", "all"],

// Imports rules
"import/order": [
1,
{
alphabetize: {
order: "asc",
caseInsensitive: true,
},
groups: [
"builtin",
"external",
"internal",
["parent", "sibling"],
"index",
"object",
"type",
],
"newlines-between": "always",
},
],
"import/order": "off",
"sort-imports": "off",

// Perfectionist rules
...perfectionistPlugin.configs["recommended-natural"].rules,

"no-console": process.env.NODE_ENV === "production" ? "error" : "warn",
"no-debugger": process.env.NODE_ENV === "production" ? "error" : "warn",
Expand Down
26 changes: 7 additions & 19 deletions packages/eslint-config/vue.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import js from "@eslint/js";
import prettierConfig from "eslint-config-prettier";
import importPlugin from "eslint-plugin-import";
import perfectionistPlugin from "eslint-plugin-perfectionist";
import prettierPlugin from "eslint-plugin-prettier";
import unicornPlugin from "eslint-plugin-unicorn";
import vuePlugin from "eslint-plugin-vue";
Expand Down Expand Up @@ -41,6 +42,7 @@ export default [
},
plugins: {
import: importPlugin,
perfectionist: perfectionistPlugin,
prettier: prettierPlugin,
unicorn: unicornPlugin,
vue: vuePlugin,
Expand All @@ -53,25 +55,11 @@ export default [
// Import rules
...importPlugin.configs.recommended.rules,
...importPlugin.configs.typescript.rules,
"import/order": [
"error",
{
alphabetize: {
order: "asc",
caseInsensitive: true,
},
groups: [
"builtin",
"external",
"internal",
["parent", "sibling"],
"index",
"object",
"type",
],
"newlines-between": "always",
},
],
"import/order": "off",
"sort-imports": "off",

// Perfectionist rules
...perfectionistPlugin.configs["recommended-natural"].rules,

// Prettier rules
...prettierPlugin.configs.recommended.rules,
Expand Down
67 changes: 67 additions & 0 deletions packages/stylelint-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# @prefabs.tech/stylelint-config

Custom stylelint configuration for CSS/SCSS linting across projects.

## Supported configurations:

- `@prefabs.tech/stylelint-config` for CSS/SCSS linting in general projects
- `@prefabs.tech/stylelint-config/vue` for CSS/SCSS linting in Vue projects

## Installation and usage

**Note:** For CommonJS projects, use `stylelint.config.mjs` instead of `stylelint.config.js`.

- ### For general linting:

Install dependencies:

```sh
npm i -D @prefabs.tech/stylelint-config stylelint stylelint-config-standard stylelint-order
```

Create a `stylelint.config.js` file:

```js
import stylelintConfig from "@prefabs.tech/eslint-config/stylelint.js";

export default stylelintConfig;
```

### For Vue projects:

Install dependencies:

```sh
npm i -D @prefabs.tech/stylelint-config stylelint stylelint-config-recommended-vue stylelint-order
```

Create a `stylelint.config.js` file:

```js
import stylelintConfig from "@prefabs.tech/eslint-config/stylelint-vue.js";

export default stylelintConfig;
```

## Adding stylelint scripts

In your `package.json`, add the following commands to the `scripts` section:

```json
"stylelint": "stylelint \"src/**/*.{css,vue}\"",
"stylelint:fix": "stylelint \"src/**/*.{css,vue}\" --fix",
```

## Running stylelint

Run the following command to lint your code:

```bash
npm run stylelint
```

To automatically fix issues, run:

```bash
npm run stylelint:fix
```
14 changes: 14 additions & 0 deletions packages/stylelint-config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
extends: [
"stylelint-config-standard",
],
plugins: [
"stylelint-order",
],
rules: {
"custom-property-pattern": null,
"keyframes-name-pattern": null,
"order/properties-alphabetical-order": true,
"selector-class-pattern": null,
},
};
47 changes: 47 additions & 0 deletions packages/stylelint-config/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@prefabs.tech/stylelint-config",
"version": "0.6.0",
"description": "Stylelint config",
"homepage": "https://github.com/prefabs-tech/tools/tree/main/packages/stylelint-config#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/prefabs-tech/tools.git",
"directory": "packages/stylelint-config"
},
"license": "MIT",
"main": "index.js",
"type": "module",
"files": [
"index.js",
"vue.js"
],
"scripts": {
"sort-package": "npx sort-package-json"
},
"devDependencies": {
"stylelint": "17.9.1",
"stylelint-config-recommended-vue": "1.6.1",
"stylelint-config-standard": "40.0.0",
"stylelint-order": "8.1.1"
},
"peerDependencies": {
"stylelint": ">=17.0.0",
"stylelint-config-recommended-vue": ">=1.6.0",
"stylelint-config-standard": ">=40.0.0",
"stylelint-order": ">=8.0.0"
},
"peerDependenciesMeta": {
"stylelint-config-recommended-vue": {
"optional": true
},
"stylelint-config-standard": {
"optional": true
},
"stylelint-order": {
"optional": true
}
},
"publishConfig": {
"access": "public"
}
}
8 changes: 8 additions & 0 deletions packages/stylelint-config/vue.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import baseConfig from "./index.js";

export default {
...baseConfig,
extends: [
"stylelint-config-recommended-vue",
],
};
Loading
Loading