Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Improve global and Node integration. #8

Merged
merged 3 commits into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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