Skip to content

Commit

Permalink
Bump prettier from 1.19.1 to 2.0.2 (#4669)
Browse files Browse the repository at this point in the history
* Bump prettier from 1.19.1 to 2.0.2

Bumps [prettier](https://github.com/prettier/prettier) from 1.19.1 to 2.0.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](prettier/prettier@1.19.1...2.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Prettier 2.0 fixes (#4679)

* Bump prettier from 1.19.1 to 2.0.2

Bumps [prettier](https://github.com/prettier/prettier) from 1.19.1 to 2.0.2.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](prettier/prettier@1.19.1...2.0.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Add `endOfLine: "lf"` Prettier option

* Prettier 2.0 fixes

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Stephen Edgar <stephen@netweb.com.au>
  • Loading branch information
dependabot-preview[bot] and ntwb committed Apr 2, 2020
1 parent 5c6f489 commit 551dcb5
Show file tree
Hide file tree
Showing 125 changed files with 188 additions and 214 deletions.
1 change: 1 addition & 0 deletions .prettierrc.js
Expand Up @@ -3,6 +3,7 @@
// https://prettier.io/docs/en/options.html
module.exports = {
arrowParens: 'always',
endOfLine: 'lf',
printWidth: 100,
singleQuote: true,
trailingComma: 'all',
Expand Down
16 changes: 8 additions & 8 deletions docs/developer-guide/plugins.md
Expand Up @@ -21,11 +21,11 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
expected: "Expected ..."
});

module.exports = stylelint.createPlugin(ruleName, function(
module.exports = stylelint.createPlugin(ruleName, function (
primaryOption,
secondaryOptionObject
) {
return function(postcssRoot, postcssResult) {
return function (postcssRoot, postcssResult) {
const validOptions = stylelint.utils.validateOptions(
postcssResult,
ruleName,
Expand Down Expand Up @@ -80,11 +80,11 @@ const messages = stylelint.utils.ruleMessages(ruleName, {
expected: "Expected ..."
});

module.exports = stylelint.createPlugin(ruleName, function(
module.exports = stylelint.createPlugin(ruleName, function (
primaryOption,
secondaryOptionObject
) {
return function(postcssRoot, postcssResult) {
return function (postcssRoot, postcssResult) {
const validOptions = stylelint.utils.validateOptions(
postcssResult,
ruleName,
Expand All @@ -97,9 +97,9 @@ module.exports = stylelint.createPlugin(ruleName, function(
return;
}

return new Promise(function(resolve) {
return new Promise(function (resolve) {
// some async operation
setTimeout(function() {
setTimeout(function () {
// ... some logic ...
stylelint.utils.report({
/* .. */
Expand Down Expand Up @@ -152,7 +152,7 @@ const allowableAtRules = [
];

function myPluginRule(primaryOption, secondaryOptionObject) {
return function(postcssRoot, postcssResult) {
return function (postcssRoot, postcssResult) {
const defaultedOptions = Object.assign({}, secondaryOptionObject, {
ignoreAtRules: allowableAtRules.concat(options.ignoreAtRules || [])
});
Expand Down Expand Up @@ -189,7 +189,7 @@ All rules share a common signature. They are a function that accepts two argumen
Here's an example of a plugin that runs `color-hex-case` only if there is a special directive `@@check-color-hex-case` somewhere in the stylesheet:

```js
module.exports = stylelint.createPlugin(ruleName, function(expectation) {
module.exports = stylelint.createPlugin(ruleName, function (expectation) {
const runColorHexCase = stylelint.rules["color-hex-case"](expectation);

return (root, result) => {
Expand Down
6 changes: 3 additions & 3 deletions docs/developer-guide/processors.md
Expand Up @@ -11,13 +11,13 @@ Processor modules are functions that accept an options object and return an obje

```js
// my-processor.js
module.exports = function(options) {
module.exports = function (options) {
return {
code: function(input, filepath) {
code: function (input, filepath) {
// ...
return transformedCode;
},
result: function(stylelintResult, filepath) {
result: function (stylelintResult, filepath) {
// ...
return transformedResult;
}
Expand Down
14 changes: 7 additions & 7 deletions docs/user-guide/usage/node-api.md
Expand Up @@ -3,7 +3,7 @@
The stylelint module includes a `lint()` function that provides the Node.js API.

```js
stylelint.lint(options).then(function(resultObject) {
stylelint.lint(options).then(function (resultObject) {
/* .. */
});
```
Expand Down Expand Up @@ -91,11 +91,11 @@ stylelint
config: { rules: "color-no-invalid-hex" },
files: "all/my/stylesheets/*.css"
})
.then(function(data) {
.then(function (data) {
// do things with data.output, data.errored,
// and data.results
})
.catch(function(err) {
.catch(function (err) {
// do things with err e.g.
console.error(err.stack);
});
Expand All @@ -112,7 +112,7 @@ stylelint
configBasedir: path.join(__dirname, "configs"),
files: "all/my/stylesheets/*.css"
})
.then(function() {
.then(function () {
/* .. */
});
```
Expand All @@ -128,7 +128,7 @@ stylelint
config: myConfig,
formatter: "verbose"
})
.then(function() {
.then(function () {
/* .. */
});
```
Expand All @@ -142,11 +142,11 @@ stylelint
.lint({
config: myConfig,
files: "all/my/stylesheets/*.scss",
formatter: function(stylelintResults) {
formatter: function (stylelintResults) {
/* .. */
}
})
.then(function() {
.then(function () {
/* .. */
});
```
5 changes: 1 addition & 4 deletions lib/__tests__/disableRanges.test.js
Expand Up @@ -645,8 +645,5 @@ it('enable rule without disabling rule', () => {
});

function testDisableRanges(source, cb) {
return postcss()
.use(assignDisabledRanges)
.process(source, { from: undefined })
.then(cb);
return postcss().use(assignDisabledRanges).process(source, { from: undefined }).then(cb);
}
2 changes: 1 addition & 1 deletion lib/__tests__/fixtures/processor-fenced-blocks.js
Expand Up @@ -2,7 +2,7 @@

const execall = require('execall');

module.exports = function(options = {}) {
module.exports = function (options = {}) {
const specialMessage = options.specialMessage || 'was processed';

return {
Expand Down
2 changes: 1 addition & 1 deletion lib/__tests__/fixtures/processor-triple-question-marks.js
Expand Up @@ -2,7 +2,7 @@

const execall = require('execall');

module.exports = function() {
module.exports = function () {
let found = false;

return {
Expand Down
7 changes: 4 additions & 3 deletions lib/assignDisabledRanges.js
Expand Up @@ -37,7 +37,7 @@ function createDisableRange(start, strictStart, end, strictEnd) {
* @param {PostcssResult} result
* @returns {PostcssResult}
*/
module.exports = function(root, result) {
module.exports = function (root, result) {
result.stylelint = result.stylelint || {
disabledRanges: {},
ruleSeverities: {},
Expand Down Expand Up @@ -155,8 +155,9 @@ module.exports = function(root, result) {
getCommandRules(enableCommand, comment.text).forEach((ruleToEnable) => {
// TODO TYPES
// need fallback if endLine will be undefined
const endLine =
/** @type {number} */ (comment.source && comment.source.end && comment.source.end.line);
const endLine = /** @type {number} */ (comment.source &&
comment.source.end &&
comment.source.end.line);

if (ruleToEnable === ALL_RULES) {
if (
Expand Down
69 changes: 33 additions & 36 deletions lib/augmentConfig.js
Expand Up @@ -256,42 +256,39 @@ function addPluginFunctions(config) {

const normalizedPlugins = Array.isArray(config.plugins) ? config.plugins : [config.plugins];

const pluginFunctions = normalizedPlugins.reduce(
(result, pluginLookup) => {
let pluginImport = dynamicRequire(pluginLookup);

// Handle either ES6 or CommonJS modules
pluginImport = pluginImport.default || pluginImport;

// A plugin can export either a single rule definition
// or an array of them
const normalizedPluginImport = Array.isArray(pluginImport) ? pluginImport : [pluginImport];

normalizedPluginImport.forEach((pluginRuleDefinition) => {
if (!pluginRuleDefinition.ruleName) {
throw configurationError(
'stylelint v3+ requires plugins to expose a ruleName. ' +
`The plugin "${pluginLookup}" is not doing this, so will not work ` +
'with stylelint v3+. Please file an issue with the plugin.',
);
}

if (!pluginRuleDefinition.ruleName.includes('/')) {
throw configurationError(
'stylelint v7+ requires plugin rules to be namespaced, ' +
'i.e. only `plugin-namespace/plugin-rule-name` plugin rule names are supported. ' +
`The plugin rule "${pluginRuleDefinition.ruleName}" does not do this, so will not work. ` +
'Please file an issue with the plugin.',
);
}

result[pluginRuleDefinition.ruleName] = pluginRuleDefinition.rule;
});

return result;
},
/** @type {{[k: string]: Function}} */ ({}),
);
const pluginFunctions = normalizedPlugins.reduce((result, pluginLookup) => {
let pluginImport = dynamicRequire(pluginLookup);

// Handle either ES6 or CommonJS modules
pluginImport = pluginImport.default || pluginImport;

// A plugin can export either a single rule definition
// or an array of them
const normalizedPluginImport = Array.isArray(pluginImport) ? pluginImport : [pluginImport];

normalizedPluginImport.forEach((pluginRuleDefinition) => {
if (!pluginRuleDefinition.ruleName) {
throw configurationError(
'stylelint v3+ requires plugins to expose a ruleName. ' +
`The plugin "${pluginLookup}" is not doing this, so will not work ` +
'with stylelint v3+. Please file an issue with the plugin.',
);
}

if (!pluginRuleDefinition.ruleName.includes('/')) {
throw configurationError(
'stylelint v7+ requires plugin rules to be namespaced, ' +
'i.e. only `plugin-namespace/plugin-rule-name` plugin rule names are supported. ' +
`The plugin rule "${pluginRuleDefinition.ruleName}" does not do this, so will not work. ` +
'Please file an issue with the plugin.',
);
}

result[pluginRuleDefinition.ruleName] = pluginRuleDefinition.rule;
});

return result;
}, /** @type {{[k: string]: Function}} */ ({}));

config.pluginFunctions = pluginFunctions;

Expand Down
2 changes: 1 addition & 1 deletion lib/createPlugin.js
Expand Up @@ -5,7 +5,7 @@
* @param {Function} rule
* @returns {{ruleName: string, rule: Function}}
*/
module.exports = function(ruleName, rule) {
module.exports = function (ruleName, rule) {
return {
ruleName,
rule,
Expand Down
2 changes: 1 addition & 1 deletion lib/createStylelint.js
Expand Up @@ -22,7 +22,7 @@ const STOP_DIR = IS_TEST ? path.resolve(__dirname, '..') : undefined;
* @param {import('stylelint').StylelintStandaloneOptions} options
* @returns {StylelintInternalApi}
*/
module.exports = function(options = {}) {
module.exports = function (options = {}) {
/** @type {Partial<StylelintInternalApi>} */
const stylelint = { _options: options };

Expand Down
6 changes: 3 additions & 3 deletions lib/createStylelintResult.js
Expand Up @@ -13,7 +13,7 @@ const _ = require('lodash');
* @param {import('stylelint').StylelintCssSyntaxError} [cssSyntaxError]
* @return {Promise<StylelintResult>}
*/
module.exports = function(stylelint, postcssResult, filePath, cssSyntaxError) {
module.exports = function (stylelint, postcssResult, filePath, cssSyntaxError) {
/** @type {StylelintResult} */
let stylelintResult;
/** @type {string | undefined} */
Expand Down Expand Up @@ -103,8 +103,8 @@ module.exports = function(stylelint, postcssResult, filePath, cssSyntaxError) {

return stylelint.getConfigForFile(filePath).then((configForFile) => {
// TODO TYPES handle possible null here
const config =
/** @type {{ config: import('stylelint').StylelintConfig, filepath: string }} */ (configForFile).config;
const config = /** @type {{ config: import('stylelint').StylelintConfig, filepath: string }} */ (configForFile)
.config;
const file = source || (cssSyntaxError && cssSyntaxError.file);

if (config.resultProcessors) {
Expand Down
2 changes: 1 addition & 1 deletion lib/dynamicRequire.js
Expand Up @@ -5,6 +5,6 @@
* @param {string} name
* @return {any} any module
*/
module.exports = function(name) {
module.exports = function (name) {
return require(name);
};
2 changes: 1 addition & 1 deletion lib/formatters/__tests__/prepareFormatterOutput.js
Expand Up @@ -9,7 +9,7 @@ symbolConversions.set('✔', '√');
symbolConversions.set('⚠', '‼');
symbolConversions.set('✖', '×');

module.exports = function(results, formatter) {
module.exports = function (results, formatter) {
let output = stripAnsi(formatter(results)).trim();

symbolConversions.forEach((win, nix) => {
Expand Down
7 changes: 2 additions & 5 deletions lib/formatters/disableOptionsReportStringFormatter.js
Expand Up @@ -10,17 +10,14 @@ const path = require('path');
function logFrom(fromValue) {
if (fromValue.startsWith('<')) return fromValue;

return path
.relative(process.cwd(), fromValue)
.split(path.sep)
.join('/');
return path.relative(process.cwd(), fromValue).split(path.sep).join('/');
}

/**
* @param {import('stylelint').StylelintDisableOptionsReport} report
* @returns {string}
*/
module.exports = function(report) {
module.exports = function (report) {
if (!report) return '';

let output = '';
Expand Down
7 changes: 2 additions & 5 deletions lib/formatters/stringFormatter.js
Expand Up @@ -68,10 +68,7 @@ function invalidOptionsFormatter(results) {
function logFrom(fromValue) {
if (fromValue.startsWith('<')) return fromValue;

return path
.relative(process.cwd(), fromValue)
.split(path.sep)
.join('/');
return path.relative(process.cwd(), fromValue).split(path.sep).join('/');
}

/**
Expand Down Expand Up @@ -200,7 +197,7 @@ function formatter(messages, source) {
* @param {import('stylelint').StylelintResult[]} results
* @returns {string}
*/
module.exports = function(results) {
module.exports = function (results) {
let output = invalidOptionsFormatter(results);

output += deprecationsFormatter(results);
Expand Down
2 changes: 1 addition & 1 deletion lib/formatters/verboseFormatter.js
Expand Up @@ -8,7 +8,7 @@ const stringFormatter = require('./stringFormatter');
* @param {import('stylelint').StylelintResult[]} results
* @returns {string}
*/
module.exports = function(results) {
module.exports = function (results) {
let output = stringFormatter(results);

if (output === '') {
Expand Down
2 changes: 1 addition & 1 deletion lib/getConfigForFile.js
Expand Up @@ -13,7 +13,7 @@ const path = require('path');
* @param {string} [searchPath]
* @returns {ConfigPromise}
*/
module.exports = function(stylelint, searchPath = process.cwd()) {
module.exports = function (stylelint, searchPath = process.cwd()) {
const optionsConfig = stylelint._options.config;

if (optionsConfig !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion lib/getPostcssResult.js
Expand Up @@ -18,7 +18,7 @@ const postcssProcessor = postcss();
*
* @returns {Promise<import('postcss').Result>}
*/
module.exports = function(stylelint, options = {}) {
module.exports = function (stylelint, options = {}) {
const cached = options.filePath ? stylelint._postcssResultCache.get(options.filePath) : undefined;

if (cached) return Promise.resolve(cached);
Expand Down
2 changes: 1 addition & 1 deletion lib/invalidScopeDisables.js
Expand Up @@ -9,7 +9,7 @@
* @param {import('stylelint').StylelintConfig|undefined} config
* @returns {StylelintDisableOptionsReport}
*/
module.exports = function(results, config = {}) {
module.exports = function (results, config = {}) {
/** @type {StylelintDisableOptionsReport} */
const report = [];
const usedRules = new Set(Object.keys(config.rules || {}));
Expand Down

0 comments on commit 551dcb5

Please sign in to comment.