1
1
mirror of https://github.com/primer/css.git synced 2024-12-23 22:24:11 +03:00

chore: lint lib/

This commit is contained in:
Shawn Allen 2019-02-11 13:58:10 -08:00
parent 7a36ebd476
commit fecf4508bf
4 changed files with 18 additions and 19 deletions

View File

@ -11,10 +11,13 @@ module.exports = (nextConfig = {}) => {
assetPrefix,
pageExtensions: ['js', 'jsx', 'md', 'mdx'],
publicRuntimeConfig: Object.assign({
assetPrefix,
production: NODE_ENV === 'production'
}, nextConfig.publicRuntimeConfig),
publicRuntimeConfig: Object.assign(
{
assetPrefix,
production: NODE_ENV === 'production'
},
nextConfig.publicRuntimeConfig
),
webpack(config, options) {
if (!options.defaultLoaders) {
@ -23,7 +26,7 @@ module.exports = (nextConfig = {}) => {
)
}
const {dev, isServer} = options
const {dev} = options
// only attempt to sync locally and in CI
if (dev && !configured) {
@ -37,10 +40,7 @@ module.exports = (nextConfig = {}) => {
config.module.rules.push({
test: /\.mdx?$/,
use: [
options.defaultLoaders.babel,
require.resolve('./mdx-loader')
]
use: [options.defaultLoaders.babel, require.resolve('./mdx-loader')]
})
configured = true

View File

@ -24,9 +24,7 @@ module.exports = async function(source) {
emoji,
[textr, {plugins: [typographicBase]}]
],
hastPlugins: [
rehypePrism
],
hastPlugins: [rehypePrism],
compilers: [mdxExportJSONByDefault('frontMatter', data)]
},
getOptions(this),
@ -39,11 +37,12 @@ module.exports = async function(source) {
return callback(err)
}
let code = `
return callback(
null,
`
import React from 'react'
import {MDXTag} from '@mdx-js/tag'
${result}
`
return callback(null, code)
)
}

View File

@ -27,7 +27,7 @@ module.exports = options => {
let result = node
const source = nodeToString(node)
try {
parent.properties.className = (parent.properties.className || []).concat('language-' + lang)
parent.properties.className = (parent.properties.className || []).concat(`language-${lang}`)
result = refractor.highlight(source, lang)
} catch (err) {
if (/Unknown language/.test(err.message)) {
@ -52,8 +52,8 @@ function getLanguage(node, aliases) {
for (const classListItem of className) {
if (classListItem.slice(0, 9) === 'language-') {
let language = classListItem.slice(9).replace(/{.*/, '')
let alias = aliases[language]
const language = classListItem.slice(9).replace(/{.*/, '')
const alias = aliases[language]
return alias || language
}
}

View File

@ -2,7 +2,7 @@ module.exports = function rename(fn, options = {}) {
const {log = noop} = options
return (files, metal, done) => {
for (const [key, file] of Object.entries(files)) {
let dest = fn(file, key, files, metal)
const dest = fn(file, key, files, metal)
if (dest === true) {
log(`[rename] keep: ${key}`)
} else if (dest && dest !== key) {