Skip to content

Commit

Permalink
chore: Always lint types folder and JSON (rollup#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotWoods authored and LarsDenBakker committed Sep 12, 2020
1 parent 1b664e9 commit b1f4ffa
Show file tree
Hide file tree
Showing 47 changed files with 135 additions and 165 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"ci:coverage:submit": "node scripts/codecov",
"ci:lint": "node scripts/run-changed.js ci:lint",
"ci:test": "node scripts/run-changed.js ci:test",
"lint": "pnpm run lint:docs && pnpm run lint:package && node scripts/run-changed.js lint",
"lint:docs": "prettier --write README.md",
"lint": "pnpm run lint:docs && npm run lint:json && pnpm run lint:package && node scripts/run-changed.js lint",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint scripts util",
"lint:json": "prettier --single-quote --write tsconfig.*.json codecov.yml pnpm-workspace.yaml",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"preinstall": "node scripts/disallow-npm.js",
"pub": "node scripts/pub.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/alias/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"ci:test": "pnpm run test -- --verbose",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint --fix --cache src test --ext .js,.ts",
"lint:js": "eslint --fix --cache src test types --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prebuild": "del-cli dist",
"prepare": "pnpm run build",
Expand Down
4 changes: 0 additions & 4 deletions packages/alias/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"lib": ["es6"],
"module": "esnext"
},
"include": [
"src/**/*",
"types/**/*"
Expand Down
38 changes: 19 additions & 19 deletions packages/alias/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import { Plugin, ResolveIdResult } from 'rollup';

export interface Alias {
find: string | RegExp;
replacement: string;
customResolver?: ResolverFunction | ResolverObject | null;
find: string | RegExp;
replacement: string;
customResolver?: ResolverFunction | ResolverObject | null;
}

export type ResolverFunction = (
source: string,
importer: string | undefined
source: string,
importer: string | undefined
) => Promise<ResolveIdResult> | ResolveIdResult;

export interface ResolverObject {
resolveId: ResolverFunction;
resolveId: ResolverFunction;
}

export interface RollupAliasOptions {
/**
* Instructs the plugin to use an alternative resolving algorithm,
* rather than the Rollup's resolver.
* @default null
*/
customResolver?: ResolverFunction | ResolverObject | null;
/**
* Instructs the plugin to use an alternative resolving algorithm,
* rather than the Rollup's resolver.
* @default null
*/
customResolver?: ResolverFunction | ResolverObject | null;

/**
* Specifies an `Object`, or an `Array` of `Object`,
* which defines aliases used to replace values in `import` or `require` statements.
* With either format, the order of the entries is important,
* in that the first defined rules are applied first.
*/
entries?: readonly Alias[] | { [find: string]: string };
/**
* Specifies an `Object`, or an `Array` of `Object`,
* which defines aliases used to replace values in `import` or `require` statements.
* With either format, the order of the entries is important,
* in that the first defined rules are applied first.
*/
entries?: readonly Alias[] | { [find: string]: string };
}

/**
Expand Down
4 changes: 0 additions & 4 deletions packages/auto-install/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"lib": ["es6"],
"module": "esnext"
},
"include": [
"src/**/*",
"types/**/*"
Expand Down
2 changes: 1 addition & 1 deletion packages/beep/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"ci:test": "ava --verbose",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint --fix --cache lib test --ext .js,.ts",
"lint:js": "eslint --fix --cache lib test types --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"test": "ava"
},
Expand Down
12 changes: 6 additions & 6 deletions packages/beep/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Plugin } from 'rollup';

/**
* 🍣 A Rollup plugin that beeps when a build ends with errors.
*/
export default function beep(): Plugin;
import { Plugin } from 'rollup';

