Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: format all files #22

Merged
merged 3 commits into from
May 14, 2024
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
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ on:
- main

jobs:
verify_files:
name: Verify Files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "lts/*"

- name: Install Packages
run: npm install

- name: Lint Files
run: npm run lint

- name: Check Formatting
run: npm run fmt:check

build:
runs-on: ${{ matrix.os }}

Expand Down
60 changes: 30 additions & 30 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
# Output which releases were created
- name: Output release info
run: |
echo "releases_created:" ${{ steps.release.outputs.releases_created }}
echo "packages/compat--release_created:" ${{ steps.release.outputs['packages/compat--release_created'] }}
echo "packages/object-schema--release_created:" ${{ steps.release.outputs['packages/object-schema--release_created'] }}
echo "packages/config-array--release_created" ${{ steps.release.outputs['packages/config-array--release_created'] }}
echo "releases_created:" ${{ steps.release.outputs.releases_created }}
echo "packages/compat--release_created:" ${{ steps.release.outputs['packages/compat--release_created'] }}
echo "packages/object-schema--release_created:" ${{ steps.release.outputs['packages/object-schema--release_created'] }}
echo "packages/config-array--release_created" ${{ steps.release.outputs['packages/config-array--release_created'] }}

# Check to see if we need to do any releases and if so check out the repo
- uses: actions/checkout@v4
Expand All @@ -39,8 +39,8 @@ jobs:
registry-url: "https://registry.npmjs.org"

- run: |
npm install
npm run build
npm install
npm run build
if: ${{ steps.release.outputs.releases_created == 'true' }}

#-----------------------------------------------------------------------------
Expand All @@ -61,28 +61,28 @@ jobs:

- name: Publish @eslint/compat package to JSR
run: |
npm run build --if-present
npx jsr publish
npm run build --if-present
npx jsr publish
working-directory: packages/compat
if: ${{ steps.release.outputs['packages/compat--release_created'] }}

- name: Tweet Release Announcement
run: npx @humanwhocodes/tweet "@eslint/compat v${{ steps.release.outputs['packages/compat--major'] }}.${{ steps.release.outputs['packages/compat--minor'] }}.${{ steps.release.outputs['packages/compat--patch'] }} has been released!\n\n${{ github.event.repository.html_url }}/releases/tag/v${{ steps.release.outputs['packages/compat--tag_name'] }}"
if: ${{ steps.release.outputs['packages/compat--release_created'] }}
env:
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}

- name: Toot Release Announcement
run: npx @humanwhocodes/toot "@eslint/compat v${{ steps.release.outputs['packages/compat--major'] }}.${{ steps.release.outputs['packages/compat--minor'] }}.${{ steps.release.outputs['packages/compat--patch'] }} has been released!\n\n${{ github.event.repository.html_url }}/releases/tag/v${{ steps.release.outputs['packages/compat--tag_name'] }}"'
if: ${{ steps.release.outputs['packages/compat--release_created'] }}
env:
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MASTODON_HOST: ${{ secrets.MASTODON_HOST }}
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MASTODON_HOST: ${{ secrets.MASTODON_HOST }}

#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# @eslint/object-schema
#-----------------------------------------------------------------------------

Expand All @@ -101,17 +101,17 @@ jobs:
run: npx @humanwhocodes/tweet "@eslint/object-schema v${{ steps.release.outputs['packages/object-schema--major'] }}.${{ steps.release.outputs['packages/object-schema--minor'] }}.${{ steps.release.outputs['packages/object-schema--patch'] }} has been released!\n\n${{ github.event.repository.html_url }}/releases/tag/v${{ steps.release.outputs['packages/object-schema--tag_name'] }}"
if: ${{ steps.release.outputs['packages/object-schema--release_created'] }}
env:
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}

- name: Toot Release Announcement
run: npx @humanwhocodes/toot "@eslint/object-schema v${{ steps.release.outputs['packages/object-schema--major'] }}.${{ steps.release.outputs['packages/object-schema--minor'] }}.${{ steps.release.outputs['packages/object-schema--patch'] }} has been released!\n\n${{ github.event.repository.html_url }}/releases/tag/v${{ steps.release.outputs['packages/object-schema--tag_name'] }}"'
if: ${{ steps.release.outputs['packages/object-schema--release_created'] }}
env:
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MASTODON_HOST: ${{ secrets.MASTODON_HOST }}
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MASTODON_HOST: ${{ secrets.MASTODON_HOST }}

