Skip to content

Commit

Permalink
Merge branch 'main' into add-media-feature-name-value-no-unknown--wit…
Browse files Browse the repository at this point in the history
…ty-south-china-tiger-8b25eed791
  • Loading branch information
romainmenke committed Jun 10, 2023
2 parents d64cce8 + 7f51872 commit bc2833a
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-dingos-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: `max-nesting-depth` error for at-rules in Sass syntax
5 changes: 5 additions & 0 deletions .changeset/swift-pugs-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"stylelint": minor
---

Added: support for `.mjs` configuration files
2 changes: 1 addition & 1 deletion docs/user-guide/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Stylelint expects a configuration object, and looks for one in a:
- `stylelint` property in `package.json`
- `.stylelintrc` file
- `.stylelintrc.{cjs,js,json,yaml,yml}` file
- `stylelint.config.{cjs,js}` file exporting a JS object
- `stylelint.config.{cjs,mjs,js}` file

Starting from the current working directory, Stylelint stops searching when one of these is found. Alternatively, you can use the [`--config` or `configFile` option](options.md#configfile) to short-circuit the search.

Expand Down
10 changes: 5 additions & 5 deletions lib/__tests__/__snapshots__/cli.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ exports[`CLI --help 1`] = `
--config, -c <path_or_module>
A path to a specific configuration file (JSON, YAML, or CommonJS), or a
module name in "node_modules" that points to one. If no argument is
A path to a specific configuration file (JSON, YAML, CommonJS, or ES module),
or a module name in "node_modules" that points to one. If no argument is
provided, Stylelint will search for configuration files in the following
places, in this order:
- a "stylelint" property in "package.json"
- a ".stylelintrc" file (with or without filename extension:
".json", ".yaml", ".yml", ".js", and ".cjs" are available)
- a "stylelint.config.js" file exporting a JS object
- a ".stylelintrc" file
- a ".stylelintrc.{cjs,mjs,js,json,yaml,yml}" file
- a "stylelint.config.{cjs,mjs,js}" file
The search will begin in the working directory and move up the directory
tree until a configuration file is found.
Expand Down
10 changes: 5 additions & 5 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ const meowOptions = {
--config, -c <path_or_module>
A path to a specific configuration file (JSON, YAML, or CommonJS), or a
module name in "node_modules" that points to one. If no argument is
A path to a specific configuration file (JSON, YAML, CommonJS, or ES module),
or a module name in "node_modules" that points to one. If no argument is
provided, Stylelint will search for configuration files in the following
places, in this order:
- a "stylelint" property in "package.json"
- a ".stylelintrc" file (with or without filename extension:
".json", ".yaml", ".yml", ".js", and ".cjs" are available)
- a "stylelint.config.js" file exporting a JS object
- a ".stylelintrc" file
- a ".stylelintrc.{cjs,mjs,js,json,yaml,yml}" file
- a "stylelint.config.{cjs,mjs,js}" file
The search will begin in the working directory and move up the directory
tree until a configuration file is found.
Expand Down
17 changes: 17 additions & 0 deletions lib/rules/max-nesting-depth/__tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const { stripIndent } = require('common-tags');

const { messages, ruleName } = require('..');

testRule({
Expand Down Expand Up @@ -281,3 +283,18 @@ testRule({
},
],
});

testRule({
ruleName,
config: [1],
customSyntax: 'postcss-sass',

accept: [
{
code: stripIndent`
@media print
color: white
`,
},
],
});
4 changes: 2 additions & 2 deletions lib/rules/max-nesting-depth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ const rule = (primary, secondaryOptions) => {
function nestingDepth(node, level) {
const parent = node.parent;

if (parent == null) {
throw new Error('The parent node must exist');
if (!parent) {
return 0;
}

if (isIgnoreAtRule(parent)) {
Expand Down
5 changes: 5 additions & 0 deletions scripts/visual-config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const config = require('./visual-config.json');

module.exports = config;
3 changes: 3 additions & 0 deletions scripts/visual-config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import config from './visual-config.cjs';

export default config;
15 changes: 11 additions & 4 deletions scripts/visual.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/usr/bin/env bash
set -u

echo "Normal:"
node ../bin/stylelint.js visual.css --config=visual-config.json
echo "########## Compact formatter ##########"
echo ""
node ../bin/stylelint.js visual.css --config visual-config.mjs --formatter compact
echo ""

echo -e "\n\nVerbose:"
node ../bin/stylelint.js visual.css --config=visual-config.json --formatter verbose
echo ""
echo "########## Default formatter ##########"
node ../bin/stylelint.js visual.css --config visual-config.json

echo "########## Verbose formatter ##########"
node ../bin/stylelint.js visual.css --config visual-config.cjs --formatter verbose

0 comments on commit bc2833a

Please sign in to comment.