Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
8147357
runs tests of Windows
dimaMachina Nov 13, 2024
8843865
fix
dimaMachina Nov 13, 2024
9498762
prettier
dimaMachina Nov 13, 2024
5cbc87a
fix lint
dimaMachina Nov 13, 2024
1e3545b
set ``"moduleResolution": "bundler"`
dimaMachina Nov 13, 2024
d3a7e37
set `"module": "esnext"`
dimaMachina Nov 13, 2024
7cf03ee
try to fix examples.spec.ts
dimaMachina Nov 13, 2024
f544776
use optional chaining
dimaMachina Nov 13, 2024
fc30129
add log
dimaMachina Nov 13, 2024
4ddd75b
fix
dimaMachina Nov 13, 2024
d8b6fd1
should fix
dimaMachina Nov 13, 2024
f58f2a7
fix new line on windows
dimaMachina Nov 13, 2024
bea628f
fix
dimaMachina Nov 13, 2024
2d61d2b
and here
dimaMachina Nov 13, 2024
d7bf065
maybe this
dimaMachina Nov 13, 2024
fbfab61
try
dimaMachina Nov 13, 2024
c8c499a
try
dimaMachina Nov 13, 2024
09eccb7
try
dimaMachina Nov 13, 2024
2ccc2d4
attempt to fix schema.spec
dimaMachina Nov 13, 2024
0829d95
add shell: true
dimaMachina Nov 13, 2024
a7fed92
improve
dimaMachina Nov 13, 2024
3a9214f
try
dimaMachina Nov 13, 2024
8db9020
try
dimaMachina Nov 13, 2024
9cad17a
try
dimaMachina Nov 13, 2024
6b55c88
try
dimaMachina Nov 13, 2024
3eb4e72
try
dimaMachina Nov 13, 2024
03852ab
try
dimaMachina Nov 13, 2024
d90176a
try fix prettier example on windows
dimaMachina Nov 13, 2024
5d37b79
try
dimaMachina Nov 13, 2024
4de0722
try now
dimaMachina Nov 13, 2024
1db7b06
try now
dimaMachina Nov 13, 2024
c3daf77
more
dimaMachina Nov 13, 2024
5d03814
try
dimaMachina Nov 13, 2024
32394d4
Merge branch 'master' into runs-tests-on-windows
dimaMachina Nov 13, 2024
d4cfd8a
upd banner
dimaMachina Nov 13, 2024
d0d7732
Merge branch 'master' into runs-tests-on-windows
dimaMachina Nov 13, 2024
634918f
merge
dimaMachina Nov 13, 2024
3e0d963
Merge branch 'master' into runs-tests-on-windows
dimaMachina Nov 13, 2024
d70be52
more
dimaMachina Nov 13, 2024
1318f08
more
dimaMachina Nov 13, 2024
9cf7003
more
dimaMachina Nov 13, 2024
6f3969f
fix
dimaMachina Nov 13, 2024
3aff50b
log
dimaMachina Nov 13, 2024
bff0e98
more
dimaMachina Nov 13, 2024
b2c37cc
now
dimaMachina Nov 13, 2024
9ee17c4
more
dimaMachina Nov 13, 2024
e7548a9
try slash for filePath
dimaMachina Nov 13, 2024
8e5faae
yoyo
dimaMachina Nov 13, 2024
f20bbc1
more
dimaMachina Nov 13, 2024
1a6b675
try
dimaMachina Nov 13, 2024
ff9320e
add changeset
dimaMachina Nov 13, 2024
f2d4dc5
aa
dimaMachina Nov 13, 2024
6a82aec
more
dimaMachina Nov 13, 2024
d616168
i know the problem
dimaMachina Nov 13, 2024
7b80f95
fix eslint tailwindcss
dimaMachina Nov 13, 2024
e02992f
see
dimaMachina Nov 13, 2024
2501773
aa
dimaMachina Nov 13, 2024
bbf71c2
use `"eslint-plugin-tailwindcss": "3.17.3"`
dimaMachina Nov 13, 2024
ee0c130
yes
dimaMachina Nov 13, 2024
091f59e
should be all good now
dimaMachina Nov 13, 2024
d14482b
try now
dimaMachina Nov 13, 2024
1836e8a
thiiis
dimaMachina Nov 13, 2024
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
35 changes: 21 additions & 14 deletions .changeset/chilled-rivers-prove.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,33 @@

1. graphql plugin can now we be specified as

```js
plugins: { '@graphql-eslint': graphqlPlugin }
```
```diff
plugins: {
- '@graphql-eslint': {
- graphqlPlugin.rules
- }
+ '@graphql-eslint': graphqlPlugin
}
```

1. Config rules should now be accessed through the `rules` property

```diff
rules: {
- ...graphqlESLint.configs['flat/operations-recommended']
+ ...graphqlESLint.configs['flat/operations-recommended'].rules
```
```diff
rules: {
- ...graphqlESLint.configs['flat/operations-recommended']
+ ...graphqlESLint.configs['flat/operations-recommended'].rules
```

1. processor can now be specified with accessing `processor` property

```js
processor: graphqlPlugin.processor
```
```diff
- processor: graphql.processors.graphql
+ processor: graphqlPlugin.processor
```

1. The plugin can now be imported using a default import

```js
import graphqlPlugin from '@graphql-eslint/eslint-plugin'
```
```diff
- import * as graphql from '@graphql-eslint/eslint-plugin'
+ import graphqlPlugin from '@graphql-eslint/eslint-plugin'
```
5 changes: 5 additions & 0 deletions .changeset/metal-wasps-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-eslint/eslint-plugin': patch
---

fix some issues on Windows by running tests with matrix on github CI
19 changes: 14 additions & 5 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = {
],
rules: {
'unicorn/prefer-array-some': 'error',
'unicorn/better-regex': 'error',
'prefer-destructuring': ['error', { VariableDeclarator: { object: true } }],
quotes: ['error', 'single', { avoidEscape: true }], // Matches Prettier, but also replaces backticks
},
Expand All @@ -28,9 +27,6 @@ module.exports = {
'@typescript-eslint/array-type': ['error', { readonly: 'generic' }],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'no-type-imports' }],
},
parserOptions: {
project: ['tsconfig.json', 'website/tsconfig.json', 'tsconfig.eslint.json'],
},
},
{
files: ['**/rules/*.ts'],
Expand Down Expand Up @@ -99,7 +95,12 @@ module.exports = {
'error',
{
// TODO: figure out why there is an error only on CI
whitelist: ['nextra-scrollbar'],
whitelist: [
'nextra-scrollbar',
'_text-primary-600',
'_underline',
'_decoration-from-font',
],
},
],
'react/no-unknown-property': ['error', { ignore: ['jsx', 'global'] }],
Expand All @@ -110,5 +111,13 @@ module.exports = {
},
},
},
{
files: ['website/**/*.mdx'],
rules: {
// TODO: remove `# {frontMatter.title}` and this override
'@typescript-eslint/no-unused-expressions': 'off',
'no-undef': 'off',
},
},
],
};
32 changes: 26 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,27 @@ jobs:
githubToken: ${{ secrets.GITHUB_TOKEN }}

