Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add ignorePattern option. #2834

Merged
merged 1 commit into from
Sep 1, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions lib/__tests__/ignore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,72 @@ describe("specified `ignorePath` file ignoring one file", () => {
});
});

describe("specified `ignorePattern` file ignoring one file", () => {
let results;
let actualCwd;

beforeAll(() => {
actualCwd = process.cwd();
process.chdir(__dirname);
});

afterAll(() => {
process.chdir(actualCwd);
});

beforeEach(() => {
return standalone({
files: [`${fixturesPath}/empty-block.css`],
config: {
rules: {
"block-no-empty": true
}
},
ignorePattern: "fixtures/empty-block.css"
}).then(data => (results = data.results));
});

it("no files read", () => {
expect(results.length).toBe(0);
});
});

describe("specified `ignorePattern` file ignoring two files", () => {
let results;
let actualCwd;

beforeAll(() => {
actualCwd = process.cwd();
process.chdir(__dirname);
});

afterAll(() => {
process.chdir(actualCwd);
});

beforeEach(() => {
return standalone({
files: [
`${fixturesPath}/empty-block.css`,
`${fixturesPath}/no-syntax-error.css`
],
config: {
rules: {
"block-no-empty": true
}
},
ignorePattern: [
"fixtures/empty-block.css",
"fixtures/no-syntax-error.css"
]
}).then(data => (results = data.results));
});

it("no files read", () => {
expect(results.length).toBe(0);
});
});

describe("using ignoreFiles with input files that would cause a postcss syntax error", () => {
let results;

Expand Down
5 changes: 5 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const minimistOptions = {
f: "formatter",
h: "help",
i: "ignore-path",
ip: "ignore-pattern",
id: "ignore-disables",
q: "quiet",
rd: "report-needless-disables",
Expand Down Expand Up @@ -77,6 +78,10 @@ const meowOptions = {
path can be absolute or relative to process.cwd(). By default, stylelint
looks for .stylelintignore in process.cwd().

--ignore-pattern, -ip

Pattern of files to ignore (in addition to those in .stylelintignore)

--syntax, -s

Specify a non-standard syntax. Options: "scss", "less", "sugarss".
Expand Down
3 changes: 2 additions & 1 deletion lib/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ module.exports = function(
} catch (readError) {
if (readError.code !== FILE_NOT_FOUND_ERROR_CODE) throw readError;
}
const ignorer = ignore().add(ignoreText);
const ignorePattern = options.ignorePattern || [];
const ignorer = ignore().add(ignoreText).add(ignorePattern);

const isValidCode = typeof code === "string";
if ((!files && !isValidCode) || (files && (code || isValidCode))) {
Expand Down