/**
* 🍣 A Rollup plugin that beeps when a build ends with errors.
*/
export default function beep(): Plugin;
8 changes: 1 addition & 7 deletions packages/buble/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"lib": ["es6"],
"module": "esnext",
"allowJs": true
},
"include": [
"src/**/*",
"types/**/*",
"typings-test.js"
"types/**/*"
]
}
2 changes: 1 addition & 1 deletion packages/dsv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ci:test": "pnpm run test -- --verbose",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint --fix --cache src test",
"lint:js": "eslint --fix --cache src test --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prebuild": "del-cli dist",
"prepare": "pnpm run build",
Expand Down
2 changes: 1 addition & 1 deletion packages/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"ci:test": "pnpm run test -- --verbose",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write *.md",
"lint:js": "eslint --fix --cache lib test",
"lint:js": "eslint --fix --cache lib test --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prepublishOnly": "pnpm run lint",
"test": "ava"
Expand Down
2 changes: 1 addition & 1 deletion packages/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"ci:test": "pnpm run test -- --verbose",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write *.md",
"lint:js": "eslint --fix --cache src test",
"lint:js": "eslint --fix --cache src test --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prebuild": "del-cli dist",
"prepare": "pnpm run build",
Expand Down
2 changes: 1 addition & 1 deletion packages/inject/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ci:test": "pnpm run test -- --verbose && pnpm run test:ts",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint --fix --cache src test",
"lint:js": "eslint --fix --cache src test --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prebuild": "del-cli dist",
"prepare": "pnpm run build",
Expand Down
26 changes: 12 additions & 14 deletions packages/inject/test/types.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
// @ts-check
import { dirname } from "path";
import { RollupOptions } from 'rollup';

import inject, { RollupInjectOptions } from "..";
import inject from '..';