typecheck:
name: typecheck / graphql v${{matrix.graphql_version}}
runs-on: ubuntu-latest
name: typecheck / graphql v${{matrix.graphql_version}} (${{matrix.os}})
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
graphql_version: [16]

steps:
- name: Checkout Master
- name: Checkout out code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-

- name: Setup ENV
uses: the-guild-org/shared-config/setup@main
with:
Expand All @@ -39,13 +48,16 @@ jobs:
run: pnpm build

test:
name: Node.js v${{matrix.node_version}} / GraphQL v${{matrix.graphql_version}} / ESLint v9
name:
Node.js v${{matrix.node_version}} / GraphQL v${{matrix.graphql_version}} / ESLint v9
(${{matrix.os}})
timeout-minutes: 60
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
needs: [typecheck]
strategy:
matrix:
node_version: [18, 20, 22]
os: [ubuntu-latest, windows-latest]
node_version: [22]
graphql_version: [16]

steps:
Expand All @@ -54,6 +66,14 @@ jobs:
with:
fetch-depth: 0

- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-

- name: Setup ENV
uses: the-guild-org/shared-config/setup@main
with:
Expand Down
7 changes: 0 additions & 7 deletions .prettierrc.cjs

This file was deleted.

3 changes: 3 additions & 0 deletions examples/prettier/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ module.exports = {
env: {
es6: true,
},
parserOptions: {
sourceType: 'module',
},
},
{
files: ['*.graphql'],
Expand Down
4 changes: 4 additions & 0 deletions examples/prettier/prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default {
endOfLine: 'auto',
singleQuote: true,
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"scripts": {
"build": "turbo run build --filter=!website && attw --pack packages/plugin/dist",
"ci:lint": "ESLINT_USE_FLAT_CONFIG=false eslint --ignore-path .gitignore --output-file eslint_report.json --format json .",
"ci:lint": "pnpm lint --output-file eslint_report.json --format json",
"create-rule": "tsx scripts/create-rule.ts",
"generate:configs": "tsx scripts/generate-configs.ts",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint --ignore-path .gitignore --cache .",
Expand All @@ -30,7 +30,7 @@
"@changesets/cli": "2.27.9",
"@graphql-tools/utils": "10.5.6",
"@theguild/eslint-config": "0.13.0",
"@theguild/prettier-config": "2.0.7",
"@theguild/prettier-config": "3.0.0",
"@types/dedent": "0.7.2",
"@types/node": "22.9.0",
"chalk": "5.3.0",
Expand Down
50 changes: 32 additions & 18 deletions packages/plugin/__tests__/examples.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { spawnSync } from 'node:child_process';
import { join, relative } from 'node:path';
import os from 'node:os';
import path from 'node:path';
import { ESLint } from 'eslint';
import { CWD as PROJECT_CWD } from '../src/utils.js';
import { CWD as PROJECT_CWD, slash } from '../src/utils.js';

const CWD = join(PROJECT_CWD, '..', '..');
const CWD = path.join(PROJECT_CWD, '..', '..');

function countErrors(results: ESLint.LintResult[]): number {
return results.reduce<number>((acc, curr: ESLint.LintResult & { fatalErrorCount: number }) => {
Expand All @@ -18,7 +19,11 @@ ${results.map(result => result.messages.map(m => m.message)).join('\n\n')}
}

function getFlatESLintOutput(cwd: string): ESLint.LintResult[] {
const { stdout, stderr } = spawnSync('eslint', ['--format', 'json', '.'], { cwd });
const { stdout, stderr } = spawnSync('eslint', ['--format', 'json', '.'], {
cwd,
// For Windows, otherwise `stdout` and `stderr` are `null`
shell: os.platform() === 'win32',
});

return parseESLintOutput({ stdout, stderr });
}
Expand All @@ -30,6 +35,8 @@ function getLegacyESLintOutput(cwd: string): ESLint.LintResult[] {
{
cwd,
env: { ...process.env, ESLINT_USE_FLAT_CONFIG: 'false' },
// For Windows, otherwise `stdout` and `stderr` are `null`
shell: os.platform() === 'win32',
},
);

Expand All @@ -46,10 +53,15 @@ function parseESLintOutput({
const errorOutput = stderr
.toString()
.replace(
/\(node:\d{4,7}\) \[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead./,
/\(node:\d+\) \[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead./,
'',
)
.replace(
/\(node:\d+\) ESLintRCWarning: You are using an eslintrc configuration file, which is deprecated and support will be removed in v10.0.0. Please migrate to an eslint.config.js file. See https:\/\/eslint.org\/docs\/latest\/use\/configure\/migration-guide for details./,
'',
)
.replace('(Use `node --trace-deprecation ...` to show where the warning was created)', '')
.replace('(Use `node --trace-warnings ...` to show where the warning was created)', '')
.trimEnd();
if (errorOutput) {
throw new Error(errorOutput);
Expand All @@ -63,60 +75,62 @@ function parseESLintOutput({
function normalizeResults(results: ESLint.LintResult[]) {
return results
.map(result => ({
filePath: relative(CWD, result.filePath),
filePath: slash(path.relative(CWD, result.filePath)),
messages: result.messages,
}))
.filter(result => result.messages.length > 0);
}

describe('Examples', () => {
it('should work programmatically', () => {
const cwd = join(CWD, 'examples/programmatic');
const cwd = path.join(CWD, 'examples', 'programmatic');
testESLintOutput(cwd, 6);
});

it('should work on `.js` files', () => {
const cwd = join(CWD, 'examples/code-file');
const cwd = path.join(CWD, 'examples', 'code-file');
testESLintOutput(cwd, 4);
});

it('should work with `graphql-config`', () => {
const cwd = join(CWD, 'examples/graphql-config');
const cwd = path.join(CWD, 'examples', 'graphql-config');
testESLintOutput(cwd, 2);
});

it('should work with `eslint-plugin-prettier`', () => {
const cwd = join(CWD, 'examples/prettier');
const cwd = path.join(CWD, 'examples', 'prettier');
testESLintOutput(cwd, 23);
});

it('should work in monorepo', () => {
const cwd = join(CWD, 'examples/monorepo');
const cwd = path.join(CWD, 'examples', 'monorepo');
testESLintOutput(cwd, 11);
});

it('should work in svelte', () => {
const cwd = join(CWD, 'examples/svelte-code-file');
const cwd = path.join(CWD, 'examples', 'svelte-code-file');
testESLintOutput(cwd, 2);
});

it('should work in vue', () => {
const cwd = join(CWD, 'examples/vue-code-file');
const cwd = path.join(CWD, 'examples', 'vue-code-file');
testESLintOutput(cwd, 2);
});

it('should work in multiple projects', () => {
const cwd = join(CWD, 'examples/multiple-projects-graphql-config');
const cwd = path.join(CWD, 'examples', 'multiple-projects-graphql-config');
testESLintOutput(cwd, 4);
});
});

function testESLintOutput(cwd: string, errorCount: number): void {
const flatResults = getFlatESLintOutput(cwd);
expect(countErrors(flatResults)).toBe(errorCount);
expect(normalizeResults(flatResults)).toMatchSnapshot();

const results = getLegacyESLintOutput(cwd);
// Windows has some offset for `range`, I think due \r\n handling
if (os.platform() !== 'win32') {
expect(normalizeResults(flatResults)).toMatchSnapshot();
expect(normalizeResults(results)).toMatchSnapshot();
}
expect(countErrors(flatResults)).toBe(errorCount);
expect(countErrors(results)).toBe(errorCount);
expect(normalizeResults(results)).toMatchSnapshot();
}
Loading
Loading