Skip to content

Commit

Permalink
fix(eslint): add config and docs to lint test, fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
theetrain committed Aug 17, 2017
1 parent 827da41 commit a606a92
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 40 deletions.
8 changes: 4 additions & 4 deletions config/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const path = require('path');
const path = require('path')

module.exports = {
rootDir: path.resolve('src'),
moduleNameMapper: {
"\\.modules\.scss$": "identity-obj-proxy",
"^.+\\.(css|scss)$": "<rootDir>/__mocks__/styleMock.js"
'\\.modules.scss$': 'identity-obj-proxy',
'^.+\\.(css|scss)$': '<rootDir>/__mocks__/styleMock.js'
},
setupTestFrameworkScriptFile: path.resolve('node_modules/jest-enzyme/lib/index.js')
};
}
36 changes: 19 additions & 17 deletions config/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import path from 'path';
import path from 'path'

import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'

import babel from 'rollup-plugin-babel';
import babel from 'rollup-plugin-babel'

import postcss from 'rollup-plugin-postcss';
import postcssModules from 'postcss-modules';
import sass from 'node-sass';
import autoprefixer from 'autoprefixer';
import postcss from 'rollup-plugin-postcss'
import postcssModules from 'postcss-modules'
import sass from 'node-sass'
import autoprefixer from 'autoprefixer' // eslint-disable-line import/no-extraneous-dependencies

const cssExportMap = {};
const cssExportMap = {}

/* eslint-disable no-shadow */
const sassPreprocessor = (content, id) => new Promise((resolve) => {
const result = sass.renderSync({ file: id });
resolve({ code: result.css.toString() });
});
const result = sass.renderSync({ file: id })
resolve({ code: result.css.toString() })
})
/* eslint-enable */

export default {
entry: path.resolve('./src/index.js'),
Expand Down Expand Up @@ -44,19 +46,19 @@ export default {
postcssModules({
globalModulePaths: [/src\/scss/, /src\/components\/(?!Button)/],
generateScopedName: 'TDS_[name]__[local]___[hash:base64:5]',
getJSON (id, exportTokens) {
cssExportMap[id] = exportTokens;
getJSON(id, exportTokens) {
cssExportMap[id] = exportTokens
}
})
],
getExportNamed: false,
getExport (id) {
return cssExportMap[id];
getExport(id) {
return cssExportMap[id]
}
}),
babel({
plugins: ['external-helpers'],
exclude: 'node_modules/**'
})
]
};
}
26 changes: 13 additions & 13 deletions config/styleguide.config.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
const path = require('path');
const path = require('path')

const version = require('../package.json').version;
const version = require('../package.json').version

const toggle = (path) => (
const toggle = path => ( // eslint-disable-line no-shadow
process.env.NODE_ENV === 'production' ? undefined : path
);
)

const compact = (array) => array.filter((element) => element !== undefined);
const compact = array => array.filter(element => element !== undefined)


module.exports = {
title: `TDS v${version}`,

skipComponentsWithoutExample: true,
getComponentPathLine(componentPath) {
let name = path.basename(componentPath, '.jsx');
let name = path.basename(componentPath, '.jsx')

// Grid has name-spaced sub-components
if (path.dirname(componentPath).includes('Grid')) {
name = 'Grid';
name = 'Grid'
}

// Steps has name-spaced sub-components
if (path.dirname(componentPath).includes('StepTracker')) {
name = 'Steps';
name = 'Steps'
}

// ExpandCollapse has name-spaced sub-components
if (path.dirname(componentPath).includes('ExpandCollapse')) {
name = 'ExpandCollapse';
name = 'ExpandCollapse'
}

// Link component has name-space sub-components
if (path.dirname(componentPath).includes('Link')) {
name = 'Link';
name = 'Link'
}

return `import { ${name} } from '@telusdigital/tds';`;
return `import { ${name} } from '@telusdigital/tds';`
},

showUsage: true,
Expand Down Expand Up @@ -147,7 +147,7 @@ module.exports = {
]
},
{
name: "Icons",
name: 'Icons',
components: path.resolve('src/components/Icon/Icon.jsx')
},
{
Expand Down Expand Up @@ -228,4 +228,4 @@ module.exports = {
linkHover: '#54595F'
}
}
};
}
10 changes: 5 additions & 5 deletions docs/components/Logo.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import React from 'react'

import {version} from '../../package.json';
import logo from './Logo.svg';
import { version } from '../../package.json'
import logo from './Logo.svg'

const Logo = () => (
<div>
Expand All @@ -11,6 +11,6 @@ const Logo = () => (

TDS v{version}
</div>
);
)

export default Logo;
export default Logo
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"deploy:docs": "node ./scripts/deploy-docs.js",
"deploy:package": "scripts/publish.sh",
"dev": "styleguidist server --config config/styleguide.config.js",
"lint:js": "eslint src --ext '.js,.jsx' --config config/.eslintrc.json --fix",
"lint:js": "eslint src config docs --ext '.js,.jsx' --config config/.eslintrc.json --fix",
"lint:scss": "stylelint 'src/scss/**/*.scss' --config config/.stylelintrc.json",
"lint:ec": "echint",
"lint": "yarn lint:js && yarn lint:scss && yarn lint:ec",
Expand Down

0 comments on commit a606a92

Please sign in to comment.