Skip to content

Commit

Permalink
Lint es-design-system and es-vue-base
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanMulready committed Jul 22, 2022
1 parent 3efe35e commit 88e90fb
Show file tree
Hide file tree
Showing 15 changed files with 4,450 additions and 716 deletions.
73 changes: 73 additions & 0 deletions es-vue-base/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
module.exports = {
settings: {
'import/resolver': {
webpack: {
config: {
resolve: {
extensions: ['*', '.js', '.vue', '.json'],
alias: {
'~': __dirname,
'@': __dirname,
},
},
},
},
},
},
extends: [
'eslint-config-energysage',
],
// Using one eslint file and overrides definition to handle sub directories
// https://eslint.org/docs/user-guide/configuring/configuration-files#how-do-overrides-work
overrides: [
{
files: [
'**/icons/**',
],
// Disable max length to allow for long paths in svg components
rules: {
'max-len': 'off',
},
},
// https://github.com/jest-community/eslint-plugin-jest#readme
{
files: [
'**/jest**',
'**/*spec.*',
],
env: {
jest: true,
},
extends: [
'plugin:jest/recommended',
'plugin:jest/style',
],
plugins: ['jest'],
globals: {
// From jest.vue.config.js
testid: 'readonly',
axe: 'readonly',
},
rules: {
'jest/no-standalone-expect': [
'error',
{ additionalTestBlockFunctions: ['test', 'each.test'] },
],
},

},
],
rules: {
// Disable/Enable any custom rules for your project
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: [
'**/*rollup*',
'**/*jest*',
'**/*spec*',
],
},
],
},
};
22 changes: 11 additions & 11 deletions es-vue-base/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const devPresets = ['@vue/babel-preset-app'];
const buildPresets = [
[
'@babel/preset-env',
// Config for @babel/preset-env
{
// Example: Always transpile optional chaining/nullish coalescing
// include: [
// /(optional-chaining|nullish-coalescing)/
// ],
},
],
[
'@babel/preset-env',
// Config for @babel/preset-env
{
// Example: Always transpile optional chaining/nullish coalescing
// include: [
// /(optional-chaining|nullish-coalescing)/
// ],
},
],
];
module.exports = {
presets: (process.env.NODE_ENV === 'development' ? devPresets : buildPresets),
presets: (process.env.NODE_ENV === 'development' ? devPresets : buildPresets),
};
236 changes: 118 additions & 118 deletions es-vue-base/build/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,160 +12,160 @@ import minimist from 'minimist';

// Get browserslist config and remove ie from es build targets
const esbrowserslist = fs.readFileSync('./.browserslistrc')
.toString()
.split('\n')
.filter((entry) => entry && entry.substring(0, 2) !== 'ie');
.toString()
.split('\n')
.filter((entry) => entry && entry.substring(0, 2) !== 'ie');

// Extract babel preset-env config, to combine with esbrowserslist
const babelPresetEnvConfig = require('../babel.config')
.presets.filter((entry) => entry[0] === '@babel/preset-env')[0][1];
.presets.filter((entry) => entry[0] === '@babel/preset-env')[0][1];

const argv = minimist(process.argv.slice(2));

const projectRoot = path.resolve(__dirname, '..');