#-----------------------------------------------------------------------------
# @eslint/config-array
Expand All @@ -132,14 +132,14 @@ jobs:
run: npx @humanwhocodes/tweet "@eslint/config-array v${{ steps.release.outputs['packages/config-array--major'] }}.${{ steps.release.outputs['packages/config-array--minor'] }}.${{ steps.release.outputs['packages/config-array--patch'] }} has been released!\n\n${{ github.event.repository.html_url }}/releases/tag/v${{ steps.release.outputs['packages/config-array--tag_name'] }}"
if: ${{ steps.release.outputs['packages/config-array--release_created'] }}
env:
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}

- name: Toot Release Announcement
run: npx @humanwhocodes/toot "@eslint/config-array v${{ steps.release.outputs['packages/config-array--major'] }}.${{ steps.release.outputs['packages/config-array--minor'] }}.${{ steps.release.outputs['packages/config-array--patch'] }} has been released!\n\n${{ github.event.repository.html_url }}/releases/tag/v${{ steps.release.outputs['packages/config-array--tag_name'] }}"'
if: ${{ steps.release.outputs['packages/config-array--release_created'] }}
env:
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MASTODON_HOST: ${{ secrets.MASTODON_HOST }}
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MASTODON_HOST: ${{ secrets.MASTODON_HOST }}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist
CHANGELOG.md
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

Monorepo for the rewrite of ESLint.


## Packages

This repository is the home of the following packages:

* [`@eslint/object-schema`](packages/object-schema)
* [`@eslint/config-array`](packages/config-array)
* [`@eslint/compat`](packages/compat)
- [`@eslint/object-schema`](packages/object-schema)
- [`@eslint/config-array`](packages/config-array)
- [`@eslint/compat`](packages/compat)
6 changes: 3 additions & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default [
afterEach: "readonly",
before: "readonly",
after: "readonly",
}
}
}
},
},
},
];
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build": "node scripts/build.js",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"fmt": "prettier --write ."
"fmt": "prettier --write .",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should rather be fmt:fix and the check should be fmt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting is currently not covered by our package-json-conventions.

@nzakas what do you think about script names?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest lets keep the script name to be format for analysing formatting problems. and format:fix for the write formatted changes. I can send a PR to add it to package conventions as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format & format:fix would be aligned with lint & lint:fix, which looks good for consistency, but in the context of the word "format" it might be surprising that format only checks the format, so maybe format:check & format:fix?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this PR has a high potential of running into merge conflicts with any future PRs, what do you think about merging this now as-is, and continuing this discussion on a PR that updates package conventions? Then, we could get back to this repo and update the script names if needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea lets merge this PR and then pick this as a separate issue.

"fmt:check": "prettier --check ."
},
"workspaces": [
"packages/*"
Expand All @@ -20,7 +21,8 @@
"*.js": [
"eslint --fix",
"prettier --write"
]
],
"!(*.js)": "prettier --write --ignore-unknown"
Comment on lines 21 to +25
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prettier runs on all files, but separate "*.js" and "!(*.js)" tasks are needed to make sure that eslint runs before prettier on .js files.