/** @type {import("rollup").RollupOptions} */
const config = {
input: "main.js",
const config: RollupOptions = {
input: 'main.js',
output: {
file: "bundle.js",
format: "iife"
file: 'bundle.js',
format: 'iife'
},
plugins: [
inject({
include: "config.js",
exclude: "node_modules/**",
Promise: ["es6-promise", "Promise"],
$: "jquery",
include: 'config.js',
exclude: 'node_modules/**',
Promise: ['es6-promise', 'Promise'],
$: 'jquery',
modules: {
Promise: ["es6-promise", "Promise"],
$: "jquery"
Promise: ['es6-promise', 'Promise'],
$: 'jquery'
}
})
]
Expand Down
3 changes: 2 additions & 1 deletion packages/json/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
"ci:lint": "pnpm run build && pnpm run lint",
"ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}",
"ci:test": "pnpm run test -- --verbose && pnpm run test:ts",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:json && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint --fix --cache src test types --ext .js,.ts",
"lint:json": "prettier --write \"test/fixtures/!(garbage)/*.json\"",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prebuild": "del-cli dist",
"prepare": "pnpm run build",
Expand Down
4 changes: 1 addition & 3 deletions packages/json/test/fixtures/array/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
[
1, 2, 3
]
[1, 2, 3]
2 changes: 1 addition & 1 deletion packages/json/test/fixtures/basic/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"answer": 42
"answer": 42
}
2 changes: 1 addition & 1 deletion packages/json/test/fixtures/extensionless/config.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"answer": 42
"answer": 42
}
2 changes: 1 addition & 1 deletion packages/json/test/fixtures/extensionless/dir/index.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"Are extensionless imports and /index resolutions a good idea?": "No."
"Are extensionless imports and /index resolutions a good idea?": "No."
}
4 changes: 2 additions & 2 deletions packages/json/test/fixtures/named/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "this-should-be-excluded",
"version": "1.33.7"
"name": "this-should-be-excluded",
"version": "1.33.7"
}
2 changes: 1 addition & 1 deletion packages/legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ci:test": "pnpm run test -- --verbose",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint --fix --cache src test",
"lint:js": "eslint --fix --cache src test --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prebuild": "del-cli dist",
"prepare": "pnpm run build",
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 @@ -19,7 +19,7 @@
"ci:test": "pnpm run test -- --verbose",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint --fix --cache src test",
"lint:js": "eslint --fix --cache src test --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prebuild": "del-cli dist",
"prepare": "pnpm run build",
Expand Down
4 changes: 2 additions & 2 deletions packages/pluginutils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"ci:test": "pnpm run test -- --verbose",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint --fix --cache src --ext .js,.ts",
"lint:js": "eslint --fix --cache src test types --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prebuild": "del-cli dist",
"prepare": "pnpm run build",
Expand All @@ -47,14 +47,14 @@
"rollup": "^1.20.0"
},
"dependencies": {
"@types/estree": "0.0.39",
"estree-walker": "^1.0.1",
"micromatch": "^4.0.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"@rollup/plugin-typescript": "^3.0.0",
"@types/estree": "0.0.39",
"@types/jest": "^24.9.0",
"@types/micromatch": "^3.1.1",
"@types/node": "^12.12.25",
Expand Down
2 changes: 1 addition & 1 deletion packages/pluginutils/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
plugins: [
resolve(),
commonjs({ include: '../../node_modules/.pnpm/registry.npmjs.org/**' }),
typescript({ include: '**/*.{ts,js}' })
typescript({ include: '**/*.{ts,js}', module: 'esnext' })
],
external: Object.keys(pkg.dependencies).concat('path', 'util'),
output: [
Expand Down
2 changes: 1 addition & 1 deletion packages/pluginutils/src/attachScopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const attachScopes: AttachScopes = function attachScopes(ast, propertyName = 'sc
}

// create new block scope
if (node.type === 'BlockStatement' && !/Function/.test(parent!.type)) {
if (node.type === 'BlockStatement' && !/Function/.test(parent.type)) {
newScope = new Scope({
parent: scope,
block: true
Expand Down
5 changes: 3 additions & 2 deletions packages/pluginutils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"lib": ["es6"],
"esModuleInterop": true
"esModuleInterop": true,
"module": "commonjs"
},
"include": [
"src/**/*",
"test/**/*",
"types/**/*"
]
}
12 changes: 3 additions & 9 deletions packages/pluginutils/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
// eslint-disable-next-line import/no-unresolved
import { BaseNode } from 'estree';

export interface AttachedScope {
parent?: AttachedScope;
isBlockScope: boolean;
declarations: { [key: string]: boolean };
addDeclaration(
node: BaseNode,
isBlockDeclaration: boolean,
isVar: boolean
): void;
addDeclaration(node: BaseNode, isBlockDeclaration: boolean, isVar: boolean): void;
contains(name: string): boolean;
}

Expand All @@ -35,10 +32,7 @@ export function addExtension(filename: string, ext?: string): string;
* Each `Scope` object has a `scope.contains(name)` method that returns `true`
* if a given name is defined in the current scope or a parent scope.
*/
export function attachScopes(
ast: BaseNode,
propertyName?: string
): AttachedScope;
export function attachScopes(ast: BaseNode, propertyName?: string): AttachedScope;

/**
* Constructs a filter function which can be used to determine whether or not
Expand Down
2 changes: 1 addition & 1 deletion packages/strip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"ci:test": "pnpm run test -- --verbose",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint --fix --cache src test/test.js",
"lint:js": "eslint --fix --cache src test --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"pretest": "pnpm run build",
"test": "ava"
Expand Down
1 change: 1 addition & 0 deletions packages/strip/test/fixtures/assert/input.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
function foo(message) {
assert.equal(arguments.length, 1);
assert.equal(typeof arguments[0], 'string');
Expand Down
1 change: 1 addition & 0 deletions packages/strip/test/fixtures/super-method/input.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
class Foo {
bar() {
a();
Expand Down
6 changes: 4 additions & 2 deletions packages/strip/test/snapshots/test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ Generated by [AVA](https://ava.li).

> Snapshot 1
`function foo(message) {␊
`/* eslint-disable */␊
function foo(message) {␊
bar(message);␊
}␊
`
Expand Down Expand Up @@ -113,7 +114,8 @@ Generated by [AVA](https://ava.li).

> Snapshot 1
`class Foo {␊
`/* eslint-disable */␊
class Foo {␊
bar() {␊
a();␊
b();␊
Expand Down
Binary file modified packages/strip/test/snapshots/test.js.snap
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/sucrase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"ci:test": "pnpm run test -- --verbose",
"lint": "pnpm run lint:js && pnpm run lint:docs && pnpm run lint:package",
"lint:docs": "prettier --single-quote --write README.md",
"lint:js": "eslint --fix --cache src test",
"lint:js": "eslint --fix --cache src test --ext .js,.ts",
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package",
"prebuild": "del-cli dist",
"prepare": "pnpm run build",
Expand Down
Loading

0 comments on commit b1f4ffa

Please sign in to comment.