Meta tags:
description= The Stylelint module includes a lint() function that provides the Node.js API.;
Headings (most frequently used words):
example, the, config, code, cwd, node, js, api, options, returned, promise, result, object, syntax, errors, usage, examples, resolving, effective, for, file, abortsignal, files, globbyoptions, errored, output, postcssresults, report, results, maxwarningsexceeded, edit, info,
Text of the page (most frequently used words):
the (63), stylelint (22), code (19), config (18), lint (17), for (16), #result (16), #example (14), that (13), files (12), you (12), const (12), with (12), file (11), this (11), will (11), cwd (10), true (10), option (10), object (9), css (9), and (9), text (9), report (8), options (8), await (8), warning (8), edit (7), promise (7), fix (7), string (7), guide (7), returned (6), rules (6), use (6), node (6), all (6), myconfig (6), relative (6), have (6), rule (6), like (6), array (6), syntax (5), following (5), configuration (5), using (5), formatter (5), error (5), contains (5), when (5), opacity (5), objects (5), api (5), errors (4), results (4), errored (4), globbyoptions (4), abortsignal (4), postcss (4), line (4), configbasedir (4), resolves (4), color (4), invalid (4), path (4), property (4), things (4), stylesheets (4), not (4), source (4), range (4), containing (4), directory (4), are (4), effective (3), usage (3), customsyntax (3), can (3), resolveconfig (3), plugins (3), extends (3), linting (3), function (3), autofixed (3), instead (3), default (3), url (3), paths (3), does (3), err (3), see (3), about (3), editinfo (3), sourcecodetext (3), number (3), may (3), each (3), has (3), been (3), empty (3), block (3), severity (3), warnings (3), one (3), operation (3), set (3), globs (3), controller (3), cancel (3), signal (3), resolving (2), examples (2), info (2), maxwarningsexceeded (2), postcssresults (2), output (2), plugin (2), next (2), command (2), interface (2), cli (2), page (2), also (2), pass (2), would (2), cannot (2), found (2), return (2), undefined (2), standard (2), hex (2), filepath (2), used (2), available (2), value (2), pink (2), accepts (2), custom (2), your (2), verbose (2), glob (2), new (2), contain (2), reject (2), information (2), only (2), specific (2), slice (2), indices (2), column (2), change (2), might (2), look (2), enabled (2), provides (2), provided (2), feature (2), removed (2), problem (2), least (2), level (2), passed (2), migration (2), working (2), considered (2), both (2), home (2), previous, subset, normally, scss, modules, want, find, out, what, exact, without, actually, given, angle, hue, degree, notation, refer, documentation, details, note, builder, stringify, opts, parse, own, json, meta, import, configs, fileurltopath, stack, console, catch, try, single, recorded, region, multiple, ranges, overlap, first, apply, replacement, add, pair, based, remove, include, suggested, fixes, computeeditinfo, changed, matches, ignore, pattern, ignored, invalidoptionwarnings, https, docs, reference, deprecated, major, version, deprecation, deprecations, should, endcolumn, endline, triggered, identifier, input, maximum, amount, maxwarnings, foundwarnings, formatters, consume, formatted, problems, whichever, accumulated, lazyresults, boolean, registered, otherwise, returns, properties, more, detail, globby, globbing, though, optional, must, from, which, defaults, current, process, bother, looking, aborting, leave, workspace, partially, fixed, state, some, already, written, before, cancellation, abort, needed, resultpromise, abortcontroller, useful, long, running, consumers, language, servers, need, flight, document, changes, aborted, reason, future, release, experimental, addition, module, includes, awesome, changelog, maintainer, contributor, developer, ignoring, configuring, customizing, getting, started, user, search, github, demo, skip, main, content,
Text of the page (random words):
node js api stylelint skip to main content home rules demo github search home user guide getting started customizing configuring rules rules ignoring code command line interface cli node js api postcss plugin options errors warnings developer guide migration guide contributor guide maintainer guide about changelog awesome on this page node js api the stylelint module includes a lint function that provides the node js api const result await stylelint lint options options in addition to the standard options the node api accepts abortsignal warning this option is experimental and might change in a future release an abortsignal to cancel the lint operation when the signal is aborted stylelint lint will reject with the signal s reason this is useful for long running consumers like language servers that need to cancel in flight linting when a document changes const controller new abortcontroller const resultpromise stylelint lint code a config myconfig abortsignal controller signal cancel the lint if needed controller abort warning aborting a lint operation that has fix enabled with files may leave a workspace in a partially fixed state as some files may have already been written before cancellation config a configuration object stylelint does not bother looking for a configuration file e g stylelint config js if you use this option code a string to lint cwd the directory from which stylelint will look for files defaults to the current working directory returned by process cwd files a file glob or array of file globs relative globs are considered relative to globbyoptions cwd though both files and code are optional you must have one and cannot have both globbyoptions the options that are passed with files for example you can set a specific cwd to use when globbing paths relative globs in files are considered relative to this path by default globbyoptions cwd will be set by cwd for more detail usage see globby guide the returned promise stylelint lint returns a promise that resolves with an object containing the following properties code a string that contains the autofixed code if the fix option is set to true and the code option is provided otherwise it is undefined cwd the directory used as the working directory for the linting operation errored boolean if true at least one rule with an error level severity registered a problem output warning this property has been removed in 17 0 0 use report or code instead see the migration guide to 16 0 0 postcssresults an array containing all the accumulated postcss lazyresults report a string that contains the formatted problems using the default formatter or whichever you passed results an array containing all the stylelint result objects the objects that formatters consume maxwarningsexceeded an object containing the maximum number of warnings and the amount found e g maxwarnings 0 foundwarnings 12 result object source path to file css the filepath or postcss identifier like input css 1 errored true this is true if at least one rule with an error level severity triggered a warning warnings array of rule problem warning objects each like the following line 3 column 12 endline 4 endcolumn 15 rule block no empty severity error text you should not have an empty block block no empty deprecations array of deprecation warning objects each like the following text feature x has been deprecated and will be removed in the next major version reference https stylelint io docs feature x md invalidoptionwarnings array of invalid option warning objects each like the following text invalid option x for rule y ignored true this is true if the file s path matches a provided ignore pattern autofixed true this is true if the fix option changed the source edit info when the computeeditinfo option is enabled a warning may include a fix property that provides information about suggested fixes range number number the pair of 0 based indices in source code text to remove text string the text to add for example to change a opacity 10 to a opacity 0 1 the editinfo might look like line column rule fix range 13 16 indices of 10 text 0 1 replacement text to apply this edit you would const sourcecodetext a opacity 10 const result sourcecodetext slice 0 edit range 0 a opacity edit text 0 1 sourcecodetext slice edit range 1 a opacity 0 1 only a single editinfo will be recorded for a specific region in source code if multiple report ranges overlap only the first will contain editinfo syntax errors stylelint lint does not reject the promise when your css contains syntax errors it resolves with an object see the returned promise that contains information about the syntax error usage examples example a as config contains no relative paths for extends or plugins you do not have to use configbasedir try const result await stylelint lint config rules color no invalid hex files all my stylesheets css do things with result report result errored and result results catch err do things with err e g console error err stack example b if myconfig does contain relative paths for extends or plugins you do have to use configbasedir const result await stylelint lint config myconfig configbasedir url fileurltopath new url configs import meta url files all my stylesheets css example c using a string code instead of a file glob and the verbose formatter instead of the default json const result await stylelint lint code a color pink config myconfig formatter verbose do things with result report the report will be available as the value of the report property in the returned object example d using your own custom formatter function const result await stylelint lint config myconfig files all my stylesheets css formatter results example e using a custom syntax const result await stylelint lint config myconfig files all my stylesheets css customsyntax parse css opts stringify node builder note the customsyntax option also accepts a string refer to the options documentation for details example f using a string code and the fix option const result await stylelint lint code a color pink config rules hue degree notation angle fix true do things with result code the autofixed code will be available as the value of the code property in the returned object resolving the effective config for a file if you want to find out what exact configuration will be used for a file without actually linting it you can use the resolveconfig function given a file path it will return a promise that resolves with the effective configuration object const config await stylelint resolveconfig filepath config rules color no invalid hex true extends stylelint config standard stylelint config css modules plugins stylelint scss if a configuration cannot be found for a file resolveconfig will return a promise that resolves to undefined you can also pass the following subset of the options that you would normally pass to lint cwd config configbasedir customsyntax edit this page previous command line interface cli next postcss plugin options abortsignal config code cwd files globbyoptions the returned promise code cwd errored output postcssresults report results maxwarningsexceeded result object edit info syntax errors usage examples example a example b example c example d example e example f resolving the effective config for a file
|