mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 17:03:34 +00:00

The fixer for non-ascii-character does not typidally do the right thing. It removes the entire node, not the offending character. I discovered this when it removed the entire contents of a file and I wasn't sure which auto-fix rule was doing it. This commit adds a minimal test for the rule. The tests require that auto-fix results be supplied, so if someone wants to re-add auto-fixing to the rule, we'll have tests that it does the right thing. PR-URL: https://github.com/nodejs/node/pull/38413 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
27 lines
578 B
JavaScript
27 lines
578 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
common.skipIfEslintMissing();
|
|
|
|
const RuleTester = require('../../tools/node_modules/eslint').RuleTester;
|
|
const rule = require('../../tools/eslint-rules/non-ascii-character');
|
|
|
|
new RuleTester().run('non-ascii-characters', rule, {
|
|
valid: [
|
|
{
|
|
code: 'console.log("fhqwhgads")',
|
|
options: []
|
|
},
|
|
],
|
|
invalid: [
|
|
{
|
|
code: 'console.log("μ")',
|
|
options: [],
|
|
errors: [{ message: "Non-ASCII character 'μ' detected." }],
|
|
},
|
|
]
|
|
});
|