Skip to content

Commit

Permalink
fix: Improve global and Node integration. (#8)
Browse files Browse the repository at this point in the history
* Add node preset.

* Fix danger.

* Improve globals.
  • Loading branch information
milesj authored Sep 16, 2019
1 parent f75536a commit 3b565a7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/require.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
node-version: 12
- name: Setup
run: yarn install --frozen-lockfile --ignore-engines
- name: Build
run: yarn run build
- name: Run Danger CI
run: yarn danger ci --use-github-checks
env:
Expand Down
9 changes: 8 additions & 1 deletion packages/config-eslint/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const { IGNORE_PATHS } = require('@airbnb/nimbus-common/constants');
/**
* @typedef {object} ConfigOptions
* @property {boolean} [next]
* @property {boolean} [node]
* @property {boolean} [prettier]
* @property {boolean} [typescript]
*/
Expand All @@ -26,6 +27,7 @@ function fromHere(filePath) {
*/
exports.getExtendsList = function getExtendsList({
next = false,
node = false,
prettier = false,
typescript = false,
}) {
Expand All @@ -41,7 +43,12 @@ exports.getExtendsList = function getExtendsList({
paths.push(fromHere('presets/typescript.js'));
}

// Prettier
// Node
if (node) {
paths.push(fromHere('presets/node.js'));
}

// Prettier (must be last)
if (prettier) {
paths.push(fromHere('presets/prettier.js'));

Expand Down
10 changes: 9 additions & 1 deletion packages/config-eslint/presets/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ module.exports = {

globals: {
__DEV__: 'readonly',
jsdom: 'readonly',
// Metrics and analytics providers
ga: 'readonly',
newrelic: 'readonly',
// Mostly for easier compatibility between browsers, workers, etc
global: 'readonly',
// Mostly references to `process.env.NODE_ENV`
process: 'readonly',
},

env: {
Expand Down Expand Up @@ -55,6 +60,9 @@ module.exports = {
{
files: [`*.test.${EXTS_GROUP}`],
plugins: ['jest'],
globals: {
jsdom: 'readonly',
},
env: {
jest: true,
node: true,
Expand Down
6 changes: 6 additions & 0 deletions packages/config-eslint/presets/node.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
env: {
browser: false,
node: true,
},
};
3 changes: 2 additions & 1 deletion packages/nimbus/configs/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ const { getExtendsList, getIgnoreList } = require('@airbnb/config-eslint');
const { getSettings } = require('@airbnb/nimbus-common');

const { tool } = process.beemo;
const { next } = getSettings();
const { next, node } = getSettings();

module.exports = {
extends: getExtendsList({
next,
node,
prettier: tool.isPluginEnabled('driver', 'prettier'),
typescript: tool.isPluginEnabled('driver', 'typescript'),
}),
Expand Down

0 comments on commit 3b565a7

Please sign in to comment.