Skip to content

Commit

Permalink
chore: use shared prettier config
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalexiei committed Oct 27, 2024
1 parent 3508675 commit d69f53c
Show file tree
Hide file tree
Showing 42 changed files with 383 additions and 363 deletions.
9 changes: 7 additions & 2 deletions .eslint-doc-generatorrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import prettier from "prettier";
import * as prettier from 'prettier';
import prettierConfig from '@marcalexiei/prettier-config';

/** @type {import('eslint-doc-generator').GenerateOptions} */
export default {
postprocess: (content) => prettier.format(content, { parser: "markdown" }),
postprocess: (content) => {
/** @type {import('prettier').Options} */
const options = { parser: 'markdown', ...prettierConfig };
return prettier.format(content, options);
},
};
8 changes: 4 additions & 4 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: This is a composite GitHub Action that sets up pnpm, node and insta

inputs:
node-version:
description: "Explicit node version. Otherwise fallback reading `.nvmrc`"
description: 'Explicit node version. Otherwise fallback reading `.nvmrc`'

runs:
using: composite
Expand All @@ -16,14 +16,14 @@ runs:
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: "pnpm"
cache: 'pnpm'

- name: Setup Node.js (via .nvmrc)
if: ${{ !inputs.node-version }}
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "pnpm"
node-version-file: '.nvmrc'
cache: 'pnpm'

- name: Install Dependencies
shell: bash
Expand Down
52 changes: 26 additions & 26 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
version: 2

updates:
- package-ecosystem: "github-actions"
directory: "/"
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: "weekly"
interval: 'weekly'
open-pull-requests-limit: 10

- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "weekly"
interval: 'weekly'
open-pull-requests-limit: 10
groups:
dev-deps-changeset:
applies-to: "version-updates"
dependency-type: "development"
applies-to: 'version-updates'
dependency-type: 'development'
patterns:
- "@changesets/*"
- '@changesets/*'

dev-deps-code-check:
applies-to: "version-updates"
dependency-type: "development"
applies-to: 'version-updates'
dependency-type: 'development'
patterns:
- "prettier"
- "eslint"
- "eslint-*"
- "@eslint/*"
- "typescript-eslint"
- 'prettier'
- 'eslint'
- 'eslint-*'
- '@eslint/*'
- 'typescript-eslint'

dev-deps-build:
applies-to: "version-updates"
dependency-type: "development"
applies-to: 'version-updates'
dependency-type: 'development'
patterns:
- "@types/*"
- "@rollup/*"
- "rollup"
- "typescript"
- "@typescript-eslint/"
- '@types/*'
- '@rollup/*'
- 'rollup'
- 'typescript'
- '@typescript-eslint/'

dev-deps-test:
applies-to: "version-updates"
dependency-type: "development"
applies-to: 'version-updates'
dependency-type: 'development'
patterns:
- "vitest"
- 'vitest'
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI

concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
group: '${{ github.workflow }}-${{ github.head_ref || github.ref }}'
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

on:
Expand Down Expand Up @@ -44,10 +44,10 @@ jobs:
strategy:
fail-fast: true
matrix:
script: ["lint", "format"]
script: ['lint', 'format']
include:
- needsBuild: true
script: "lint"
script: 'lint'