const baseConfig = {
input: 'src/entry.js',
plugins: {
preVue: [
alias({
entries: [
{
find: '@',
replacement: `${path.resolve(projectRoot, 'src')}`,
},
input: 'src/entry.js',
plugins: {
preVue: [
alias({
entries: [
{
find: '@',
replacement: `${path.resolve(projectRoot)}`,
},
],
}),
],
}),
],
replace: {
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify('production'),
},
vue: {
css: true,
template: {
isProduction: true,
},
},
postVue: [
resolve({
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
}),
commonjs(),
],
babel: {
exclude: 'node_modules/**',
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
babelHelpers: 'bundled',
replace: {
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify('production'),
},
vue: {
css: true,
template: {
isProduction: true,
},
},
postVue: [
resolve({
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
}),
commonjs(),
],
babel: {
exclude: 'node_modules/**',
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue'],
babelHelpers: 'bundled',
},
},
},
};

// ESM/UMD/IIFE shared settings: externals
// Refer to https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
const external = [
// list external dependencies, exactly the way it is written in the import statement.
// eg. 'jquery'
'vue',
// list external dependencies, exactly the way it is written in the import statement.
// eg. 'jquery'
'vue',
];

// UMD/IIFE shared settings: output.globals
// Refer to https://rollupjs.org/guide/en#output-globals for details
const globals = {
// Provide global variable names to replace your external imports
// eg. jquery: '$'
vue: 'Vue',
// Provide global variable names to replace your external imports
// eg. jquery: '$'
vue: 'Vue',
};

// Customize configs for individual targets
const buildFormats = [];
if (!argv.format || argv.format === 'es') {
const esConfig = {
...baseConfig,
input: 'src/entry.esm.js',
external,
output: {
file: 'dist/es-vue-base.esm.js',
format: 'esm',
exports: 'named',
},
plugins: [
replace(baseConfig.plugins.replace),
...baseConfig.plugins.preVue,
vue(baseConfig.plugins.vue),
...baseConfig.plugins.postVue,
babel({
...baseConfig.plugins.babel,
presets: [
[
'@babel/preset-env',
{
...babelPresetEnvConfig,
targets: esbrowserslist,
},
],
const esConfig = {
...baseConfig,
input: 'src/entry.esm.js',
external,
output: {
file: 'dist/es-vue-base.esm.js',
format: 'esm',
exports: 'named',
},
plugins: [
replace(baseConfig.plugins.replace),
...baseConfig.plugins.preVue,
vue(baseConfig.plugins.vue),
...baseConfig.plugins.postVue,
babel({
...baseConfig.plugins.babel,
presets: [
[
'@babel/preset-env',
{
...babelPresetEnvConfig,
targets: esbrowserslist,
},
],
],
}),
],
}),
],
};
buildFormats.push(esConfig);
};
buildFormats.push(esConfig);
}

if (!argv.format || argv.format === 'cjs') {
const umdConfig = {
...baseConfig,
external,
output: {
compact: true,
file: 'dist/es-vue-base.ssr.js',
format: 'cjs',
name: 'EsVueBase',
exports: 'auto',
globals,
},
plugins: [
replace(baseConfig.plugins.replace),
...baseConfig.plugins.preVue,
vue({
...baseConfig.plugins.vue,
template: {
...baseConfig.plugins.vue.template,
optimizeSSR: true,
const umdConfig = {
...baseConfig,
external,
output: {
compact: true,
file: 'dist/es-vue-base.ssr.js',
format: 'cjs',
name: 'EsVueBase',
exports: 'auto',
globals,
},
}),
...baseConfig.plugins.postVue,
babel(baseConfig.plugins.babel),
],
};
buildFormats.push(umdConfig);
plugins: [
replace(baseConfig.plugins.replace),
...baseConfig.plugins.preVue,
vue({
...baseConfig.plugins.vue,
template: {
...baseConfig.plugins.vue.template,
optimizeSSR: true,
},
}),
...baseConfig.plugins.postVue,
babel(baseConfig.plugins.babel),
],
};
buildFormats.push(umdConfig);
}

if (!argv.format || argv.format === 'iife') {
const unpkgConfig = {
...baseConfig,
external,
output: {
compact: true,
file: 'dist/es-vue-base.min.js',
format: 'iife',
name: 'EsVueBase',
exports: 'auto',
globals,
},
plugins: [
replace(baseConfig.plugins.replace),
...baseConfig.plugins.preVue,
vue(baseConfig.plugins.vue),
...baseConfig.plugins.postVue,
babel(baseConfig.plugins.babel),
terser({
const unpkgConfig = {
...baseConfig,
external,
output: {
ecma: 5,
compact: true,
file: 'dist/es-vue-base.min.js',
format: 'iife',
name: 'EsVueBase',
exports: 'auto',
globals,
},
}),
],
};
buildFormats.push(unpkgConfig);
plugins: [
replace(baseConfig.plugins.replace),
...baseConfig.plugins.preVue,
vue(baseConfig.plugins.vue),
...baseConfig.plugins.postVue,
babel(baseConfig.plugins.babel),
terser({
output: {
ecma: 5,
},
}),
],
};
buildFormats.push(unpkgConfig);
}

// Export config
Expand Down
Loading

0 comments on commit 88e90fb

Please sign in to comment.