https://github.com/lint-staged/lint-staged?tab=readme-ov-file#task-concurrency

},
"devDependencies": {
"@eslint/js": "^9.0.0",
Expand Down
59 changes: 29 additions & 30 deletions packages/compat/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# ESLint Compatibility Utilities


## Overview

This packages contains functions that allow you to wrap existing ESLint rules, plugins, and configurations that were intended for use with ESLint v8.x to allow them to work as-is in ESLint v9.x.
Expand Down Expand Up @@ -29,9 +28,9 @@ deno add @eslint/compat

This package exports the following functions in both ESM and CommonJS format:

* `fixupRule(rule)` - wraps the given rule in a compatibility layer and returns the result
* `fixupPluginRules(plugin)` - wraps each rule in the given plugin using `fixupRule()` and returns a new object that represents the plugin with the fixed-up rules
* `fixupConfigRules(configs)` - wraps all plugins found in an array of config objects using `fixupPluginRules()`
- `fixupRule(rule)` - wraps the given rule in a compatibility layer and returns the result
- `fixupPluginRules(plugin)` - wraps each rule in the given plugin using `fixupRule()` and returns a new object that represents the plugin with the fixed-up rules
- `fixupConfigRules(configs)` - wraps all plugins found in an array of config objects using `fixupPluginRules()`

### Fixing Rules

Expand Down Expand Up @@ -77,15 +76,15 @@ import { fixupPluginRules } from "@eslint/compat";
import somePlugin from "eslint-plugin-some-plugin";

export default [
{
plugins: {
// insert the fixed plugin instead of the original
somePlugin: fixupPluginRules(somePlugin)
},
rules: {
"somePlugin/rule-name": "error"
}
}
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prettier uses tabs by default? Seems like too much space from the existing one?

Copy link
Member Author

@mdjermanovic mdjermanovic May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, tabs are default in Prettier. - wrong

This is only 1 tab, but GitHub by default renders tabs as 8 spaces so it looks huge.

Copy link
Member Author

@mdjermanovic mdjermanovic May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub by default renders tabs as 8 spaces

It's configurable:

https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-user-account-settings/managing-your-tab-size-rendering-preference

I've just changed my Tab size preference to 4 and this looks the same as before on my screen:

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, prettier's default indentation is 2 spaces. But we configured it in this project to use tabs:

useTabs: true,

plugins: {
// insert the fixed plugin instead of the original
somePlugin: fixupPluginRules(somePlugin),
},
rules: {
"somePlugin/rule-name": "error",
},
},
];
```

Expand All @@ -97,15 +96,15 @@ const { fixupPluginRules } = require("@eslint/compat");
const somePlugin = require("eslint-plugin-some-plugin");

module.exports = [
{
plugins: {
// insert the fixed plugin instead of the original
somePlugin: fixupPluginRules(somePlugin)
},
rules: {
"somePlugin/rule-name": "error"
}
}
{
plugins: {
// insert the fixed plugin instead of the original
somePlugin: fixupPluginRules(somePlugin),
},
rules: {
"somePlugin/rule-name": "error",
},
},
];
```

Expand All @@ -119,10 +118,10 @@ import { fixupConfigRules } from "@eslint/compat";
import someConfig from "eslint-config-some-config";

export default [
...fixupConfigRules(someConfig),
{
// your overrides
}
...fixupConfigRules(someConfig),
{
// your overrides
},
];
```

Expand All @@ -134,10 +133,10 @@ const { fixupConfigRules } = require("@eslint/compat");
const someConfig = require("eslint-config-some-config");

module.exports = [
...fixupConfigRules(someConfig),
{
// your overrides
}
...fixupConfigRules(someConfig),
{
// your overrides
},
];
```

Expand Down
28 changes: 14 additions & 14 deletions packages/compat/jsr.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "@eslint/compat",
"version": "1.0.1",
"exports": "./dist/esm/index.js",
"publish": {
"include": [
"dist/esm/index.js",
"dist/esm/index.d.ts",
"dist/esm/types.d.ts",
"dist/esm/types.ts",
"README.md",
"jsr.json",
"LICENSE"
]
}
"name": "@eslint/compat",
"version": "1.0.1",
"exports": "./dist/esm/index.js",
"publish": {
"include": [
"dist/esm/index.js",
"dist/esm/index.d.ts",
"dist/esm/types.d.ts",
"dist/esm/types.ts",
"README.md",
"jsr.json",
"LICENSE"
]
}
}
28 changes: 14 additions & 14 deletions packages/compat/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@
export type FixupLegacyRuleDefinition = (context: Object) => Object;

export interface FixupRuleDefinition {
meta?: Object;
create(context: Object): Object;
meta?: Object;
create(context: Object): Object;
}

export interface FixupPluginDefinition {
meta?: Object;
rules?: Record<string, FixupRuleDefinition>;
configs?: Record<string, Object>;
processors?: Record<string, Object>;
meta?: Object;
rules?: Record<string, FixupRuleDefinition>;
configs?: Record<string, Object>;
processors?: Record<string, Object>;
}

export interface FixupConfig {
files?: Array<string>;
ignores?: Array<string>;
name?: string;
languageOptions?: Record<string, any>;
linterOptions?: Record<string, any>;
processor?: string|Object;
plugins?: Record<string, FixupPluginDefinition>;
rules?: Record<string, any>;
files?: Array<string>;
ignores?: Array<string>;
name?: string;
languageOptions?: Record<string, any>;
linterOptions?: Record<string, any>;
processor?: string | Object;
plugins?: Record<string, FixupPluginDefinition>;
rules?: Record<string, any>;
}

export type FixupConfigArray = Array<FixupConfig>;
2 changes: 1 addition & 1 deletion packages/compat/tsconfig.cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"outDir": "dist/cjs",
"moduleResolution": "Bundler",
"module": "Preserve"
},
}
}
2 changes: 1 addition & 1 deletion packages/compat/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "./tsconfig.json",
"files": ["dist/esm/index.js"],
"files": ["dist/esm/index.js"]
}
Loading