Skip to content

Instantly share code, notes, and snippets.

@evanpurkhiser
Created January 31, 2019 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evanpurkhiser/ba3bba705a765c424ecefb791998331a to your computer and use it in GitHub Desktop.
Save evanpurkhiser/ba3bba705a765c424ecefb791998331a to your computer and use it in GitHub Desktop.
/*eslint-env node*/
/*eslint import/no-nodejs-modules:0 */
const path = require('path');
const config = {
extends: ['sentry-app'],
globals: {
GSTestStubs: true,
MockApiClient: true,
require: false,
Sentry: true,
TestStubs: true,
tick: true,
},
rules: {},
};
/**
* The import/resolver plugin uses a webpack configuration to determine import
* resolution, because getsentry is built in context of sentry the
* webpack.config determines the path to sentry by looking at the location of
* the python module.
*
* If we ARE NOT in a virtual environment, which some editors which execute
* eslint may not be, we will not be able to load sentrys webpack config,
* default to a configuration that only aliases getsentry modules.
*/
const staticPrefix = path.join(__dirname, 'static/getsentry');
// When we're unable to resolve the location of sentry, we must provide the
// list of modules that sentry would provide for getsentry.
const sentryProvidedModules = [
'create-react-class',
'emotion',
'emotion-theming',
'grid-emotion',
'jquery',
'js-cookie',
'moment',
'prop-types',
'react',
'react-bootstrap',
'react-bootstrap/lib/Modal',
'react-dom',
'react-emotion',
'react-router',
'reflux',
];
const externals = sentryProvidedModules.reduce(
(a, c) => Object.assign({}, a, {[c]: null}),
{}
);
let appConfig = {
externals,
resolve: {
alias: {
getsentry: path.join(staticPrefix, 'gsApp'),
admin: path.join(staticPrefix, 'gsAdmin'),
},
extensions: ['.js', '.jsx'],
},
};
/**
* If possible, attempt to load the real webpack configuration to allow proper
* linting of sentry imports.
*/
try {
[appConfig] = require('./webpack.config');
} catch (e) {
// If we cannot load the configuration, disable resolution of sentry imports,
// as eslint will not know where to find them.
config.rules['import/no-unresolved'] = ['error', {ignore: ['^sentry/.*']}];
}
console.log(appConfig);
config.settings = {
'import/resolver': {webpack: {config: appConfig}},
};
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment