Skip to content

Commit

Permalink
chore(repo): update linting, prettier configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Jul 15, 2021
1 parent 9e31d93 commit e32a9e9
Show file tree
Hide file tree
Showing 20 changed files with 721 additions and 257 deletions.
70 changes: 10 additions & 60 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,28 @@
module.exports = {
extends: ['rollup', 'plugin:import/typescript'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['./tsconfig.eslint.json', './packages/*/tsconfig.json'],
tsconfigRootDir: __dirname
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/member-ordering': 'error',
'@typescript-eslint/no-inferrable-types': 'error',
'@typescript-eslint/no-redeclare': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
vars: 'local',
args: 'after-used',
ignoreRestSiblings: true
}
],
'import/extensions': [
'error',
'always',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never'
}
],
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/scripts/**/*.ts',
'**/*.test.*',
'**/test/**/*.js',
'**/test/**/*.ts'
],
optionalDependencies: false
}
],
'import/prefer-default-export': 'off',
'import/no-namespace': 'off',
'import/no-named-export': 'off',
'no-redeclare': 'off',
'no-unused-vars': 'off',
'prefer-object-spread': 'off',
'spaced-comment': 'off',
'prettier/prettier': [
'error',
{
arrowParens: 'always',
printWidth: 100,
singleQuote: true,
trailingComma: 'none',
plugins: ['prettier-plugin-package']
}
]
// disabling sort keys for now so we can get the rest of the linting shored up
'sort-keys': 'off',
'typescript-sort-keys/interface': 'off'
},
overrides: [
{
'files': ['**/test/**/*.{js,ts}'],
'files': ['**/fixtures/**'],
'rules': {
'no-console': 'off'
'no-console': 'off',
'import/extensions': 'off',
'import/no-unresolved': 'off'
}
},
{
'files': ['**/*.ts'],
'files': ['**/test/**'],
'rules': {
'no-undef': 'off'
'import/extensions': 'off'
}
}
]
],
};
4 changes: 2 additions & 2 deletions .github/workflows/node-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ on:
- synchronize
push:
branches:
- "*"
- '*'

jobs:
build:
runs-on: windows-2019

strategy:
matrix:
node: ["16", "14", "12"]
node: ['16', '14', '12']

name: Node v${{ matrix.node }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ on:
- synchronize
push:
branches:
- "*"
- '*'

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node: ["16", "14", "12"]
node: ['16', '14', '12']

name: Node v${{ matrix.node }}

Expand Down
3 changes: 3 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Note: This file is necessary so that prettier writes which happen in hooks and scripts match the
// same config that we're using from the eslint-config package.
module.exports = require('eslint-config-rollup/prettier');
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"scripts": {
"ci:coverage:submit": "node scripts/codecov",
"lint": "pnpm lint:docs && pnpm --no-bail lint:json && pnpm lint:package && pnpm lint:js",
"lint:docs": "prettier --single-quote --arrow-parens avoid --trailing-comma none --write **/README.md",
"lint:docs": "prettier --write .github/**/*.md **/README.md",
"lint:js": "eslint --cache packages scripts shared util --ext .js,.ts",
"lint:json": "prettier --write **/tsconfig*.json **/*.{yml,yaml}",
"lint:json": "prettier --write .github/**/*.yml **/tsconfig.json tsconfig.*.json pnpm-workspace.yaml",
"lint:package": "prettier --write **/package.json --plugin=prettier-plugin-package",
"plugin:release": "ts-node ./scripts/release.ts",
"preinstall": "node scripts/disallow-npm.js",
Expand All @@ -25,7 +25,7 @@
"codecov-lite": "2.0.0",
"conventional-commits-parser": "^3.2.1",
"del-cli": "4.0.0",
"eslint-config-rollup": "^1.0.0",
"eslint-config-rollup": "^2.0.4",
"esm": "^3.2.25",
"execa": "^5.1.1",
"globby": "^11.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ It's main purpose is to allow other tools for configuration of transpilation wit
```js
import { createBabelInputPluginFactory } from '@rollup/plugin-babel';

export default createBabelInputPluginFactory(babelCore => {
export default createBabelInputPluginFactory((babelCore) => {
function myPlugin() {
return {
visitor: {}
Expand Down
28 changes: 15 additions & 13 deletions packages/commonjs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'cjs',
format: 'cjs'
},
plugins: [commonjs()],
plugins: [commonjs()]
};
```

Expand Down Expand Up @@ -66,8 +66,8 @@ commonjs({
'!node_modules/logform/index.js',
'!node_modules/logform/format.js',
'!node_modules/logform/levels.js',
'!node_modules/logform/browser.js',
],
'!node_modules/logform/browser.js'
]
});
```

Expand Down Expand Up @@ -250,7 +250,7 @@ This is in line with how other bundlers handle this situation and is also the mo

var dep$1 = /*#__PURE__*/ Object.freeze({
__proto__: null,
default: dep,
default: dep
});

console.log(dep$1.default);
Expand Down Expand Up @@ -281,7 +281,7 @@ For these situations, you can change Rollup's behaviour either globally or per m
enumerable: true,
get: function () {
return n[k];
},
}
}
);
});
Expand Down Expand Up @@ -309,7 +309,9 @@ For these situations, you can change Rollup's behaviour either globally or per m
import * as dep$1 from 'dep';

function getDefaultExportFromNamespaceIfNotNamed(n) {
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1
? n['default']
: n;
}

var dep = getDefaultExportFromNamespaceIfNotNamed(dep$1);
Expand Down Expand Up @@ -357,9 +359,9 @@ export default {
output: {
file: 'bundle.js',
format: 'iife',
name: 'MyModule',
name: 'MyModule'
},
plugins: [resolve(), commonjs()],
plugins: [resolve(), commonjs()]
};
```