steps:
- name: Checkout
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ jobs:
id: changesets
uses: changesets/action@v1
with:
commit: "chore: release"
title: "chore: release"
publish: "pnpm release"
commit: 'chore: release'
title: 'chore: release'
publish: 'pnpm release'
env:
GITHUB_TOKEN: ${{ secrets.CHANGESET_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_CONFIG_PROVENANCE: true

on-ci-fail:
name: "Failure"
name: 'Failure'
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pnpm add --save-dev eslint eslint-plugin-react-import

```js
// eslint.config.js
import eslintPluginReactImport from "eslint-plugin-react-import";
import eslintPluginReactImport from 'eslint-plugin-react-import';
export default [
// other configs
// ...
Expand All @@ -63,8 +63,8 @@ export default [
```js
// eslint.config.js
import eslintPluginReactImport from "eslint-plugin-react-import";
import typescriptEslintParser from "@typescript-eslint/parser";
import eslintPluginReactImport from 'eslint-plugin-react-import';
import typescriptEslintParser from '@typescript-eslint/parser';

export default [
// other configs
Expand All @@ -89,16 +89,16 @@ module.exports = {
root: true,
plugins: [
// Other plugins...
"react-import",
'react-import',
],
// Remember to change parser if you are using ts
parser: "@typescript-eslint/parser",
parser: '@typescript-eslint/parser',
parserOptions: {
// ...
},
rules: {
// Configure the rule
"react-import/consistent-syntax": ["error", "namespace"],
'react-import/consistent-syntax': ['error', 'namespace'],
},
};
```
12 changes: 6 additions & 6 deletions docs/rules/consistent-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
Examples of **incorrect** code for this rule:

```js
import React, { useState } from "react";
import React, { useState } from 'react';
```

Examples of **correct** code for this rule:

```js
import * as React from "react";
import * as React from 'react';
```

## Options
Expand All @@ -34,27 +34,27 @@ This rule has one string options that allows to choose the preferred syntax for
Examples of **incorrect** code with this option:

```js
import React, { useState } from "react";
import React, { useState } from 'react';
```

Examples of **correct** code with this option:

```js
import * as React from "react";
import * as React from 'react';
```

### `default`

Examples of **incorrect** code with this option:

```js
import * as React from "react";
import * as React from 'react';
```

Examples of **correct** code with this option:

```js
import React from "react";
import React from 'react';
```

## When Not To Use It
Expand Down
20 changes: 10 additions & 10 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import pluginJs from "@eslint/js";
import pluginEslintPlugin from "eslint-plugin-eslint-plugin";
import pluginEslintNode from "eslint-plugin-n";
import tseslint from "typescript-eslint";
import pluginJs from '@eslint/js';
import pluginEslintPlugin from 'eslint-plugin-eslint-plugin';
import pluginEslintNode from 'eslint-plugin-n';
import tseslint from 'typescript-eslint';

/** @type {Array<import('eslint').Linter.Config>} */
export default [
{
ignores: ["dist", "coverage", "tests/fixtures/**/*"],
ignores: ['dist', 'coverage', 'tests/fixtures/**/*'],
},
pluginJs.configs.recommended,
pluginEslintPlugin.configs["flat/recommended"],
pluginEslintPlugin.configs['flat/recommended'],
{
...pluginEslintNode.configs["flat/recommended-module"],
...pluginEslintNode.configs['flat/recommended-module'],
rules: {
...pluginEslintNode.configs["flat/recommended-module"].rules,
"n/no-missing-import": ["error", { allowModules: ["estree"] }],
...pluginEslintNode.configs['flat/recommended-module'].rules,
'n/no-missing-import': ['error', { allowModules: ['estree'] }],
},
},
{
Expand All @@ -27,6 +27,6 @@ export default [
// typechecking related rule should run only inside src
...tseslint.configs.strictTypeChecked.map((it) => ({
...it,
files: ["src/**/*.{js,mjs,cjs,ts}"],
files: ['src/**/*.{js,mjs,cjs,ts}'],
})),
];
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"scripts": {
"build": "rollup --config",
"lint": "pnpm run lint:js && eslint-doc-generator",
"lint": "pnpm run lint:js && pnpm run lint:docs",
"lint:js": "eslint .",
"lint:js:fix": "eslint . --fix",
"lint:docs": "eslint-doc-generator --check",
Expand All @@ -45,14 +45,16 @@
"release": "pnpm run build && changeset publish",
"check-all": "pnpm run \"/^(lint|format|typecheck|build)$/\" && pnpm run test --run"
},
"packageManager": "pnpm@9.10.0+sha512.73a29afa36a0d092ece5271de5177ecbf8318d454ecd701343131b8ebc0c1a91c487da46ab77c8e596d6acf1461e3594ced4becedf8921b074fbd8653ed7051c",
"packageManager": "pnpm@9.12.2+sha512.22721b3a11f81661ae1ec68ce1a7b879425a1ca5b991c975b074ac220b187ce56c708fe5db69f4c962c989452eee76c82877f4ee80f474cebd61ee13461b6228",
"prettier": "@marcalexiei/prettier-config",
"peerDependencies": {
"eslint": "^8.57 || ^9"
},
"devDependencies": {
"@changesets/changelog-github": "0.5.0",
"@changesets/cli": "2.27.9",
"@eslint/js": "9.13.0",
"@marcalexiei/prettier-config": "1.0.4",
"@rollup/plugin-typescript": "12.1.1",
"@types/estree": "1.0.6",
"@types/json-schema": "7.0.15",
Expand Down
13 changes: 13 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
packages:
- "./"
- "./tests/fixtures/**"
- './'
- './tests/fixtures/**'
28 changes: 14 additions & 14 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { promises as fs } from "node:fs";
import { promises as fs } from 'node:fs';

import { defineConfig } from "rollup";
import typescript from "@rollup/plugin-typescript";
import { defineConfig } from 'rollup';
import typescript from '@rollup/plugin-typescript';

export default defineConfig({
input: "src/index.ts",
input: 'src/index.ts',

output: [
{
dir: "dist",
entryFileNames: "[name].js",
format: "esm",
dir: 'dist',
entryFileNames: '[name].js',
format: 'esm',
sourcemap: true,
},
{
dir: "dist",
entryFileNames: "[name].cjs",
format: "cjs",
dir: 'dist',
entryFileNames: '[name].cjs',
format: 'cjs',
sourcemap: true,
},
],
plugins: [
typescript({ tsconfig: "tsconfig.build.json" }),
typescript({ tsconfig: 'tsconfig.build.json' }),
{
name: "clean-dist",
name: 'clean-dist',
async buildStart() {
await fs.rm("./dist", { recursive: true, force: true });
await fs.rm('./dist', { recursive: true, force: true });
},
},
],
external: ["eslint", "node:fs"],
external: ['eslint', 'node:fs'],
});
Loading

0 comments on commit d69f53c

Please sign in to comment.