Skip to content

Commit

Permalink
chore(all): fix lint issues (#1270)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert authored Sep 24, 2022
1 parent 6090005 commit 4e85ed7
Show file tree
Hide file tree
Showing 40 changed files with 286 additions and 262 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/node-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ jobs:
node-version: ${{ matrix.node }}

- name: install pnpm
run: npm install pnpm@6 -g
run: npm install pnpm@7 -g

- name: pnpm install
run: pnpm install --ignore-scripts

- name: run tests
run: pnpm ci:test --filter "...[origin/master]"
run: pnpm --filter "...[origin/master]" ci:test
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- name: Install pnpm
run: |
npm install pnpm@6 -g;
npm install pnpm@7 -g;
echo node `pnpm -v`;
- name: Set Git Config
Expand All @@ -57,16 +57,16 @@ jobs:
run: pnpm install

- name: Build Packages
run: pnpm build --recursive
run: pnpm --recursive build

- name: Lint Monorepo
run: pnpm lint

- name: Run Tests
run: pnpm test --filter [HEAD^]
run: pnpm --filter [HEAD^] test

- name: Release and Publish Packages
run: pnpm release --filter [HEAD^]
run: pnpm --filter [HEAD^] release
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: git branch -f master origin/master

- name: Install pnpm
run: npm install pnpm@6 -g
run: npm install pnpm@7 -g

- name: Sanity Check
run: |
Expand All @@ -53,10 +53,10 @@ jobs:
# run: pnpm security

- name: Build Packages
run: pnpm build --recursive
run: pnpm --recursive build

- name: Lint Monorepo
run: pnpm lint:js

- name: Run Tests
run: pnpm ci:coverage --filter "...[origin/master]"
run: pnpm --filter "...[origin/master]" ci:coverage
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ enable-pre-post-scripts = true
link-workspace-packages = false
shamefully-hoist = true
shared-workspace-shrinkwrap = true
strict-peer-dependencies = false
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ All plugin packages are kept in the `/packages` directory.
#### Adding dependencies:

```console
$ pnpm add <package> --filter ./packages/<name>
$ pnpm --filter ./packages/<name> add <package>
```

Where `<package>` is the name of the NPM package you wish to add for a plugin package, and `<name>` is the proper name of the plugin. e.g. `@rollup/plugin-beep`.

#### Publishing:

```console
$ pnpm publish -- <name> [flags]
$ pnpm publish <name> [flags]
```

Where `<name>` is the portion of the plugin package name following `@rollup/plugin-`. (e.g. `beep`)
Expand Down Expand Up @@ -118,7 +118,7 @@ $ pnpm test
To run tests on a specific package:

```console
$ pnpm test --filter ./packages/<name>
$ pnpm --filter ./packages/<name> test
```

Linting:
Expand All @@ -132,10 +132,10 @@ $ pnpm lint
To lint a specific package:

```console
$ pnpm lint --filter ./packages/<name>
$ pnpm --filter ./packages/<name> lint
```

_Note: Scripts in the repository will run the root `test` and `lint` script on those packages which have changes. This is also how the CI pipelines function. To run either on a package outside of that pipeline, use `pnpm <script> -- @rollup/plugin-<name>`._
_Note: Scripts in the repository will run the root `test` and `lint` script on those packages which have changes. This is also how the CI pipelines function. To run either on a package outside of that pipeline, use `pnpm <script> @rollup/plugin-<name>`._

## Adding Plugins

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"husky": "8.0.1",
"lint-staged": "11.0.1",
"nyc": "^15.1.0",
"pnpm": "6.10.0",
"pnpm": "^7.12.2",
"prettier": "^2.2.1",
"prettier-plugin-package": "^1.3.0",
"semver": "^7.3.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/alias/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/auto-install/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/babel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"prebuild": "del-cli dist",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
Expand Down
9 changes: 8 additions & 1 deletion packages/babel/test/as-input-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as fs from 'fs';

import test from 'ava';
import { rollup } from 'rollup';
import { SourceMapConsumer } from 'source-map';
import jsonPlugin from '@rollup/plugin-json';
import nodeResolvePlugin from '@rollup/plugin-node-resolve';
import { createFilter } from '@rollup/pluginutils';
Expand Down Expand Up @@ -172,7 +171,15 @@ test('generates sourcemap by default', async (t) => {
} = await bundle.generate({ format: 'cjs', exports: 'auto', sourcemap: true });

const target = 'log';

// source-map uses the presence of fetch to detect browser environments which
// breaks in Node 18
const { fetch } = global;
delete global.fetch;
const { SourceMapConsumer } = await import('source-map');
const smc = await new SourceMapConsumer(map);
global.fetch = fetch;

const loc = getLocation(code, code.indexOf(target));
const original = smc.originalPositionFor(loc);

Expand Down
9 changes: 8 additions & 1 deletion packages/babel/test/as-output-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as nodePath from 'path';

import test from 'ava';
import { rollup } from 'rollup';
import { SourceMapConsumer } from 'source-map';

import { getCode } from '../../../util/test';

Expand Down Expand Up @@ -130,7 +129,15 @@ test('generates sourcemap by default', async (t) => {
});

const target = 'log';

// source-map uses the presence of fetch to detect browser environments which
// breaks in Node 18
const { fetch } = global;
delete global.fetch;
const { SourceMapConsumer } = await import('source-map');
const smc = await new SourceMapConsumer(map);
global.fetch = fetch;

const loc = getLocation(code, code.indexOf(target));
const original = smc.originalPositionFor(loc);

Expand Down
2 changes: 2 additions & 0 deletions packages/babel/test/fixtures/proposal-decorators/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unused-vars */

@annotation
export default class MyClass {}

Expand Down
2 changes: 1 addition & 1 deletion packages/buble/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/commonjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"prepublishOnly": "pnpm build",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
Expand Down
7 changes: 5 additions & 2 deletions packages/commonjs/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@ test('generates a sourcemap', async (t) => {
sourcemapFile: path.resolve('bundle.js')
});

// Hack to make it work on Node 18
// source-map uses the presence of fetch to detect browser environments which
// breaks in Node 18
const { fetch } = global;
delete global.fetch;
const { SourceMapConsumer } = await import('source-map');
const smc = await new SourceMapConsumer(map);
const locator = getLocator(code, { offsetLine: 1 });
global.fetch = fetch;

const locator = getLocator(code, { offsetLine: 1 });
let generatedLoc = locator('42');
let loc = smc.originalPositionFor(generatedLoc); // 42
t.is(loc.source, 'fixtures/samples/sourcemap/foo.js');
Expand Down
4 changes: 2 additions & 2 deletions packages/data-uri/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"ci:test": "pnpm test -- --verbose",
"prebuild": "del-cli dist",
"prerelease": "pnpm build",
"pretest": "pnpm build -- --sourcemap",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"pretest": "pnpm build --sourcemap",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/dsv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava"
},
"files": [
Expand Down
4 changes: 2 additions & 2 deletions packages/dynamic-import-vars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"ci:test": "pnpm test -- --verbose",
"prebuild": "del-cli dist",
"prerelease": "pnpm build",
"pretest": "pnpm build -- --sourcemap",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"pretest": "pnpm build --sourcemap",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"prebuild": "del-cli dist",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/inject/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc index.d.ts test/types.ts --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava"
},
"files": [
Expand Down
2 changes: 1 addition & 1 deletion packages/multi-entry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava"
},
"files": [
Expand Down
6 changes: 3 additions & 3 deletions packages/node-resolve/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov",
"ci:lint": "pnpm build && pnpm lint",
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
"ci:test": "pnpm test -- --verbose && pnpm test:ts",
"ci:test": "pnpm test -- --verbose",
"prebuild": "del-cli dist",
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prepublishOnly": "pnpm build",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"test": "ava && pnpm test:ts",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "pnpm test:ts && ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
"files": [
Expand Down
4 changes: 2 additions & 2 deletions packages/pluginutils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"prebuild": "del-cli dist",
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build -- --sourcemap",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"pretest": "pnpm build --sourcemap",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc --noEmit"
},
Expand Down
1 change: 1 addition & 0 deletions packages/pluginutils/src/dataToEsm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function serialize(obj: unknown, indent: Indent, baseIndent: string): string {
}
if (typeof obj === 'symbol') {
const key = Symbol.keyFor(obj);
// eslint-disable-next-line no-undefined
if (key !== undefined) return `Symbol.for(${stringify(key)})`;
}
if (typeof obj === 'bigint') return `${obj}n`;
Expand Down
2 changes: 1 addition & 1 deletion packages/replace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"prepare": "if [ ! -d 'dist' ]; then pnpm build; fi",
"prerelease": "pnpm build",
"pretest": "pnpm build",
"release": "pnpm plugin:release --workspace-root -- --pkg $npm_package_name",
"release": "pnpm --workspace-root plugin:release --pkg $npm_package_name",
"test": "ava",
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
Expand Down
7 changes: 6 additions & 1 deletion packages/replace/test/sourcemaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

const test = require('ava');
const { rollup } = require('rollup');
const { SourceMapConsumer } = require('source-map');
const { getLocator } = require('locate-character');
// source-map uses the presence of fetch to detect browser environments which
// breaks in Node 18
const { fetch } = global;
delete global.fetch;
const { SourceMapConsumer } = require('source-map');

global.fetch = fetch;
const replace = require('../dist/rollup-plugin-replace.cjs.js');

const { getOutputFromGenerated } = require('./helpers/util');
Expand Down
Loading

0 comments on commit 4e85ed7

Please sign in to comment.