Expand All @@ -369,7 +371,7 @@ Symlinks are common in monorepos and are also created by the `npm link` command.

```js
commonjs({
include: /node_modules/,
include: /node_modules/
});
```

Expand All @@ -392,11 +394,11 @@ function cjsDetectionPlugin() {
moduleParsed({
id,
meta: {
commonjs: { isCommonJS },
},
commonjs: { isCommonJS }
}
}) {
console.log(`File ${id} is CommonJS: ${isCommonJS}`);
},
}
};
}
```
Expand Down
2 changes: 1 addition & 1 deletion packages/dsv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ This option could be used for converting numeric `string` values into `Number` v
```js
dsv({
processRow: (row, id) => {
Object.keys(row).forEach(key => {
Object.keys(row).forEach((key) => {
var value = row[key];
row[key] = isNaN(+value) ? value : +value;
});
Expand Down
4 changes: 2 additions & 2 deletions packages/dynamic-import-vars/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export default {
plugins: [
dynamicImportVars({
// options
}),
],
})
]
};
```

Expand Down
10 changes: 5 additions & 5 deletions packages/node-resolve/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export default {
input: 'src/index.js',
output: {
dir: 'output',
format: 'cjs',
format: 'cjs'
},
plugins: [nodeResolve()],
plugins: [nodeResolve()]
};
```

Expand Down Expand Up @@ -181,9 +181,9 @@ export default {
output: {
file: 'bundle.js',
format: 'iife',
name: 'MyModule',
name: 'MyModule'
},
plugins: [nodeResolve(), commonjs()],
plugins: [nodeResolve(), commonjs()]
};
```

Expand Down Expand Up @@ -218,7 +218,7 @@ The node resolve plugin uses `import` by default, you can opt into using the `re
```js
this.resolve(importee, importer, {
skipSelf: true,
custom: { 'node-resolve': { isRequire: true } },
custom: { 'node-resolve': { isRequire: true } }
});
```

Expand Down
18 changes: 9 additions & 9 deletions packages/pluginutils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default function myPlugin(options = {}) {
// only adds an extension if there isn't one already
id = addExtension(id); // `foo` -> `foo.js`, `foo.js` -> `foo.js`
id = addExtension(id, '.myext'); // `foo` -> `foo.myext`, `foo.js` -> `foo.js`
},
}
};
}
```
Expand Down Expand Up @@ -88,9 +88,9 @@ export default function myPlugin(options = {}) {
},
leave(node) {
if (node.scope) scope = scope.parent;
},
}
});
},
}
};
}
```
Expand Down Expand Up @@ -126,15 +126,15 @@ import { createFilter } from '@rollup/pluginutils';
export default function myPlugin(options = {}) {
// assume that the myPlugin accepts options of `options.include` and `options.exclude`
var filter = createFilter(options.include, options.exclude, {
resolve: '/my/base/dir',
resolve: '/my/base/dir'
});

return {
transform(code, id) {
if (!filter(id)) return;

// proceed with the transformation...
},
}
};
}
```
Expand All @@ -160,14 +160,14 @@ import { dataToEsm } from '@rollup/pluginutils';
const esModuleSource = dataToEsm(
{
custom: 'data',
to: ['treeshake'],
to: ['treeshake']
},
{
compact: false,
indent: '\t',
preferConst: false,
objectShorthand: false,
namedExports: true,
namedExports: true
}
);
/*
Expand Down Expand Up @@ -209,9 +209,9 @@ export default function myPlugin(options = {}) {
// do something with the declared names
// e.g. for `const {x, y: z} = ...` => declaredNames = ['x', 'z']
}
},
}
});
},
}
};
}
```
Expand Down
Loading

0 comments on commit e32a9e9

Please sign in to comment.