Skip to content

Commit

Permalink
Remove syntax option (#6420)
Browse files Browse the repository at this point in the history
  • Loading branch information
fpetrakov authored and ybiquitous committed Nov 8, 2022
1 parent 4fa526d commit 3c38634
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 65 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-insects-design.md
@@ -0,0 +1,5 @@
---
"stylelint": major
---

Removed: `syntax` option
5 changes: 0 additions & 5 deletions lib/__tests__/cli.test.js
Expand Up @@ -160,11 +160,6 @@ describe('buildCLI', () => {
expect(buildCLI(['--stdin-filename=foo.css']).flags.stdinFilename).toBe('foo.css');
});

it('flags.syntax', () => {
expect(buildCLI(['--syntax=less']).flags.syntax).toBe('less');
expect(buildCLI(['-s', 'less']).flags.syntax).toBe('less');
});

it('flags.version', () => {
expect(buildCLI(['--version']).flags.version).toBe(true);
expect(buildCLI(['-v']).flags.version).toBe(true);
Expand Down
32 changes: 0 additions & 32 deletions lib/__tests__/standalone-syntax.test.js
Expand Up @@ -150,38 +150,6 @@ it('rejects on unknown custom syntax option', async () => {
);
});

it('rejects on syntax option', async () => {
await expect(
standalone({
syntax: 'scss',
code: '',
config: { rules: { 'block-no-empty': true } },
}),
).rejects.toThrow(
'The "syntax" option is no longer available. You should install an appropriate syntax, e.g. postcss-scss, and use the "customSyntax" option',
);
});

it('rejects when customSyntax and syntax are set', async () => {
const config = {
rules: {
'block-no-empty': true,
},
};

await expect(
standalone({
config,
syntax: 'less',
customSyntax: `${fixturesPath}/custom-syntax`,
code: '$foo: bar; // foo;\nb {}',
formatter: stringFormatter,
}),
).rejects.toThrow(
'The "syntax" option is no longer available. You should install an appropriate syntax, e.g. postcss-scss, and use the "customSyntax" option',
);
});

describe('customSyntax set in the config', () => {
it('standalone with path to custom parser', async () => {
const config = {
Expand Down
10 changes: 0 additions & 10 deletions lib/cli.js
Expand Up @@ -44,7 +44,6 @@ const EXIT_CODE_ERROR = 2;
* @property {boolean} [reportDescriptionlessDisables]
* @property {number} [maxWarnings]
* @property {boolean} quiet
* @property {string} [syntax]
* @property {string} [version]
* @property {boolean} [allowEmptyInput]
*/
Expand Down Expand Up @@ -80,7 +79,6 @@ const EXIT_CODE_ERROR = 2;
* @property {boolean} [reportDescriptionlessDisables]
* @property {boolean} [disableDefaultIgnores]
* @property {number} [maxWarnings]
* @property {string} [syntax]
* @property {string[]} [ignorePattern]
* @property {boolean} [allowEmptyInput]
* @property {string} [files]
Expand Down Expand Up @@ -329,10 +327,6 @@ const meowOptions = {
stdinFilename: {
type: 'string',
},
syntax: {
alias: 's',
type: 'string',
},
version: {
alias: 'v',
type: 'boolean',
Expand Down Expand Up @@ -371,10 +365,6 @@ module.exports = async (argv) => {
optionsBase.quiet = cli.flags.quiet;
}

if (cli.flags.syntax) {
optionsBase.syntax = cli.flags.syntax;
}

if (cli.flags.customSyntax) {
optionsBase.customSyntax = getModulePath(process.cwd(), cli.flags.customSyntax);
}
Expand Down
11 changes: 0 additions & 11 deletions lib/getPostcssResult.js
Expand Up @@ -26,17 +26,6 @@ module.exports = async function getPostcssResult(stylelint, options = {}) {
return cached;
}

if (stylelint._options.syntax) {
let error = 'The "syntax" option is no longer available. ';

error +=
stylelint._options.syntax === 'css'
? 'You can remove the "--syntax" CLI flag as stylelint will now parse files as CSS by default'
: `You should install an appropriate syntax, e.g. postcss-scss, and use the "customSyntax" option`;

return Promise.reject(new Error(error));
}

const syntax = options.customSyntax
? getCustomSyntax(options.customSyntax)
: cssSyntax(stylelint, options.filePath);
Expand Down
2 changes: 0 additions & 2 deletions lib/standalone.js
Expand Up @@ -58,7 +58,6 @@ async function standalone({
reportDescriptionlessDisables,
reportInvalidScopeDisables,
reportNeedlessDisables,
syntax,
}) {
const startTime = Date.now();

Expand Down Expand Up @@ -103,7 +102,6 @@ async function standalone({
reportNeedlessDisables,
reportInvalidScopeDisables,
reportDescriptionlessDisables,
syntax,
customSyntax,
fix,
quiet,
Expand Down
5 changes: 1 addition & 4 deletions types/stylelint/index.d.ts
Expand Up @@ -208,7 +208,6 @@ declare module 'stylelint' {
codeFilename?: string;
filePath?: string;
codeProcessors?: CodeProcessor[];
syntax?: string;
customSyntax?: CustomSyntax;
};

Expand Down Expand Up @@ -240,8 +239,6 @@ declare module 'stylelint' {
reportNeedlessDisables?: boolean;
reportInvalidScopeDisables?: boolean;
maxWarnings?: number;
/** @deprecated Use `customSyntax` instead. Using this option will result in an error. */
syntax?: string;
customSyntax?: CustomSyntax;
formatter?: FormatterType | Formatter;
disableDefaultIgnores?: boolean;
Expand Down Expand Up @@ -533,7 +530,7 @@ declare module 'stylelint' {

export type DisableOptionsReport = DisableReportEntry[];

export type PostcssPluginOptions = Omit<LinterOptions, 'syntax' | 'customSyntax'> | Config;
export type PostcssPluginOptions = Omit<LinterOptions, 'customSyntax'> | Config;
}

const stylelint: stylelint.PublicApi;
Expand Down
1 change: 0 additions & 1 deletion types/stylelint/type-test.ts
Expand Up @@ -34,7 +34,6 @@ const options: Partial<LinterOptions> = {
reportNeedlessDisables: true,
ignorePath: ['foo'],
customSyntax: 'postcss-scss',
syntax: 'scss', // Removed but still accepted in type definition
config: {
overrides: [
{
Expand Down

0 comments on commit 3c38634

Please sign in to comment.